[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Thu Nov 15 17:59:07 CET 2007
SVN commit 737151 by fenton:
Add Edit support for PowerSpectrumDialog.
Update FFTOptions Widget to support setting of values.
M +4 -0 libkstapp/datamanager.cpp
M +1 -1 libkstapp/equationdialog.h
M +1 -3 libkstapp/histogramdialog.h
M +55 -2 libkstapp/powerspectrumdialog.cpp
M +6 -0 libkstapp/powerspectrumdialog.h
M +5 -0 libkstmath/psd.cpp
M +1 -0 libkstmath/psd.h
M +57 -0 widgets/fftoptions.cpp
M +21 -0 widgets/fftoptions.h
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #737150:737151
@@ -24,6 +24,7 @@
#include "equation.h"
#include "vector.h"
#include "histogram.h"
+#include "psd.h"
#include <QHeaderView>
@@ -152,6 +153,8 @@
DialogLauncher::self()->showEquationDialog(equation);
} else if (HistogramPtr histogram = kst_cast<Histogram>(_currentObject)) {
DialogLauncher::self()->showHistogramDialog(histogram);
+ } else if (PSDPtr psd = kst_cast<PSD>(_currentObject)) {
+ DialogLauncher::self()->showPowerSpectrumDialog(psd);
} else if (VectorPtr vector = kst_cast<Vector>(_currentObject)) {
DialogLauncher::self()->showVectorDialog(vector);
}
@@ -160,6 +163,7 @@
void DataManager::deleteObject() {
+ qDebug() << "deleteObject" << endl;
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/equationdialog.h #737150:737151
@@ -70,7 +70,7 @@
void updateButtons();
private:
- void configureTab(ObjectPtr curve);
+ void configureTab(ObjectPtr object);
EquationTab *_equationTab;
};
--- branches/work/kst/portto4/kst/src/libkstapp/histogramdialog.h #737150:737151
@@ -54,8 +54,6 @@
CurveAppearance* curveAppearance() const;
CurvePlacement* curvePlacement() const;
-
-
void hideCurveOptions();
private Q_SLOTS:
@@ -82,7 +80,7 @@
void updateButtons();
private:
- void configureTab(ObjectPtr curve);
+ void configureTab(ObjectPtr object);
HistogramTab *_histogramTab;
};
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #737150:737151
@@ -52,6 +52,11 @@
}
+void PowerSpectrumTab::setVector(const VectorPtr vector) {
+ _vector->setSelectedVector(vector);
+}
+
+
void PowerSpectrumTab::selectionChanged() {
emit vectorChanged();
}
@@ -77,6 +82,13 @@
}
+void PowerSpectrumTab::hideCurveOptions() {
+ _curvePlacement->setVisible(false);
+ _curveAppearance->setVisible(false);
+ setMaximumHeight(235);
+}
+
+
PowerSpectrumDialog::PowerSpectrumDialog(ObjectPtr dataObject, QWidget *parent)
: DataDialog(dataObject, parent) {
@@ -88,6 +100,10 @@
_powerSpectrumTab = new PowerSpectrumTab(this);
addDataTab(_powerSpectrumTab);
+ if (editMode() == Edit) {
+ configureTab(dataObject);
+ }
+
connect(_powerSpectrumTab, SIGNAL(vectorChanged()), this, SLOT(updateButtons()));
updateButtons();
}
@@ -102,6 +118,26 @@
}
+void PowerSpectrumDialog::configureTab(ObjectPtr object) {
+ if (PSDPtr psd = kst_cast<PSD>(object)) {
+ _powerSpectrumTab->setVector(psd->vector());
+
+ _powerSpectrumTab->FFTOptionsWidget()->setSampleRate(psd->freq());
+ _powerSpectrumTab->FFTOptionsWidget()->setInterleavedAverage(psd->average());
+ _powerSpectrumTab->FFTOptionsWidget()->setFFTLength(psd->len());
+ _powerSpectrumTab->FFTOptionsWidget()->setApodize(psd->apodize());
+ _powerSpectrumTab->FFTOptionsWidget()->setRemoveMean(psd->removeMean());
+ _powerSpectrumTab->FFTOptionsWidget()->setVectorUnits(psd->vUnits());
+ _powerSpectrumTab->FFTOptionsWidget()->setRateUnits(psd->rUnits());
+ _powerSpectrumTab->FFTOptionsWidget()->setApodizeFunction(psd->apodizeFxn());
+ _powerSpectrumTab->FFTOptionsWidget()->setSigma(psd->gaussianSigma());
+ _powerSpectrumTab->FFTOptionsWidget()->setOutput(psd->output());
+ _powerSpectrumTab->FFTOptionsWidget()->setInterpolateOverHoles(psd->interpolateHoles());
+ _powerSpectrumTab->hideCurveOptions();
+ }
+}
+
+
void PowerSpectrumDialog::updateButtons() {
_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_powerSpectrumTab->vector());
}
@@ -185,8 +221,25 @@
ObjectPtr PowerSpectrumDialog::editExistingDataObject() const {
- qDebug() << "editExistingDataObject" << endl;
- return 0;
+ if (PSDPtr powerspectrum = kst_cast<PSD>(dataObject())) {
+ powerspectrum->writeLock();
+ powerspectrum->setVector(_powerSpectrumTab->vector());
+ powerspectrum->setFreq(_powerSpectrumTab->FFTOptionsWidget()->sampleRate());
+ powerspectrum->setAverage(_powerSpectrumTab->FFTOptionsWidget()->interleavedAverage());
+ powerspectrum->setLen(_powerSpectrumTab->FFTOptionsWidget()->FFTLength());
+ powerspectrum->setApodize(_powerSpectrumTab->FFTOptionsWidget()->apodize());
+ powerspectrum->setRemoveMean(_powerSpectrumTab->FFTOptionsWidget()->removeMean());
+ powerspectrum->setVUnits(_powerSpectrumTab->FFTOptionsWidget()->vectorUnits());
+ powerspectrum->setRUnits(_powerSpectrumTab->FFTOptionsWidget()->rateUnits());
+ powerspectrum->setApodizeFxn(_powerSpectrumTab->FFTOptionsWidget()->apodizeFunction());
+ powerspectrum->setGaussianSigma(_powerSpectrumTab->FFTOptionsWidget()->sigma());
+ powerspectrum->setOutput(_powerSpectrumTab->FFTOptionsWidget()->output());
+ powerspectrum->setInterpolateHoles(_powerSpectrumTab->FFTOptionsWidget()->interpolateOverHoles());
+
+ powerspectrum->update(0);
+ powerspectrum->unlock();
+ }
+ return dataObject();
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.h #737150:737151
@@ -34,10 +34,14 @@
void setObjectStore(ObjectStore *store);
VectorPtr vector() const;
+ void setVector(const VectorPtr vector);
+
CurveAppearance* curveAppearance() const;
CurvePlacement* curvePlacement() const;
FFTOptions* FFTOptionsWidget() const;
+ void hideCurveOptions();
+
private Q_SLOTS:
void selectionChanged();
@@ -60,6 +64,8 @@
void updateButtons();
private:
+ void configureTab(ObjectPtr object);
+
PowerSpectrumTab *_powerSpectrumTab;
};
--- branches/work/kst/portto4/kst/src/libkstmath/psd.cpp #737150:737151
@@ -383,6 +383,11 @@
}
+VectorPtr PSD::vector() const {
+ return _inputVectors[INVECTOR];
+}
+
+
void PSD::setVector(VectorPtr new_v) {
Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED);
--- branches/work/kst/portto4/kst/src/libkstmath/psd.h #737150:737151
@@ -66,6 +66,7 @@
QString vTag() const;
void setVector(VectorPtr);
+ VectorPtr vector() const;
const QString& vUnits() const;
void setVUnits(const QString& units);
--- branches/work/kst/portto4/kst/src/widgets/fftoptions.cpp #737150:737151
@@ -63,54 +63,111 @@
}
+void FFTOptions::setSampleRate(const double sampleRate) {
+ _sampleRate->setText(QString::number(sampleRate));
+}
+
+
double FFTOptions::sigma() const {
return _sigma->value();
}
+
+void FFTOptions::setSigma(const double sigma) {
+ _sigma->setValue(sigma);
+}
+
+
bool FFTOptions::interleavedAverage() const {
return _interleavedAverage->isChecked();
}
+void FFTOptions::setInterleavedAverage(const bool interleavedAverage) {
+ _interleavedAverage->setChecked(interleavedAverage);
+}
+
+
bool FFTOptions::apodize() const {
return _apodize->isChecked();
}
+void FFTOptions::setApodize(const bool apodize) {
+ _apodize->setChecked(apodize);
+}
+
+
bool FFTOptions::removeMean() const {
return _removeMean->isChecked();
}
+void FFTOptions::setRemoveMean(const bool removeMean) {
+ _removeMean->setChecked(removeMean);
+}
+
+
bool FFTOptions::interpolateOverHoles() const {
return _interpolateOverHoles->isChecked();
}
+
+void FFTOptions::setInterpolateOverHoles(const bool interpolateOverHoles) {
+ _interpolateOverHoles->setChecked(interpolateOverHoles);
+}
+
+
int FFTOptions::FFTLength() const {
return _FFTLength->value();
}
+void FFTOptions::setFFTLength(const int FFTLength) {
+ _FFTLength->setValue(FFTLength);
+}
+
+
QString FFTOptions::vectorUnits() const {
return _vectorUnits->text();
}
+void FFTOptions::setVectorUnits(const QString vectorUnits) {
+ _vectorUnits->setText(vectorUnits);
+}
+
+
QString FFTOptions::rateUnits() const {
return _rateUnits->text();
}
+void FFTOptions::setRateUnits(const QString rateUnits) {
+ _rateUnits->setText(rateUnits);
+}
+
+
ApodizeFunction FFTOptions::apodizeFunction() const {
return (ApodizeFunction)_apodizeFunction->currentIndex();
}
+void FFTOptions::setApodizeFunction(const ApodizeFunction apodizeFunction) {
+ _apodizeFunction->setCurrentItem((ApodizeFunction)apodizeFunction);
+}
+
+
PSDType FFTOptions::output() const {
return (PSDType)_output->currentIndex();
}
+void FFTOptions::setOutput(const PSDType output) {
+ _output->setCurrentItem((PSDType)output);
+}
+
+
void FFTOptions::changedApodizeFxn() {
int gaussianIndex = 5;
if (_apodizeFunction->itemText(0).isEmpty()) {
--- branches/work/kst/portto4/kst/src/widgets/fftoptions.h #737150:737151
@@ -29,16 +29,37 @@
~FFTOptions();
double sampleRate() const;
+ void setSampleRate(const double sampleRate);
+
double sigma() const;
+ void setSigma(const double sigma);
+
bool interleavedAverage() const;
+ void setInterleavedAverage(const bool interleavedAverage);
+
int FFTLength() const;
+ void setFFTLength(const int FFTLength);
+
bool apodize() const;
+ void setApodize(const bool apodize);
+
bool removeMean() const;
+ void setRemoveMean(const bool removeMean);
+
QString vectorUnits() const;
+ void setVectorUnits(const QString vectorUnits);
+
QString rateUnits() const;
+ void setRateUnits(const QString rateUnits);
+
ApodizeFunction apodizeFunction() const;
+ void setApodizeFunction(const ApodizeFunction apodizeFunction);
+
PSDType output() const;
+ void setOutput(const PSDType output);
+
bool interpolateOverHoles() const;
+ void setInterpolateOverHoles(const bool interpolateOverHoles);
void update();
More information about the Kst
mailing list