[Kst] branches/work/kst/portto4/kst/src
Mike Fenton
mike at staikos.net
Thu Dec 6 20:16:19 CET 2007
SVN commit 745662 by fenton:
Add Apply button and Edit Multiple support to PowerSpectrumDialog.
M +92 -17 libkstapp/powerspectrumdialog.cpp
M +4 -0 libkstapp/powerspectrumdialog.h
M +82 -3 widgets/fftoptions.cpp
M +51 -37 widgets/fftoptions.h
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #745661:745662
@@ -26,6 +26,7 @@
#include "psd.h"
#include "tabwidget.h"
#include "view.h"
+#include "editmultiplewidget.h"
#include <QPushButton>
@@ -38,6 +39,8 @@
setTabTitle(tr("Power Spectrum"));
connect(_vector, SIGNAL(selectionChanged(QString)), this, SLOT(selectionChanged()));
+ connect(_FFTOptions, SIGNAL(modified()), this, SIGNAL(modified()));
+ connect(_vector, SIGNAL(selectionChanged(QString)), this, SIGNAL(modified()));
}
@@ -50,6 +53,11 @@
}
+bool PowerSpectrumTab::vectorDirty() const {
+ return _vector->selectedVectorDirty();
+}
+
+
void PowerSpectrumTab::setVector(const VectorPtr vector) {
_vector->setSelectedVector(vector);
}
@@ -87,6 +95,12 @@
}
+void PowerSpectrumTab::clearTabValues() {
+ _vector->clearSelection();
+ _FFTOptions->clearValues();
+}
+
+
PowerSpectrumDialog::PowerSpectrumDialog(ObjectPtr dataObject, QWidget *parent)
: DataDialog(dataObject, parent) {
@@ -105,6 +119,10 @@
}
connect(_powerSpectrumTab, SIGNAL(vectorChanged()), this, SLOT(updateButtons()));
+ connect(this, SIGNAL(editMultipleMode()), this, SLOT(editMultipleMode()));
+ connect(this, SIGNAL(editSingleMode()), this, SLOT(editSingleMode()));
+
+ connect(_powerSpectrumTab, SIGNAL(modified()), this, SLOT(modified()));
updateButtons();
}
@@ -118,6 +136,16 @@
}
+void PowerSpectrumDialog::editMultipleMode() {
+ _powerSpectrumTab->clearTabValues();
+}
+
+
+void PowerSpectrumDialog::editSingleMode() {
+ configureTab(dataObject());
+}
+
+
void PowerSpectrumDialog::setVector(VectorPtr vector) {
_powerSpectrumTab->setVector(vector);
}
@@ -143,12 +171,20 @@
_powerSpectrumTab->FFTOptionsWidget()->setOutput(psd->output());
_powerSpectrumTab->FFTOptionsWidget()->setInterpolateOverHoles(psd->interpolateHoles());
_powerSpectrumTab->hideCurveOptions();
+ if (_editMultipleWidget) {
+ QStringList objectList;
+ PSDList objects = _document->objectStore()->getObjects<PSD>();
+ foreach(PSDPtr object, objects) {
+ objectList.append(object->tag().displayString());
+ }
+ _editMultipleWidget->addObjects(objectList);
+ }
}
}
void PowerSpectrumDialog::updateButtons() {
- _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_powerSpectrumTab->vector());
+ _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_powerSpectrumTab->vector() || (editMode() == EditMultiple));
}
@@ -235,25 +271,64 @@
ObjectPtr PowerSpectrumDialog::editExistingDataObject() const {
if (PSDPtr powerspectrum = kst_cast<PSD>(dataObject())) {
- powerspectrum->writeLock();
- powerspectrum->setVector(_powerSpectrumTab->vector());
- powerspectrum->setFrequency(_powerSpectrumTab->FFTOptionsWidget()->sampleRate());
- powerspectrum->setAverage(_powerSpectrumTab->FFTOptionsWidget()->interleavedAverage());
- powerspectrum->setLength(_powerSpectrumTab->FFTOptionsWidget()->FFTLength());
- powerspectrum->setApodize(_powerSpectrumTab->FFTOptionsWidget()->apodize());
- powerspectrum->setRemoveMean(_powerSpectrumTab->FFTOptionsWidget()->removeMean());
- powerspectrum->setVectorUnits(_powerSpectrumTab->FFTOptionsWidget()->vectorUnits());
- powerspectrum->setRateUnits(_powerSpectrumTab->FFTOptionsWidget()->rateUnits());
- powerspectrum->setApodizeFxn(_powerSpectrumTab->FFTOptionsWidget()->apodizeFunction());
- powerspectrum->setGaussianSigma(_powerSpectrumTab->FFTOptionsWidget()->sigma());
- powerspectrum->setOutput(_powerSpectrumTab->FFTOptionsWidget()->output());
- powerspectrum->setInterpolateHoles(_powerSpectrumTab->FFTOptionsWidget()->interpolateOverHoles());
+ if (editMode() == EditMultiple) {
+ const FFTOptions *options = _powerSpectrumTab->FFTOptionsWidget();
+ QStringList objects = _editMultipleWidget->selectedObjects();
+ foreach (QString objectTag, objects) {
+ PSDPtr powerspectrum = kst_cast<PSD>(_document->objectStore()->retrieveObject(ObjectTag::fromString(objectTag)));
+ if (powerspectrum) {
+ VectorPtr vector = _powerSpectrumTab->vectorDirty() ? _powerSpectrumTab->vector() : powerspectrum->vector();
+ const double frequency = options->sampleRateDirty() ? options->sampleRate() : powerspectrum->frequency();
+ const double sigma = options->sigmaDirty() ? options->sigma() : powerspectrum->gaussianSigma();
- powerspectrum->update(0);
- powerspectrum->unlock();
+ const bool apodize = options->apodizeDirty() ? options->apodize() : powerspectrum->apodize();
+ const bool removeMean = options->removeMeanDirty() ? options->removeMean() : powerspectrum->removeMean();
+ const bool interpolateOverHoles = options->interpolateOverHolesDirty() ? options->interpolateOverHoles() : powerspectrum->interpolateHoles();
+ const bool interleavedAverage = options->interleavedAverageDirty() ? options->interleavedAverage() : powerspectrum->average();
+ const int FFTLength = options->FFTLengthDirty() ? options->FFTLength() : powerspectrum->length();
+ const ApodizeFunction apodizeFunction = options->apodizeFunctionDirty() ? options->apodizeFunction() : powerspectrum->apodizeFxn();
+ const PSDType output = options->outputDirty() ? options->output() : powerspectrum->output();
+ const QString vectorUnits = options->vectorUnitsDirty() ? options->vectorUnits() : powerspectrum->vectorUnits();
+ const QString rateUnits = options->rateUnitsDirty() ? options->rateUnits() : powerspectrum->rateUnits();
- _powerSpectrumTab->FFTOptionsWidget()->setWidgetDefaults();
+ powerspectrum->writeLock();
+ powerspectrum->setVector(vector);
+ powerspectrum->setFrequency(frequency);
+ powerspectrum->setAverage(interleavedAverage);
+ powerspectrum->setLength(FFTLength);
+ powerspectrum->setApodize(apodize);
+ powerspectrum->setRemoveMean(removeMean);
+ powerspectrum->setVectorUnits(vectorUnits);
+ powerspectrum->setRateUnits(rateUnits);
+ powerspectrum->setApodizeFxn(apodizeFunction);
+ powerspectrum->setGaussianSigma(sigma);
+ powerspectrum->setOutput(output);
+ powerspectrum->setInterpolateHoles(interpolateOverHoles);
+ powerspectrum->update(0);
+ powerspectrum->unlock();
+ }
+ }
+ } else {
+ powerspectrum->writeLock();
+ powerspectrum->setVector(_powerSpectrumTab->vector());
+ powerspectrum->setFrequency(_powerSpectrumTab->FFTOptionsWidget()->sampleRate());
+ powerspectrum->setAverage(_powerSpectrumTab->FFTOptionsWidget()->interleavedAverage());
+ powerspectrum->setLength(_powerSpectrumTab->FFTOptionsWidget()->FFTLength());
+ powerspectrum->setApodize(_powerSpectrumTab->FFTOptionsWidget()->apodize());
+ powerspectrum->setRemoveMean(_powerSpectrumTab->FFTOptionsWidget()->removeMean());
+ powerspectrum->setVectorUnits(_powerSpectrumTab->FFTOptionsWidget()->vectorUnits());
+ powerspectrum->setRateUnits(_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();
+
+ _powerSpectrumTab->FFTOptionsWidget()->setWidgetDefaults();
+ }
}
return dataObject();
}
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.h #745661:745662
@@ -34,6 +34,7 @@
void setObjectStore(ObjectStore *store);
VectorPtr vector() const;
+ bool vectorDirty() const;
void setVector(const VectorPtr vector);
CurveAppearance* curveAppearance() const;
@@ -41,6 +42,7 @@
FFTOptions* FFTOptionsWidget() const;
void hideCurveOptions();
+ void clearTabValues();
private Q_SLOTS:
void selectionChanged();
@@ -64,6 +66,8 @@
private Q_SLOTS:
void updateButtons();
+ void editMultipleMode();
+ void editSingleMode();
private:
void configureTab(ObjectPtr object=0);
--- branches/work/kst/portto4/kst/src/widgets/fftoptions.cpp #745661:745662
@@ -20,12 +20,21 @@
setupUi(this);
connect(_interleavedAverage, SIGNAL(clicked()), this, SLOT(clickedInterleaved()));
-
connect(_apodize, SIGNAL(clicked()), this, SLOT(clickedApodize()));
-
connect(_apodizeFunction, SIGNAL(activated(int)), this, SLOT(changedApodizeFxn()));
+ connect(_apodize, SIGNAL(clicked()), this, SLOT(changedApodizeFxn()));
- connect(_apodize, SIGNAL(clicked()), this, SLOT(changedApodizeFxn()));
+ connect(_apodizeFunction, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+ connect(_output, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+ connect(_apodize, SIGNAL(clicked()), this, SIGNAL(modified()));
+ connect(_removeMean, SIGNAL(clicked()), this, SIGNAL(modified()));
+ connect(_interleavedAverage, SIGNAL(clicked()), this, SIGNAL(modified()));
+ connect(_interpolateOverHoles, SIGNAL(clicked()), this, SIGNAL(modified()));
+ connect(_sampleRate, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
+ connect(_vectorUnits, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
+ connect(_rateUnits, SIGNAL(textChanged(const QString&)), this, SIGNAL(modified()));
+ connect(_sigma, SIGNAL(valueChanged(double)), this, SIGNAL(modified()));
+ connect(_FFTLength, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
}
@@ -41,6 +50,11 @@
}
+bool FFTOptions::sampleRateDirty() const {
+ return !_sampleRate->text().isEmpty();
+}
+
+
void FFTOptions::setSampleRate(const double sampleRate) {
_sampleRate->setText(QString::number(sampleRate));
}
@@ -51,6 +65,11 @@
}
+bool FFTOptions::sigmaDirty() const {
+ return !_sigma->text().isEmpty();
+}
+
+
void FFTOptions::setSigma(const double sigma) {
_sigma->setValue(sigma);
}
@@ -61,6 +80,11 @@
}
+bool FFTOptions::interleavedAverageDirty() const {
+ return _interleavedAverage->checkState() == Qt::PartiallyChecked;
+}
+
+
void FFTOptions::setInterleavedAverage(const bool interleavedAverage) {
_interleavedAverage->setChecked(interleavedAverage);
}
@@ -71,6 +95,11 @@
}
+bool FFTOptions::apodizeDirty() const {
+ return _apodize->checkState() == Qt::PartiallyChecked;
+}
+
+
void FFTOptions::setApodize(const bool apodize) {
_apodize->setChecked(apodize);
}
@@ -81,6 +110,11 @@
}
+bool FFTOptions::removeMeanDirty() const {
+ return _removeMean->checkState() == Qt::PartiallyChecked;
+}
+
+
void FFTOptions::setRemoveMean(const bool removeMean) {
_removeMean->setChecked(removeMean);
}
@@ -91,6 +125,11 @@
}
+bool FFTOptions::interpolateOverHolesDirty() const {
+ return _interpolateOverHoles->checkState() == Qt::PartiallyChecked;
+}
+
+
void FFTOptions::setInterpolateOverHoles(const bool interpolateOverHoles) {
_interpolateOverHoles->setChecked(interpolateOverHoles);
}
@@ -101,6 +140,11 @@
}
+bool FFTOptions::FFTLengthDirty() const {
+ return !_FFTLength->text().isEmpty();
+}
+
+
void FFTOptions::setFFTLength(const int FFTLength) {
_FFTLength->setValue(FFTLength);
}
@@ -111,6 +155,11 @@
}
+bool FFTOptions::vectorUnitsDirty() const {
+ return !_vectorUnits->text().isEmpty();
+}
+
+
void FFTOptions::setVectorUnits(const QString vectorUnits) {
_vectorUnits->setText(vectorUnits);
}
@@ -121,6 +170,11 @@
}
+bool FFTOptions::rateUnitsDirty() const {
+ return !_rateUnits->text().isEmpty();
+}
+
+
void FFTOptions::setRateUnits(const QString rateUnits) {
_rateUnits->setText(rateUnits);
}
@@ -131,6 +185,11 @@
}
+bool FFTOptions::apodizeFunctionDirty() const {
+ return _apodizeFunction->currentIndex() != -1;
+}
+
+
void FFTOptions::setApodizeFunction(const ApodizeFunction apodizeFunction) {
_apodizeFunction->setCurrentItem((ApodizeFunction)apodizeFunction);
}
@@ -141,11 +200,31 @@
}
+bool FFTOptions::outputDirty() const {
+ return _output->currentIndex() != -1;
+}
+
+
void FFTOptions::setOutput(const PSDType output) {
_output->setCurrentItem((PSDType)output);
}
+void FFTOptions::clearValues() {
+ _sigma->clear();
+ _FFTLength->clear();
+ _sampleRate->clear();
+ _vectorUnits->clear();
+ _rateUnits->clear();
+ _apodize->setCheckState(Qt::PartiallyChecked);
+ _interleavedAverage->setCheckState(Qt::PartiallyChecked);
+ _removeMean->setCheckState(Qt::PartiallyChecked);
+ _interpolateOverHoles->setCheckState(Qt::PartiallyChecked);
+ _apodizeFunction->setCurrentIndex(-1);
+ _output->setCurrentIndex(-1);
+}
+
+
void FFTOptions::changedApodizeFxn() {
int gaussianIndex = 5;
if (_apodizeFunction->itemText(0).isEmpty()) {
--- branches/work/kst/portto4/kst/src/widgets/fftoptions.h #745661:745662
@@ -24,58 +24,72 @@
class FFTOptions : public QWidget, public Ui::FFTOptions {
Q_OBJECT
-public:
- FFTOptions(QWidget *parent = 0);
- ~FFTOptions();
+ public:
+ FFTOptions(QWidget *parent = 0);
+ ~FFTOptions();
- double sampleRate() const;
- void setSampleRate(const double sampleRate);
+ double sampleRate() const;
+ bool sampleRateDirty() const;
+ void setSampleRate(const double sampleRate);
- double sigma() const;
- void setSigma(const double sigma);
+ double sigma() const;
+ bool sigmaDirty() const;
+ void setSigma(const double sigma);
- bool interleavedAverage() const;
- void setInterleavedAverage(const bool interleavedAverage);
+ bool interleavedAverage() const;
+ bool interleavedAverageDirty() const;
+ void setInterleavedAverage(const bool interleavedAverage);
- int FFTLength() const;
- void setFFTLength(const int FFTLength);
+ int FFTLength() const;
+ bool FFTLengthDirty() const;
+ void setFFTLength(const int FFTLength);
- bool apodize() const;
- void setApodize(const bool apodize);
+ bool apodize() const;
+ bool apodizeDirty() const;
+ void setApodize(const bool apodize);
- bool removeMean() const;
- void setRemoveMean(const bool removeMean);
+ bool removeMean() const;
+ bool removeMeanDirty() const;
+ void setRemoveMean(const bool removeMean);
- QString vectorUnits() const;
- void setVectorUnits(const QString vectorUnits);
+ QString vectorUnits() const;
+ bool vectorUnitsDirty() const;
+ void setVectorUnits(const QString vectorUnits);
- QString rateUnits() const;
- void setRateUnits(const QString rateUnits);
+ QString rateUnits() const;
+ bool rateUnitsDirty() const;
+ void setRateUnits(const QString rateUnits);
- ApodizeFunction apodizeFunction() const;
- void setApodizeFunction(const ApodizeFunction apodizeFunction);
+ ApodizeFunction apodizeFunction() const;
+ bool apodizeFunctionDirty() const;
+ void setApodizeFunction(const ApodizeFunction apodizeFunction);
- PSDType output() const;
- void setOutput(const PSDType output);
+ PSDType output() const;
+ bool outputDirty() const;
+ void setOutput(const PSDType output);
- bool interpolateOverHoles() const;
- void setInterpolateOverHoles(const bool interpolateOverHoles);
+ bool interpolateOverHoles() const;
+ bool interpolateOverHolesDirty() const;
+ void setInterpolateOverHoles(const bool interpolateOverHoles);
- void setWidgetDefaults();
- void loadWidgetDefaults();
+ void clearValues();
- //void update();
+ void setWidgetDefaults();
+ void loadWidgetDefaults();
-public slots:
- void changedApodizeFxn();
- void clickedInterleaved();
- void clickedApodize();
- void synch();
- bool checkValues();
- bool checkGivenValues(double sampRate, int FFTLen);
+ Q_SIGNALS:
+ void modified();
-private:
- void init();
+ public slots:
+ void changedApodizeFxn();
+ void clickedInterleaved();
+ void clickedApodize();
+ void synch();
+ bool checkValues();
+ bool checkGivenValues(double sampRate, int FFTLen);
+
+ private:
+ void init();
} KST_EXPORT;
}
More information about the Kst
mailing list