[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Sat Feb 5 20:03:43 CET 2011
SVN commit 1219027 by netterfield:
Several changes:
-add kst data file property override capability to the command line
-add some missing notes to vectors
-improves some names for filter plugins.
-make the plugin kst file reader insensitive to the the name of the
output vector
M +4 -0 libkst/datasourcepluginfactory.cpp
M +2 -0 libkst/objectstore.cpp
M +11 -0 libkst/objectstore.h
M +4 -0 libkst/vector.cpp
M +2 -0 libkst/vector.h
M +17 -0 libkst/vectorfactory.cpp
M +7 -1 libkstapp/commandlineparser.cpp
M +5 -0 libkstapp/document.cpp
M +2 -2 plugins/dataobject/differentiation/differentiation.cpp
M +9 -2 plugins/filters/butterworth_bandpass/butterworth_bandpass.cpp
M +9 -2 plugins/filters/butterworth_bandstop/butterworth_bandstop.cpp
M +9 -2 plugins/filters/butterworth_highpass/butterworth_highpass.cpp
M +8 -2 plugins/filters/butterworth_lowpass/butterworth_lowpass.cpp
M +8 -1 plugins/filters/cumulativesum/cumulativesum.cpp
M +8 -2 plugins/filters/despike/filterdespike.cpp
--- branches/work/kst/portto4/kst/src/libkst/datasourcepluginfactory.cpp #1219026:1219027
@@ -65,13 +65,17 @@
return 0;
}
+ if (store->override.fileName.isEmpty()) {
DataSourcePtr dataSource = DataSourcePluginManager::loadSource(store, fileName, fileType);
if (dataSource) {
dataSource->parseProperties(propertyAttributes);
}
return dataSource;
+ } else {
+ return 0;
}
+}
}
--- branches/work/kst/portto4/kst/src/libkst/objectstore.cpp #1219026:1219027
@@ -33,6 +33,8 @@
ObjectStore::ObjectStore()
{
+ override.fileName = QString();
+ override.f0 = override.N = override.skip = override.doAve = -5;
}
--- branches/work/kst/portto4/kst/src/libkst/objectstore.h #1219026:1219027
@@ -80,6 +80,16 @@
// void deleteDependentObjects(const Primitive &p);
+ // some variables for overriding data source properties
+ // from the command line when opening a .kst file
+ struct {
+ QString fileName;
+ int f0;
+ int N;
+ int skip;
+ int doAve;
+ } override;
+
private:
Q_DISABLE_COPY(ObjectStore)
@@ -88,6 +98,7 @@
// objects are stored in these lists
DataSourceList _dataSourceList;
QList<ObjectPtr> _list;
+
};
--- branches/work/kst/portto4/kst/src/libkst/vector.cpp #1219026:1219027
@@ -605,6 +605,10 @@
}
}
+QString Vector::propertyString() const {
+ return i18n("Provider: %1").arg(_provider->Name());
+}
+
QString Vector::descriptionTip() const {
return i18n("Vector: %1\n %2 samples\n%3").arg(Name()).arg(length()).arg(_provider->descriptionTip());
}
--- branches/work/kst/portto4/kst/src/libkst/vector.h #1219026:1219027
@@ -162,6 +162,8 @@
virtual ObjectList<Primitive> outputPrimitives() const;
+ virtual QString propertyString() const;
+
protected:
/** current number of samples */
int _size;
--- branches/work/kst/portto4/kst/src/libkst/vectorfactory.cpp #1219026:1219027
@@ -228,6 +228,23 @@
count = attrs.value("count").toString().toInt();
skip = attrs.value("skip").toString().toInt();
doAve = attrs.value("doAve").toString() == "true" ? true : false;
+
+ // set overrides if set from command line
+ if (!store->override.fileName.isEmpty()) {
+ file = store->override.fileName;
+ }
+ if (store->override.f0 != -5) {
+ start = store->override.f0;
+ }
+ if (store->override.N != -5) {
+ count = store->override.N;
+ }
+ if (store->override.skip != -5 ) {
+ skip = store->override.skip;
+ }
+ if (store->override.doAve != -5) {
+ doAve = store->override.doAve;
+ }
if (attrs.value("descriptiveNameIsManual").toString() == "true") {
descriptiveName = attrs.value("descriptiveName").toString();
}
--- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.cpp #1219026:1219027
@@ -369,12 +369,16 @@
*ok = false;
} else if (arg == "-f") {
*ok = _setIntArg(&_startFrame, i18n("Usage: -f <startframe>\n"), true);
+ _document->objectStore()->override.f0 = _startFrame;
} else if (arg == "-n") {
- *ok = _setIntArg(&_numFrames, i18n("Usage: -f <numframes>\n"), true);
+ *ok = _setIntArg(&_numFrames, i18n("Usage: -n <numframes>\n"), true);
+ _document->objectStore()->override.N = _numFrames;
} else if (arg == "-s") {
*ok = _setIntArg(&_skip, i18n("Usage: -s <frames per sample>\n"));
+ _document->objectStore()->override.skip = _skip;
} else if (arg == "-a") {
_doAve = true;
+ _document->objectStore()->override.doAve = _doAve;
} else if (arg == "-P") {
QString plot_name;
*ok = _setStringArg(plot_name,i18n("Usage: -P <plotname>\n"));
@@ -561,6 +565,8 @@
new_fileList = true;
dataPlotted = true;
}
+ } else if (arg == "-F") {
+ *ok = _setStringArg(_document->objectStore()->override.fileName, i18n("Usage: -F <datafile>\n"));
} else if (arg == "--png") {
*ok = _setStringArg(_pngFile, i18n("Usage: --png <filename>\n"));
} else if (arg == "--print") {
--- branches/work/kst/portto4/kst/src/libkstapp/document.cpp #1219026:1219027
@@ -153,6 +153,11 @@
}
}
}
+ objectStore()->override.fileName = QString();
+ objectStore()->override.f0 = objectStore()->override.N =
+ objectStore()->override.skip =
+ objectStore()->override.doAve = -5;
+
QApplication::restoreOverrideCursor();
return ok;
--- branches/work/kst/portto4/kst/src/plugins/dataobject/differentiation/differentiation.cpp #1219026:1219027
@@ -16,7 +16,7 @@
static const QString& VECTOR_IN = "Vector In";
static const QString& SCALAR_IN = "Scalar In";
-static const QString& VECTOR_OUT = "Derivative";
+static const QString& VECTOR_OUT = "Y'";
class ConfigDifferentiationPlugin : public Kst::DataObjectConfigWidget, public Ui_DifferentiationConfig {
public:
@@ -113,7 +113,7 @@
QString DifferentiationSource::_automaticDescriptiveName() const {
- return QString("Differentiation Plugin Object");
+ return QString(vector()->descriptiveName() + " Derivative");
}
--- branches/work/kst/portto4/kst/src/plugins/filters/butterworth_bandpass/butterworth_bandpass.cpp #1219026:1219027
@@ -23,7 +23,7 @@
static const QString& SCALAR_ORDER_IN = "Order Scalar";
static const QString& SCALAR_RATE_IN = "Central Frequency / Sample Rate Scalar";
static const QString& SCALAR_BANDWIDTH_IN = "Band width Scalar";
-static const QString& VECTOR_OUT = "Filtered";
+static const QString& VECTOR_OUT = "Y";
class ConfigFilterButterworthBandPassPlugin : public Kst::DataObjectConfigWidget, public Ui_FilterButterworthBandPassConfig {
public:
@@ -203,8 +203,15 @@
Kst::ScalarPtr orderScalar = _inputScalars[SCALAR_ORDER_IN];
Kst::ScalarPtr rateScalar = _inputScalars[SCALAR_RATE_IN];
Kst::ScalarPtr bandwidthScalar = _inputScalars[SCALAR_BANDWIDTH_IN];
- Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
+ Kst::VectorPtr outputVector;
+ // maintain kst file compatibility if the output vector name is changed.
+ if (_outputVectors.contains(VECTOR_OUT)) {
+ outputVector = _outputVectors[VECTOR_OUT];
+ } else {
+ outputVector = _outputVectors.values().at(0);
+ }
+
Kst::ScalarList scalars;
scalars.insert(0, orderScalar);
scalars.insert(1, rateScalar);
--- branches/work/kst/portto4/kst/src/plugins/filters/butterworth_bandstop/butterworth_bandstop.cpp #1219026:1219027
@@ -23,7 +23,7 @@
static const QString& SCALAR_ORDER_IN = "Order Scalar";
static const QString& SCALAR_RATE_IN = "Central Frequency / Sample Rate Scalar";
static const QString& SCALAR_BANDWIDTH_IN = "Band width Scalar";
-static const QString& VECTOR_OUT = "Filtered";
+static const QString& VECTOR_OUT = "Y";
class ConfigFilterButterworthBandStopPlugin : public Kst::DataObjectConfigWidget, public Ui_FilterButterworthBandStopConfig {
public:
@@ -204,8 +204,15 @@
Kst::ScalarPtr orderScalar = _inputScalars[SCALAR_ORDER_IN];
Kst::ScalarPtr rateScalar = _inputScalars[SCALAR_RATE_IN];
Kst::ScalarPtr bandwidthScalar = _inputScalars[SCALAR_BANDWIDTH_IN];
- Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
+ Kst::VectorPtr outputVector;
+ // maintain kst file compatibility if the output vector name is changed.
+ if (_outputVectors.contains(VECTOR_OUT)) {
+ outputVector = _outputVectors[VECTOR_OUT];
+ } else {
+ outputVector = _outputVectors.values().at(0);
+ }
+
Kst::ScalarList scalars;
scalars.insert(0, orderScalar);
scalars.insert(1, rateScalar);
--- branches/work/kst/portto4/kst/src/plugins/filters/butterworth_highpass/butterworth_highpass.cpp #1219026:1219027
@@ -22,7 +22,7 @@
static const QString& VECTOR_IN = "Y Vector";
static const QString& SCALAR_ORDER_IN = "Order Scalar";
static const QString& SCALAR_CUTOFF_IN = "Cutoff / Spacing Scalar";
-static const QString& VECTOR_OUT = "Filtered";
+static const QString& VECTOR_OUT = "Y";
class ConfigFilterButterworthHighPassPlugin : public Kst::DataObjectConfigWidget, public Ui_FilterButterworthHighPassConfig {
public:
@@ -181,8 +181,15 @@
Kst::VectorPtr inputVector = _inputVectors[VECTOR_IN];
Kst::ScalarPtr orderScalar = _inputScalars[SCALAR_ORDER_IN];
Kst::ScalarPtr cutoffScalar = _inputScalars[SCALAR_CUTOFF_IN];
- Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
+ Kst::VectorPtr outputVector;
+ // maintain kst file compatibility if the output vector name is changed.
+ if (_outputVectors.contains(VECTOR_OUT)) {
+ outputVector = _outputVectors[VECTOR_OUT];
+ } else {
+ outputVector = _outputVectors.values().at(0);
+ }
+
Kst::ScalarList scalars;
scalars.insert(0, orderScalar);
scalars.insert(1, cutoffScalar);
--- branches/work/kst/portto4/kst/src/plugins/filters/butterworth_lowpass/butterworth_lowpass.cpp #1219026:1219027
@@ -23,7 +23,7 @@
static const QString& VECTOR_IN = "Y Vector";
static const QString& SCALAR_ORDER_IN = "Order Scalar";
static const QString& SCALAR_CUTOFF_IN = "Cutoff / Spacing Scalar";
-static const QString& VECTOR_OUT = "Filtered";
+static const QString& VECTOR_OUT = "Y";
class ConfigFilterButterworthLowPassPlugin : public Kst::DataObjectConfigWidget, public Ui_FilterButterworthLowPassConfig {
public:
@@ -178,7 +178,13 @@
Kst::VectorPtr inputVector = _inputVectors[VECTOR_IN];
Kst::ScalarPtr orderScalar = _inputScalars[SCALAR_ORDER_IN];
Kst::ScalarPtr cutoffScalar = _inputScalars[SCALAR_CUTOFF_IN];
- Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
+ Kst::VectorPtr outputVector;
+ // maintain kst file compatibility if the output vector name is changed.
+ if (_outputVectors.contains(VECTOR_OUT)) {
+ outputVector = _outputVectors[VECTOR_OUT];
+ } else {
+ outputVector = _outputVectors.values().at(0);
+ }
Kst::ScalarList scalars;
scalars.insert(0, orderScalar);
--- branches/work/kst/portto4/kst/src/plugins/filters/cumulativesum/cumulativesum.cpp #1219026:1219027
@@ -157,8 +157,15 @@
bool CumulativeSumSource::algorithm() {
Kst::VectorPtr inputVector = _inputVectors[VECTOR_IN];
Kst::ScalarPtr inputScalar = _inputScalars[SCALAR_IN];
- Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
+ Kst::VectorPtr outputVector;
+ // maintain kst file compatibility if the output vector name is changed.
+ if (_outputVectors.contains(VECTOR_OUT)) {
+ outputVector = _outputVectors[VECTOR_OUT];
+ } else {
+ outputVector = _outputVectors.values().at(0);
+ }
+
/* Memory allocation */
outputVector->resize(inputVector->length()+1, true);
--- branches/work/kst/portto4/kst/src/plugins/filters/despike/filterdespike.cpp #1219026:1219027
@@ -20,7 +20,7 @@
static const QString& VECTOR_IN = "Y Vector";
static const QString& SCALAR_NSIGMA_IN = "NSigma Scalar";
static const QString& SCALAR_SPACING_IN = "Spacing Scalar";
-static const QString& VECTOR_OUT = "Filtered";
+static const QString& VECTOR_OUT = "Y";
class ConfigWidgetFilterDespikePlugin : public Kst::DataObjectConfigWidget, public Ui_FilterDespikeConfig {
public:
@@ -174,7 +174,13 @@
Kst::VectorPtr inputVector = _inputVectors[VECTOR_IN];
Kst::ScalarPtr nSigmaScalar = _inputScalars[SCALAR_NSIGMA_IN];
Kst::ScalarPtr spacingScalar = _inputScalars[SCALAR_SPACING_IN];
- Kst::VectorPtr outputVector = _outputVectors[VECTOR_OUT];
+ Kst::VectorPtr outputVector;
+ // maintain kst file compatibility if the output vector name is changed.
+ if (_outputVectors.contains(VECTOR_OUT)) {
+ outputVector = _outputVectors[VECTOR_OUT];
+ } else {
+ outputVector = _outputVectors.values().at(0);
+ }
int N = inputVector->length();
double last_good;
More information about the Kst
mailing list