[Kst] branches/work/kst/portto4/kst
Mike Fenton
mike at staikos.net
Tue Nov 6 19:19:40 CET 2007
SVN commit 733563 by fenton:
Add Save/Restore for CSD.
Fix crash and creation in CSDDialog.
M +1 -0 devel-docs/Kst2Specs/kstfile.txt
M +18 -12 src/libkstapp/csddialog.cpp
M +2 -0 src/libkstapp/csddialog.h
M +2 -0 src/libkstmath/builtinobjects.cpp
M +19 -17 src/libkstmath/csd.cpp
M +2 -1 src/libkstmath/csd.h
A src/libkstmath/csdfactory.cpp [License: GPL (v2+)]
A src/libkstmath/csdfactory.h [License: GPL (v2+)]
M +2 -0 src/libkstmath/libkstmath.pro
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/kstfile.txt #733562:733563
@@ -27,6 +27,7 @@
</variables>
<objects>
<equation tag="" expression="" xvector="" interpolate=""></equation>
+ <csd tag="" vector="" samplerate="" gaussiansigma="" average="" fftLen="" removemean="" apodize="" apodizefunction="" windowsize="" vectorunits="" rateunits="" outputtype=""></csd>
<psd name="">
</psd>
</objects>
--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.cpp #733562:733563
@@ -70,6 +70,12 @@
return _windowSize->value();
}
+
+void CSDTab::setObjectStore(ObjectStore *store) {
+ _vector->setObjectStore(store);
+}
+
+
CSDDialog::CSDDialog(ObjectPtr dataObject, QWidget *parent)
: DataDialog(dataObject, parent) {
@@ -98,18 +104,18 @@
Q_ASSERT(_document && _document->objectStore());
ObjectTag tag = _document->objectStore()->suggestObjectTag<CSD>(tagString(), ObjectTag::globalTagContext);
CSDPtr csd = _document->objectStore()->createObject<CSD>(tag);
- csd->setVector(_CSDTab->vector());
- csd->setFreq(_CSDTab->FFTOptionsWidget()->sampleRate());
- csd->setAverage(_CSDTab->FFTOptionsWidget()->interleavedAverage());
- csd->setRemoveMean(_CSDTab->FFTOptionsWidget()->removeMean());
- csd->setApodize(_CSDTab->FFTOptionsWidget()->apodize());
- csd->setApodizeFxn(_CSDTab->FFTOptionsWidget()->apodizeFunction());
- csd->setWindowSize(_CSDTab->windowSize());
- csd->setLength(_CSDTab->FFTOptionsWidget()->FFTLength());
- csd->setGaussianSigma(_CSDTab->FFTOptionsWidget()->sigma());
- csd->setOutput(_CSDTab->FFTOptionsWidget()->output());
- csd->setVectorUnits(_CSDTab->FFTOptionsWidget()->vectorUnits());
- csd->setRateUnits(_CSDTab->FFTOptionsWidget()->rateUnits());
+ csd->change(_CSDTab->vector(),
+ _CSDTab->FFTOptionsWidget()->sampleRate(),
+ _CSDTab->FFTOptionsWidget()->interleavedAverage(),
+ _CSDTab->FFTOptionsWidget()->removeMean(),
+ _CSDTab->FFTOptionsWidget()->apodize(),
+ _CSDTab->FFTOptionsWidget()->apodizeFunction(),
+ _CSDTab->windowSize(),
+ _CSDTab->FFTOptionsWidget()->FFTLength(),
+ _CSDTab->FFTOptionsWidget()->sigma(),
+ _CSDTab->FFTOptionsWidget()->output(),
+ _CSDTab->FFTOptionsWidget()->vectorUnits(),
+ _CSDTab->FFTOptionsWidget()->rateUnits());
csd->writeLock();
csd->update(0);
--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.h #733562:733563
@@ -31,6 +31,8 @@
CSDTab(QWidget *parent = 0);
virtual ~CSDTab();
+ void setObjectStore(ObjectStore *store);
+
VectorPtr vector() const;
CurvePlacement* curvePlacement() const;
FFTOptions* FFTOptionsWidget() const;
--- branches/work/kst/portto4/kst/src/libkstmath/builtinobjects.cpp #733562:733563
@@ -11,11 +11,13 @@
#include "builtinobjects.h"
#include "equationfactory.h"
+#include "csdfactory.h"
namespace Kst {
namespace Builtins {
void initObjects() {
new EquationFactory;
+ new CSDFactory;
}
}
}
--- branches/work/kst/portto4/kst/src/libkstmath/csd.cpp #733562:733563
@@ -16,7 +16,7 @@
#include <assert.h>
#include <math.h>
-#include <QTextDocument>
+#include <QXmlStreamWriter>
#include <QLatin1String>
#include "kst_i18n.h"
@@ -34,6 +34,7 @@
namespace Kst {
const QString CSD::staticTypeString = I18N_NOOP("Cumulative Spectral Decay");
+const QString CSD::staticTypeTag = I18N_NOOP("csd");
static const QLatin1String INVECTOR = QLatin1String("I");
static const QLatin1String& OUTMATRIX = QLatin1String("M");
@@ -265,22 +266,23 @@
return setLastUpdateResult(UPDATE);
}
-void CSD::save(QTextStream &ts, const QString& indent) {
- QString l2 = indent + " ";
- ts << indent << "<csdobject>" << endl;
- ts << l2 << "<tag>" << Qt::escape(tag().tagString()) << "</tag>" << endl;
- ts << l2 << "<vectag>" << Qt::escape(_inputVectors[INVECTOR]->tag().tagString()) << "</vectag>" << endl;
- ts << l2 << "<sampRate>" << _frequency << "</sampRate>" << endl;
- ts << l2 << "<average>" << _average << "</average>" << endl;
- ts << l2 << "<fftLen>" << int(ceil(log(double(_PSDLen*2)) / log(2.0))) << "</fftLen>" << endl;
- ts << l2 << "<removeMean>" << _removeMean << "</removeMean>" << endl;
- ts << l2 << "<apodize>" << _apodize << "</apodize>" << endl;
- ts << l2 << "<apodizefxn>" << _apodizeFxn << "</apodizefxn>" << endl;
- ts << l2 << "<windowsize>" << _windowSize << "</windowsize>" << endl;
- ts << l2 << "<vectorunits>" << _vectorUnits << "</vectorunits>" << endl;
- ts << l2 << "<rateunits>" << _rateUnits << "</rateunits>" << endl;
- ts << l2 << "<output>" << _outputType << "</output>" << endl;
- ts << indent << "</csdobject>" << endl;
+
+void CSD::save(QXmlStreamWriter &s) {
+ s.writeStartElement(staticTypeTag);
+ s.writeAttribute("tag", tag().tagString());
+ s.writeAttribute("vector", _inputVectors[INVECTOR]->tag().tagString());
+ s.writeAttribute("samplerate", QString::number(_frequency));
+ s.writeAttribute("gaussiansigma", QString::number(_gaussianSigma));
+ s.writeAttribute("average", QVariant(_average).toString());
+ s.writeAttribute("fftLen", QString::number(int(ceil(log(double(_PSDLen*2)) / log(2.0)))));
+ s.writeAttribute("removemean", QVariant(_removeMean).toString());
+ s.writeAttribute("apodize", QVariant(_apodize).toString());
+ s.writeAttribute("apodizefunction", QString::number(_apodizeFxn));
+ s.writeAttribute("windowsize", QString::number(_windowSize));
+ s.writeAttribute("vectorunits", _vectorUnits);
+ s.writeAttribute("rateunits", _rateUnits);
+ s.writeAttribute("outputtype", QString::number(_outputType));
+ s.writeEndElement();
}
--- branches/work/kst/portto4/kst/src/libkstmath/csd.h #733562:733563
@@ -28,10 +28,11 @@
public:
static const QString staticTypeString;
const QString& typeString() const { return staticTypeString; }
+ static const QString staticTypeTag;
virtual UpdateType update(int update_counter = -1);
- virtual void save(QTextStream& ts, const QString& indent = QString::null);
+ virtual void save(QXmlStreamWriter &s);
virtual QString propertyString() const;
QString vTag() const;
--- branches/work/kst/portto4/kst/src/libkstmath/libkstmath.pro #733562:733563
@@ -30,6 +30,7 @@
dataobject.cpp \
dataobjectcollection.cpp \
csd.cpp \
+ csdfactory.cpp \
psd.cpp \
relation.cpp \
curvepointsymbol.cpp \
@@ -66,6 +67,7 @@
basicplugin.h \
colorsequence.h \
csd.h \
+ csdfactory.h \
curvehint.h \
curvepointsymbol.h \
dataobjectcollection.h \
More information about the Kst
mailing list