[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Nov 20 04:00:08 CET 2007
SVN commit 738975 by netterfield:
powerspectrum dialog gets defaults.
Datawizard shares them.
M +19 -3 libkst/dialogdefaults.cpp
M +21 -9 libkst/dialogdefaults.h
M +0 -3 libkstapp/application.cpp
M +46 -5 libkstapp/datawizard.cpp
M +22 -1 libkstapp/powerspectrumdialog.cpp
M +1 -1 libkstapp/powerspectrumdialog.h
--- branches/work/kst/portto4/kst/src/libkst/dialogdefaults.cpp #738974:738975
@@ -26,11 +26,27 @@
Kst::dialogDefaults->setValue("vector/doAve", V->doAve());
}
-//FIXME: move to dialogdefaults.cpp... (How do you add a file to the build system??)
void Kst::setGenVectorDefaults(GeneratedVectorPtr V) {
- //FIXME Do we need a V->readLock() here?
+ //FIXME Do we need a V->readLock() here?
Kst::dialogDefaults->setValue("genVector/min", V->min());
Kst::dialogDefaults->setValue("genVector/max", V->max());
Kst::dialogDefaults->setValue("genVector/length", V->length());
}
-//---------------------------------------------------------------------------
+
+void Kst::setSpectrumDefaults(PSDPtr P) {
+ //FIXME Do we need a V->readLock() here?
+ //NOTE: we are storing enums as ints here... so there might be
+ // odd behavior if the enums change betwee recompiles.
+ Kst::dialogDefaults->setValue("spectrum/freq", P->frequency());
+ Kst::dialogDefaults->setValue("spectrum/average", P->average());
+ Kst::dialogDefaults->setValue("spectrum/len", P->length());
+ Kst::dialogDefaults->setValue("spectrum/apodize", P->apodize());
+ Kst::dialogDefaults->setValue("spectrum/removeMean", P->removeMean());
+ Kst::dialogDefaults->setValue("spectrum/vUnits", P->vectorUnits());
+ Kst::dialogDefaults->setValue("spectrum/rUnits", P->rateUnits());
+ Kst::dialogDefaults->setValue("spectrum/apodizeFxn", P->apodizeFxn());
+ Kst::dialogDefaults->setValue("spectrum/gaussianSigma", P->gaussianSigma());
+ Kst::dialogDefaults->setValue("spectrum/output", P->output());
+ Kst::dialogDefaults->setValue("spectrum/interpolateHoles", P->interpolateHoles());
+}
+
--- branches/work/kst/portto4/kst/src/libkst/dialogdefaults.h #738974:738975
@@ -19,6 +19,7 @@
#define KSTDIALOGDEFAULTS
#include "datavector.h"
+#include "../libkstmath/psd.h"
#include "generatedvector.h"
class QSettings;
@@ -28,7 +29,7 @@
void setDataVectorDefaults(DataVectorPtr);
void setGenVectorDefaults(GeneratedVectorPtr V);
-
+ void setSpectrumDefaults(PSDPtr P);
}
#endif
@@ -36,16 +37,27 @@
// Dialog defaults are stored and retreived from the Kst::dialogDefaults.
// As you add defaults, add them here!
// Name Type Where used
-// vector/datasource QString vectordialog
-// vector/range int vectordialog
-// vector/start int vectordialog
-// vector/countFromEnd bool vectordialog
-// vector/readToEnd bool vectordialog
-// vector/skip int vectordialog
-// vector/doSkip bool vectordialog
-// vector/doAve bool vectordialog
+// vector/datasource QString vectordialog datawizard
+// vector/range int vectordialog datawizard
+// vector/start int vectordialog datawizard
+// vector/countFromEnd bool vectordialog datawizard
+// vector/readToEnd bool vectordialog datawizard
+// vector/skip int vectordialog datawizard
+// vector/doSkip bool vectordialog datawizard
+// vector/doAve bool vectordialog datawizard
//
// genVector/min" int vectordialog
// genVector/max" int vectordialog
// genVector/length int vectordialog
+// spectrum/freq double powerspectrumdailog datawizard
+// spectrum/average bool powerspectrumdailog datawizard
+// spectrum/len int powerspectrumdailog datawizard
+// spectrum/apodize bool powerspectrumdailog datawizard
+// spectrum/removeMean bool powerspectrumdailog datawizard
+// spectrum/vUnits QString powerspectrumdailog datawizard
+// spectrum/rUnits QString powerspectrumdailog datawizard
+// spectrum/apodizeFxn int powerspectrumdailog datawizard
+// spectrum/gaussianSigma double powerspectrumdailog datawizard
+// spectrum/output int powerspectrumdailog datawizard
+// spectrum/interpolateHoles bool powerspectrumdailog datawizard
--- branches/work/kst/portto4/kst/src/libkstapp/application.cpp #738974:738975
@@ -43,9 +43,6 @@
QSettings *settingsObject = new QSettings("kstdatarc", QSettings::IniFormat);
DataSource::setupOnStartup(settingsObject);
- // Initialize the dialogDefaults settings
- //dialogDefaults = new QSettings("kstdialogrc", QSettings::NativeFormat);
-
_mainWindow = new MainWindow;
//Replace the data singleton with one that actually works
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #738974:738975
@@ -20,6 +20,7 @@
#include "dataobjectcollection.h"
#include "plotiteminterface.h"
#include "plotitem.h"
+#include "dialogdefaults.h"
#include <QMessageBox>
@@ -35,12 +36,14 @@
: QWizardPage(parent), _pageValid(false), _store(store) {
setupUi(this);
- QString default_source = vectorDefaults.dataSource();
+ connect(_url, SIGNAL(changed(const QString&)), this, SLOT(sourceChanged(const QString&)));
+ connect(_configureSource, SIGNAL(clicked()), this, SLOT(configureSource()));
+
+ QString default_source = Kst::dialogDefaults->value("vector/datasource",".").toString();
_url->setFile(default_source);
_url->setFocus();
+ //sourceChanged(default_source);
- connect(_url, SIGNAL(changed(const QString&)), this, SLOT(sourceChanged(const QString&)));
- connect(_configureSource, SIGNAL(clicked()), this, SLOT(configureSource()));
}
@@ -366,6 +369,27 @@
_xVectorExisting->setObjectStore(store);
+ dataRange()->setRange(Kst::dialogDefaults->value("vector/range", 1).toInt());
+ dataRange()->setStart(Kst::dialogDefaults->value("vector/start", 0).toInt());
+ dataRange()->setCountFromEnd(Kst::dialogDefaults->value("vector/countFromEnd",false).toBool());
+ dataRange()->setReadToEnd(Kst::dialogDefaults->value("vector/readToEnd",true).toBool());
+ dataRange()->setSkip(Kst::dialogDefaults->value("vector/skip", 0).toInt());
+ dataRange()->setDoSkip(Kst::dialogDefaults->value("vector/doSkip", false).toBool());
+ dataRange()->setDoFilter(Kst::dialogDefaults->value("vector/doAve",false).toBool());
+
+ getFFTOptions()->setSampleRate(Kst::dialogDefaults->value("spectrum/freq",100.0).toDouble());
+ getFFTOptions()->setInterleavedAverage(Kst::dialogDefaults->value("spectrum/average",true).toBool());
+ getFFTOptions()->setFFTLength(Kst::dialogDefaults->value("spectrum/len",12).toInt());
+ getFFTOptions()->setApodize(Kst::dialogDefaults->value("spectrum/apodize",true).toBool());
+ getFFTOptions()->setRemoveMean(Kst::dialogDefaults->value("spectrum/removeMean",true).toBool());
+ getFFTOptions()->setVectorUnits(Kst::dialogDefaults->value("spectrum/vUnits","V").toString());
+ getFFTOptions()->setRateUnits(Kst::dialogDefaults->value("spectrum/rUnits","Hz").toString());
+ getFFTOptions()->setApodizeFunction(ApodizeFunction(Kst::dialogDefaults->value("spectrum/apodizeFxn",WindowOriginal).toInt()));
+ getFFTOptions()->setSigma(Kst::dialogDefaults->value("spectrum/gaussianSigma",1.0).toDouble());
+ getFFTOptions()->setOutput(PSDType(Kst::dialogDefaults->value("spectrum/output",PSDPowerSpectralDensity).toInt()));
+ getFFTOptions()->setInterpolateOverHoles(Kst::dialogDefaults->value("spectrum/interpolateHoles",true).toInt());
+
+
connect(_radioButtonPlotData, SIGNAL(clicked()), this, SLOT(updatePlotTypeOptions()));
connect(_radioButtonPlotPSD, SIGNAL(clicked()), this, SLOT(updatePlotTypeOptions()));
connect(_radioButtonPlotDataPSD, SIGNAL(clicked()), this, SLOT(updatePlotTypeOptions()));
@@ -511,6 +535,10 @@
connect(_pageDataSource, SIGNAL(dataSourceChanged()), _pageDataPresentation, SLOT(updateVectors()));
disconnect(button(QWizard::FinishButton), SIGNAL(clicked()), (QDialog*)this, SLOT(accept()));
connect(button(QWizard::FinishButton), SIGNAL(clicked()), this, SLOT(finished()));
+
+ // the dialog needs to know that the default has been set....
+ _pageDataSource->sourceChanged(Kst::dialogDefaults->value("vector/datasource",".").toString());
+
}
@@ -629,13 +657,14 @@
// only create create the y-vectors
{
+ DataVectorPtr vector;
for (int i = 0; i < _pageVectors->plotVectors()->count(); i++) {
QString field = _pageVectors->plotVectors()->item(i)->text();
Q_ASSERT(_document && _document->objectStore());
const ObjectTag tag = _document->objectStore()->suggestObjectTag<DataVector>(QString(), ds->tag());
- DataVectorPtr vector = _document->objectStore()->createObject<DataVector>(tag);
+ vector = _document->objectStore()->createObject<DataVector>(tag);
vector->writeLock();
vector->change(ds, field,
@@ -651,8 +680,12 @@
vectors.append(vector);
++n_curves;
}
+ if (n_curves>0) {
+ Kst::setDataVectorDefaults(vector);
+ }
}
+
// create the necessary plots
QList<PlotItem*> plotList;
PlotItem *plotItem = 0;
@@ -808,12 +841,16 @@
int indexColor = 0;
ptype = 0;
+ PSDPtr powerspectrum;
+ int n_psd=0;
+
for (DataVectorList::Iterator it = vectors.begin(); it != vectors.end(); ++it) {
if ((*it)->length() > 0) {
Q_ASSERT(_document && _document->objectStore());
const ObjectTag tag = _document->objectStore()->suggestObjectTag<Curve>(QString(), ds->tag());
- PSDPtr powerspectrum = _document->objectStore()->createObject<PSD>(tag);
+ powerspectrum = _document->objectStore()->createObject<PSD>(tag);
+ n_psd++;
Q_ASSERT(powerspectrum);
powerspectrum->writeLock();
@@ -875,6 +912,10 @@
}
}
}
+
+ if (n_psd>0) {
+ setSpectrumDefaults(powerspectrum);
+ }
}
// legends and labels
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #738974:738975
@@ -28,6 +28,7 @@
#include "defaultnames.h"
#include "datacollection.h"
#include "dataobjectcollection.h"
+#include "dialogdefaults.h"
#include <QPushButton>
@@ -102,6 +103,8 @@
if (editMode() == Edit) {
configureTab(dataObject);
+ } else {
+ configureTab(0);
}
connect(_powerSpectrumTab, SIGNAL(vectorChanged()), this, SLOT(updateButtons()));
@@ -119,7 +122,21 @@
void PowerSpectrumDialog::configureTab(ObjectPtr object) {
- if (PSDPtr psd = kst_cast<PSD>(object)) {
+ if (!object) {
+ _powerSpectrumTab->FFTOptionsWidget()->setSampleRate(Kst::dialogDefaults->value("spectrum/freq",100.0).toDouble());
+ _powerSpectrumTab->FFTOptionsWidget()->setInterleavedAverage(Kst::dialogDefaults->value("spectrum/average",true).toBool());
+ _powerSpectrumTab->FFTOptionsWidget()->setFFTLength(Kst::dialogDefaults->value("spectrum/len",12).toInt());
+ _powerSpectrumTab->FFTOptionsWidget()->setApodize(Kst::dialogDefaults->value("spectrum/apodize",true).toBool());
+ _powerSpectrumTab->FFTOptionsWidget()->setRemoveMean(Kst::dialogDefaults->value("spectrum/removeMean",true).toBool());
+ _powerSpectrumTab->FFTOptionsWidget()->setVectorUnits(Kst::dialogDefaults->value("spectrum/vUnits","V").toString());
+ _powerSpectrumTab->FFTOptionsWidget()->setRateUnits(Kst::dialogDefaults->value("spectrum/rUnits","Hz").toString());
+ _powerSpectrumTab->FFTOptionsWidget()->setApodizeFunction(ApodizeFunction(Kst::dialogDefaults->value("spectrum/apodizeFxn",WindowOriginal).toInt()));
+ _powerSpectrumTab->FFTOptionsWidget()->setSigma(Kst::dialogDefaults->value("spectrum/gaussianSigma",1.0).toDouble());
+ _powerSpectrumTab->FFTOptionsWidget()->setOutput(PSDType(Kst::dialogDefaults->value("spectrum/output",PSDPowerSpectralDensity).toInt()));
+ _powerSpectrumTab->FFTOptionsWidget()->setInterpolateOverHoles(Kst::dialogDefaults->value("spectrum/interpolateHoles",true).toInt());
+
+//xxxxxxxxxx fill the dialog from the settings...
+ } else if (PSDPtr psd = kst_cast<PSD>(object)) {
_powerSpectrumTab->setVector(psd->vector());
_powerSpectrumTab->FFTOptionsWidget()->setSampleRate(psd->frequency());
@@ -165,6 +182,7 @@
powerspectrum->update(0);
powerspectrum->unlock();
+ setSpectrumDefaults(powerspectrum);
//FIXME this should be a command...
//FIXME need some smart placement...
@@ -238,6 +256,9 @@
powerspectrum->update(0);
powerspectrum->unlock();
+
+ setSpectrumDefaults(powerspectrum);
+
}
return dataObject();
}
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.h #738974:738975
@@ -64,7 +64,7 @@
void updateButtons();
private:
- void configureTab(ObjectPtr object);
+ void configureTab(ObjectPtr object=0);
PowerSpectrumTab *_powerSpectrumTab;
};
More information about the Kst
mailing list