[Kst] branches/work/kst/portto4/kst/src

Mike Fenton mike at staikos.net
Wed Dec 12 20:35:11 CET 2007


SVN commit 747702 by fenton:

Add Apply and EditMultiple Functionality to CSDDialog.
Disable InterpolateOverHoles in FFTOptions for CSD's.


 M  +102 -17   libkstapp/csddialog.cpp  
 M  +5 -0      libkstapp/csddialog.h  
 M  +6 -0      widgets/fftoptions.cpp  
 M  +1 -0      widgets/fftoptions.h  


--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.cpp #747701:747702
@@ -12,6 +12,7 @@
 #include "csddialog.h"
 
 #include "dialogpage.h"
+#include "editmultiplewidget.h"
 
 #include "psd.h"
 
@@ -41,6 +42,9 @@
   setupUi(this);
   setTabTitle(tr("Cumulative Spectral Decay"));
   connect(_vector, SIGNAL(selectionChanged(QString)), this, SLOT(selectionChanged()));
+  connect(_FFTOptions, SIGNAL(modified()), this, SIGNAL(modified()));
+  connect(_vector, SIGNAL(selectionChanged(QString)), this, SIGNAL(modified()));
+  connect(_windowSize, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
 }
 
 
@@ -58,6 +62,11 @@
 }
 
 
+bool CSDTab::vectorDirty() const {
+  return _vector->selectedVectorDirty();
+}
+
+
 void CSDTab::setVector(const VectorPtr vector) {
   _vector->setSelectedVector(vector);
 }
@@ -83,6 +92,11 @@
 }
 
 
+bool CSDTab::windowSizeDirty() const {
+  return !_windowSize->text().isEmpty();
+}
+
+
 void CSDTab::setWindowSize(const int windowSize) {
   _windowSize->setValue(windowSize);
 }
@@ -100,6 +114,14 @@
 }
 
 
+void CSDTab::clearTabValues() {
+  _vector->clearSelection();
+  _windowSize->clear();
+  _FFTOptions->clearValues();
+  _FFTOptions->disableInterpolateOverHoles();
+}
+
+
 CSDDialog::CSDDialog(ObjectPtr dataObject, QWidget *parent)
   : DataDialog(dataObject, parent) {
 
@@ -115,7 +137,13 @@
     configureTab(dataObject);
   }
 
-  connect(_CSDTab, SIGNAL(optionsChanged()), this, SLOT(updateButtons()));
+  _CSDTab->FFTOptionsWidget()->disableInterpolateOverHoles();
+
+  connect(_CSDTab, SIGNAL(optionsChanged()), this, SLOT(updateButtons()));  
+  connect(this, SIGNAL(editMultipleMode()), this, SLOT(editMultipleMode()));
+  connect(this, SIGNAL(editSingleMode()), this, SLOT(editSingleMode()));
+
+  connect(_CSDTab, SIGNAL(modified()), this, SLOT(modified()));
   updateButtons();
 }
 
@@ -129,8 +157,18 @@
 }
 
 
+void CSDDialog::editMultipleMode() {
+  _CSDTab->clearTabValues();
+}
+
+
+void CSDDialog::editSingleMode() {
+   configureTab(dataObject());
+}
+
+
 void CSDDialog::updateButtons() {
-  _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_CSDTab->vector());
+  _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_CSDTab->vector() || (editMode() == EditMultiple));
 }
 
 
@@ -154,6 +192,14 @@
     _CSDTab->FFTOptionsWidget()->setSigma(csd->gaussianSigma());
     _CSDTab->FFTOptionsWidget()->setOutput(csd->output());
     _CSDTab->hideImageOptions();
+    if (_editMultipleWidget) {
+      QStringList objectList;
+      CSDList objects = _document->objectStore()->getObjects<CSD>();
+      foreach(CSDPtr object, objects) {
+        objectList.append(object->tag().displayString());
+      }
+      _editMultipleWidget->addObjects(objectList);
+    }
   }
 }
 
@@ -221,22 +267,61 @@
 
 ObjectPtr CSDDialog::editExistingDataObject() const {
   if (CSDPtr csd = kst_cast<CSD>(dataObject())) {
-    csd->writeLock();
-    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());
+    if (editMode() == EditMultiple) {
+      const FFTOptions *options = _CSDTab->FFTOptionsWidget();
+      QStringList objects = _editMultipleWidget->selectedObjects();
+      foreach (QString objectTag, objects) {
+        CSDPtr csd = kst_cast<CSD>(_document->objectStore()->retrieveObject(ObjectTag::fromString(objectTag)));
+        if (csd) {
+          VectorPtr vector = _CSDTab->vectorDirty() ? _CSDTab->vector() : csd->vector();
+          const double frequency = options->sampleRateDirty() ? options->sampleRate() : csd->frequency();
+          const double sigma = options->sigmaDirty() ? options->sigma() : csd->gaussianSigma();
+          const bool apodize = options->apodizeDirty() ? options->apodize() : csd->apodize();
+          const bool removeMean = options->removeMeanDirty() ? options->removeMean() : csd->removeMean();
+          const bool interleavedAverage = options->interleavedAverageDirty() ? options->interleavedAverage() : csd->average();
+          const int FFTLength = options->FFTLengthDirty() ? options->FFTLength() : csd->length();
+          const ApodizeFunction apodizeFunction = options->apodizeFunctionDirty() ? options->apodizeFunction() : csd->apodizeFxn();
+          const PSDType output = options->outputDirty() ? options->output() : csd->output();
+          const QString vectorUnits = options->vectorUnitsDirty() ? options->vectorUnits() : csd->vectorUnits();
+          const QString rateUnits = options->rateUnitsDirty() ? options->rateUnits() : csd->rateUnits();
+          const int windowSize = _CSDTab->windowSizeDirty() ? _CSDTab->windowSize() : csd->windowSize();
 
-    csd->update(0);
-    csd->unlock();
+          csd->writeLock();
+          csd->change(vector,
+                      frequency,
+                      interleavedAverage,
+                      removeMean,
+                      apodize,
+                      apodizeFunction,
+                      windowSize,
+                      FFTLength,
+                      sigma,
+                      output,
+                      vectorUnits,
+                      rateUnits);
+
+          csd->update(0);
+          csd->unlock();
+        }
+      }
+    } else {
+      csd->writeLock();
+      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->update(0);
+      csd->unlock();
+    }
   }
   return dataObject();
 }
--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.h #747701:747702
@@ -34,9 +34,11 @@
     void setObjectStore(ObjectStore *store);
 
     VectorPtr vector() const;
+    bool vectorDirty() const;
     void setVector(const VectorPtr vector);
 
     int windowSize() const;
+    bool windowSizeDirty() const;
     void setWindowSize(const int windowSize);
 
     CurvePlacement* curvePlacement() const;
@@ -44,6 +46,7 @@
     ColorPalette* colorPalette() const;
 
     void hideImageOptions();
+    void clearTabValues();
 
   private Q_SLOTS:
     void selectionChanged();
@@ -67,6 +70,8 @@
 
   private Q_SLOTS:
     void updateButtons();
+    void editMultipleMode();
+    void editSingleMode();
 
   private:
     void configureTab(ObjectPtr object);
--- branches/work/kst/portto4/kst/src/widgets/fftoptions.cpp #747701:747702
@@ -225,6 +225,12 @@
 }
 
 
+void FFTOptions::disableInterpolateOverHoles() {
+  _interpolateOverHoles->setChecked(false);
+  _interpolateOverHoles->setEnabled(false);
+}
+
+
 void FFTOptions::changedApodizeFxn() {
   int gaussianIndex = 5;
   if (_apodizeFunction->itemText(0).isEmpty()) {
--- branches/work/kst/portto4/kst/src/widgets/fftoptions.h #747701:747702
@@ -72,6 +72,7 @@
     bool interpolateOverHolesDirty() const;
     void setInterpolateOverHoles(const bool interpolateOverHoles);
 
+    void disableInterpolateOverHoles();
     void clearValues();
 
     void setWidgetDefaults();


More information about the Kst mailing list