[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Wed Nov 12 18:41:18 CET 2008
SVN commit 883323 by netterfield:
Load images from the command line.
Change default palette to greyscale.
M +42 -1 libkstapp/commandlineparser.cpp
M +1 -0 libkstapp/commandlineparser.h
M +1 -1 libkstmath/palette.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.cpp #883322:883323
@@ -20,6 +20,9 @@
#include "curve.h"
#include "psd.h"
#include "histogram.h"
+#include "datamatrix.h"
+#include "image.h"
+#include "palette.h"
#include "kst_i18n.h"
namespace Kst {
@@ -238,6 +241,27 @@
_plotItem->update();
}
+void CommandLineParser::createImageInPlot(MatrixPtr m) {
+ ImagePtr image = _document->objectStore()->createObject<Image>();
+
+ image->changeToColorOnly(m, 0.0, 1.0, true, Palette::getPaletteList().at(0));
+
+ image->writeLock();
+ image->update();
+ image->unlock();
+
+ if (_doConsecutivePlots) {
+ CreatePlotForCurve *cmd = new CreatePlotForCurve();
+ cmd->createItem();
+ _plotItem = static_cast<PlotItem*>(cmd->item());
+ _plotItem->setName(QString("P-")+image->Name());
+ _plotItem->parentView()->appendToLayout(CurvePlacement::Auto, _plotItem);
+ }
+ PlotRenderItem *renderItem = _plotItem->renderItem(PlotRenderItem::Cartesian);
+ renderItem->addRelation(kst_cast<Relation>(image));
+ _plotItem->update();
+}
+
void CommandLineParser::createOrFindPlot( const QString plot_name ) {
bool found = false;
PlotItem *pi;
@@ -440,7 +464,24 @@
} else if (arg == "-z") {
QString field;
_setStringArg(field,i18n("Usage: -z <fieldname>\n"));
- //FIXME: Create the matrix, and the image
+ for (int i_file=0; i_file<_fileNames.size(); i_file++) {
+ QString file = _fileNames.at(i_file);
+ QFileInfo info(file);
+ if (!info.exists() || !info.isFile())
+ usage(i18n("file %1 does not exist\n").arg(file));
+
+ DataSourcePtr ds = DataSource::findOrLoadSource(_document->objectStore(), file);
+
+ DataMatrixPtr dm = _document->objectStore()->createObject<DataMatrix>();
+
+ dm->writeLock();
+ dm->change(ds, field, 0, 0, -1, -1, _doAve, _skip>0, _skip, 0.0, 0.0, 1.0, 1.0);
+
+ dm->update();
+ dm->unlock();
+
+ createImageInPlot(dm);
+ }
new_fileList = true;
dataPlotted = true;
} else { // arg is not an option... must be a file
--- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.h #883322:883323
@@ -62,6 +62,7 @@
DataVectorPtr createOrFindDataVector(QString field, DataSourcePtr ds);
void createOrFindPlot(const QString name);
void createCurveInPlot(VectorPtr xv, VectorPtr yv, VectorPtr ev=0);
+ void createImageInPlot(MatrixPtr m);
};
}
--- branches/work/kst/portto4/kst/src/libkstmath/palette.cpp #883322:883323
@@ -39,8 +39,8 @@
QStringList paletteList;
//TODO Populate a shared list of colors to return here.
+ paletteList.append(KstGrayscaleName);
paletteList.append(KstColorsName);
- paletteList.append(KstGrayscaleName);
return paletteList;
}
More information about the Kst
mailing list