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

Mike Fenton mike at staikos.net
Tue Nov 20 15:18:09 CET 2007


SVN commit 739100 by fenton:

Add context menu support for object creation from DataManager.
Extend DialogLauncher framework to allow specification of default selection.


 M  +5 -0      libkstapp/csddialog.cpp  
 M  +2 -0      libkstapp/csddialog.h  
 M  +5 -0      libkstapp/curvedialog.cpp  
 M  +2 -0      libkstapp/curvedialog.h  
 M  +70 -0     libkstapp/datamanager.cpp  
 M  +5 -0      libkstapp/datamanager.h  
 M  +20 -5     libkstapp/dialoglaunchergui.cpp  
 M  +5 -5      libkstapp/dialoglaunchergui.h  
 M  +5 -0      libkstapp/histogramdialog.cpp  
 M  +2 -0      libkstapp/histogramdialog.h  
 M  +5 -0      libkstapp/imagedialog.cpp  
 M  +2 -0      libkstapp/imagedialog.h  
 M  +5 -0      libkstapp/powerspectrumdialog.cpp  
 M  +2 -0      libkstapp/powerspectrumdialog.h  
 M  +10 -5     libkstmath/dialoglauncher.cpp  
 M  +7 -5      libkstmath/dialoglauncher.h  


--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.cpp #739099:739100
@@ -134,6 +134,11 @@
 }
 
 
+void CSDDialog::setVector(VectorPtr vector) {
+  _CSDTab->setVector(vector);
+}
+
+
 void CSDDialog::configureTab(ObjectPtr object) {
   if (CSDPtr csd = kst_cast<CSD>(object)) {
     _CSDTab->setVector(csd->vector());
--- branches/work/kst/portto4/kst/src/libkstapp/csddialog.h #739099:739100
@@ -58,6 +58,8 @@
     CSDDialog(ObjectPtr dataObject, QWidget *parent = 0);
     virtual ~CSDDialog();
 
+    void setVector(VectorPtr vector);
+
   protected:
     virtual QString tagString() const;
     virtual ObjectPtr createNewDataObject() const;
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.cpp #739099:739100
@@ -205,6 +205,11 @@
 }
 
 
+void CurveDialog::setVector(VectorPtr vector) {
+  _curveTab->setYVector(vector);
+}
+
+
 void CurveDialog::updateButtons() {
   _buttonBox->button(QDialogButtonBox::Ok)->setEnabled(_curveTab->xVector() && _curveTab->yVector());
 }
--- branches/work/kst/portto4/kst/src/libkstapp/curvedialog.h #739099:739100
@@ -67,6 +67,8 @@
     CurveDialog(ObjectPtr dataObject, QWidget *parent = 0);
     virtual ~CurveDialog();
 
+    void setVector(VectorPtr vector);
+
   protected:
     virtual QString tagString() const;
     virtual ObjectPtr createNewDataObject() const;
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #739099:739100
@@ -139,6 +139,31 @@
         connect(action, SIGNAL(triggered()), this, SLOT(showEditDialog()));
         actions.append(action);
 
+        if (VectorPtr v = kst_cast<Vector>(_currentObject)) {
+
+          action = new DataButtonAction(tr("Make Curve"));
+          connect(action, SIGNAL(triggered()), this, SLOT(showCurveDialog()));
+          actions.append(action);
+
+          action = new DataButtonAction(tr("Make Power Spectrum"));
+          connect(action, SIGNAL(triggered()), this, SLOT(showPowerSpectrumDialog()));
+          actions.append(action);
+
+          action = new DataButtonAction(tr("Make Spectrogram"));
+          connect(action, SIGNAL(triggered()), this, SLOT(showCSDDialog()));
+          actions.append(action);
+
+          action = new DataButtonAction(tr("Make Histogram"));
+          connect(action, SIGNAL(triggered()), this, SLOT(showHistogramDialog()));
+          actions.append(action);
+
+        } else if (MatrixPtr m = kst_cast<Matrix>(_currentObject)) {
+          action = new DataButtonAction(tr("Make Image"));
+          connect(action, SIGNAL(triggered()), this, SLOT(showImageDialog()));
+          actions.append(action);
+        } else if (RelationPtr r = kst_cast<Relation>(_currentObject)) {
+        }
+
         action = new DataButtonAction(tr("Delete"));
         connect(action, SIGNAL(triggered()), this, SLOT(deleteObject()));
         actions.append(action);
@@ -177,6 +202,51 @@
 }
 
 
+void DataManager::showCurveDialog() {
+  if (_currentObject) {
+    if (VectorPtr vector = kst_cast<Vector>(_currentObject)) {
+      DialogLauncher::self()->showCurveDialog(0, vector);
+    }
+  }
+}
+
+
+void DataManager::showCSDDialog() {
+  if (_currentObject) {
+    if (VectorPtr vector = kst_cast<Vector>(_currentObject)) {
+      DialogLauncher::self()->showCSDDialog(0, vector);
+    }
+  }
+}
+
+
+void DataManager::showPowerSpectrumDialog() {
+  if (_currentObject) {
+    if (VectorPtr vector = kst_cast<Vector>(_currentObject)) {
+      DialogLauncher::self()->showPowerSpectrumDialog(0, vector);
+    }
+  }
+}
+
+
+void DataManager::showHistogramDialog() {
+  if (_currentObject) {
+    if (VectorPtr vector = kst_cast<Vector>(_currentObject)) {
+      DialogLauncher::self()->showHistogramDialog(0, vector);
+    }
+  }
+}
+
+
+void DataManager::showImageDialog() {
+  if (_currentObject) {
+    if (MatrixPtr matrix = kst_cast<Matrix>(_currentObject)) {
+      DialogLauncher::self()->showImageDialog(0, matrix);
+    }
+  }
+}
+
+
 void DataManager::deleteObject() {
   qDebug() << "deleteObject" << endl;
 }
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.h #739099:739100
@@ -36,6 +36,11 @@
     void showContextMenu(const QPoint &);
     void showEditDialog();
     void deleteObject();
+    void showCurveDialog();
+    void showCSDDialog();
+    void showHistogramDialog();
+    void showPowerSpectrumDialog();
+    void showImageDialog();
 
   private:
     Document *_doc;
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.cpp #739099:739100
@@ -57,14 +57,20 @@
 }
 
 
-void DialogLauncherGui::showCurveDialog(ObjectPtr objectPtr) {
+void DialogLauncherGui::showCurveDialog(ObjectPtr objectPtr, VectorPtr vector) {
   CurveDialog dialog(objectPtr, kstApp->mainWindow());
+  if (vector) {
+    dialog.setVector(vector);
+  }
   dialog.exec();
 }
 
 
-void DialogLauncherGui::showImageDialog(ObjectPtr objectPtr) {
+void DialogLauncherGui::showImageDialog(ObjectPtr objectPtr, MatrixPtr matrix) {
   ImageDialog dialog(objectPtr, kstApp->mainWindow());
+  if (matrix) {
+    dialog.setMatrix(matrix);
+  }
   dialog.exec();
 }
 
@@ -74,20 +80,29 @@
 }
 
 
-void DialogLauncherGui::showHistogramDialog(ObjectPtr objectPtr) {
+void DialogLauncherGui::showHistogramDialog(ObjectPtr objectPtr, VectorPtr vector) {
   HistogramDialog dialog(objectPtr, kstApp->mainWindow());
+  if (vector) {
+    dialog.setVector(vector);
+  }
   dialog.exec();
 }
 
 
-void DialogLauncherGui::showPowerSpectrumDialog(ObjectPtr objectPtr) {
+void DialogLauncherGui::showPowerSpectrumDialog(ObjectPtr objectPtr, VectorPtr vector) {
   PowerSpectrumDialog dialog(objectPtr, kstApp->mainWindow());
+  if (vector) {
+    dialog.setVector(vector);
+  }
   dialog.exec();
 }
 
 
-void DialogLauncherGui::showCSDDialog(ObjectPtr objectPtr) {
+void DialogLauncherGui::showCSDDialog(ObjectPtr objectPtr, VectorPtr vector) {
   CSDDialog dialog(objectPtr, kstApp->mainWindow());
+  if (vector) {
+    dialog.setVector(vector);
+  }
   dialog.exec();
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.h #739099:739100
@@ -33,18 +33,18 @@
     virtual void showStringDialog(ObjectPtr objectPtr = 0);
 
     //standard objects
-    virtual void showCurveDialog(ObjectPtr objectPtr = 0);
+    virtual void showCurveDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
-    virtual void showImageDialog(ObjectPtr objectPtr = 0);
+    virtual void showImageDialog(ObjectPtr objectPtr = 0, MatrixPtr matrix = 0);
 
     //standard data objects
     virtual void showEquationDialog(ObjectPtr objectPtr = 0);
 
-    virtual void showHistogramDialog(ObjectPtr objectPtr = 0);
+    virtual void showHistogramDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
-    virtual void showPowerSpectrumDialog(ObjectPtr objectPtr = 0);
+    virtual void showPowerSpectrumDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
-    virtual void showCSDDialog(ObjectPtr objectPtr = 0);
+    virtual void showCSDDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
     virtual void showEventMonitorDialog(ObjectPtr objectPtr = 0);
 
--- branches/work/kst/portto4/kst/src/libkstapp/histogramdialog.cpp #739099:739100
@@ -243,6 +243,11 @@
 }
 
 
+void HistogramDialog::setVector(VectorPtr vector) {
+  _histogramTab->setVector(vector);
+}
+
+
 ObjectPtr HistogramDialog::createNewDataObject() const {
   Q_ASSERT(_document && _document->objectStore());
   ObjectTag tag = _document->objectStore()->suggestObjectTag<Histogram>(tagString(), ObjectTag::globalTagContext);
--- branches/work/kst/portto4/kst/src/libkstapp/histogramdialog.h #739099:739100
@@ -71,6 +71,8 @@
     HistogramDialog(ObjectPtr dataObject, QWidget *parent = 0);
     virtual ~HistogramDialog();
 
+    void setVector(VectorPtr vector);
+
   protected:
     virtual QString tagString() const;
     virtual ObjectPtr createNewDataObject() const;
--- branches/work/kst/portto4/kst/src/libkstapp/imagedialog.cpp #739099:739100
@@ -266,6 +266,11 @@
 }
 
 
+void ImageDialog::setMatrix(MatrixPtr matrix) {
+  _imageTab->setMatrix(matrix);
+}
+
+
 void ImageDialog::configureTab(ObjectPtr object) {
   if (ImagePtr image = kst_cast<Image>(object)) {
     _imageTab->setMatrix(image->matrix());
--- branches/work/kst/portto4/kst/src/libkstapp/imagedialog.h #739099:739100
@@ -93,6 +93,8 @@
     ImageDialog(ObjectPtr dataObject, QWidget *parent = 0);
     virtual ~ImageDialog();
 
+    void setMatrix(MatrixPtr matrix);
+
   protected:
     virtual QString tagString() const;
     virtual ObjectPtr createNewDataObject() const;
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.cpp #739099:739100
@@ -121,6 +121,11 @@
 }
 
 
+void PowerSpectrumDialog::setVector(VectorPtr vector) {
+  _powerSpectrumTab->setVector(vector);
+}
+
+
 void PowerSpectrumDialog::configureTab(ObjectPtr object) {
   if (!object) {
     _powerSpectrumTab->FFTOptionsWidget()->setSampleRate(Kst::dialogDefaults->value("spectrum/freq",100.0).toDouble());
--- branches/work/kst/portto4/kst/src/libkstapp/powerspectrumdialog.h #739099:739100
@@ -55,6 +55,8 @@
     PowerSpectrumDialog(ObjectPtr dataObject, QWidget *parent = 0);
     virtual ~PowerSpectrumDialog();
 
+    void setVector(VectorPtr vector);
+
   protected:
     virtual QString tagString() const;
     virtual ObjectPtr createNewDataObject() const;
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.cpp #739099:739100
@@ -72,13 +72,15 @@
 }
 
 
-void DialogLauncher::showCurveDialog(ObjectPtr objectPtr) {
+void DialogLauncher::showCurveDialog(ObjectPtr objectPtr, VectorPtr vector) {
   Q_UNUSED(objectPtr);
+  Q_UNUSED(vector);
 }
 
 
-void DialogLauncher::showImageDialog(ObjectPtr objectPtr) {
+void DialogLauncher::showImageDialog(ObjectPtr objectPtr, MatrixPtr matrix) {
   Q_UNUSED(objectPtr);
+  Q_UNUSED(matrix);
 }
 
 
@@ -92,18 +94,21 @@
 }
 
 
-void DialogLauncher::showHistogramDialog(ObjectPtr objectPtr) {
+void DialogLauncher::showHistogramDialog(ObjectPtr objectPtr, VectorPtr vector) {
   Q_UNUSED(objectPtr);
+  Q_UNUSED(vector);
 }
 
 
-void DialogLauncher::showPowerSpectrumDialog(ObjectPtr objectPtr) {
+void DialogLauncher::showPowerSpectrumDialog(ObjectPtr objectPtr, VectorPtr vector) {
   Q_UNUSED(objectPtr);
+  Q_UNUSED(vector);
 }
 
 
-void DialogLauncher::showCSDDialog(ObjectPtr objectPtr) {
+void DialogLauncher::showCSDDialog(ObjectPtr objectPtr, VectorPtr vector) {
   Q_UNUSED(objectPtr);
+  Q_UNUSED(vector);
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.h #739099:739100
@@ -21,6 +21,8 @@
 #include <QObject>
 
 #include "object.h"
+#include "vector.h"
+#include "matrix.h"
 
 #include "kst_export.h"
 
@@ -49,18 +51,18 @@
     virtual void showStringDialog(ObjectPtr objectPtr = 0);
 
     //standard objects
-    virtual void showCurveDialog(ObjectPtr objectPtr = 0);
+    virtual void showCurveDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
-    virtual void showImageDialog(ObjectPtr objectPtr = 0);
+    virtual void showImageDialog(ObjectPtr objectPtr = 0, MatrixPtr matrix = 0);
 
     //standard data objects
     virtual void showEquationDialog(ObjectPtr objectPtr = 0);
 
-    virtual void showHistogramDialog(ObjectPtr objectPtr = 0);
+    virtual void showHistogramDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
-    virtual void showPowerSpectrumDialog(ObjectPtr objectPtr = 0);
+    virtual void showPowerSpectrumDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
-    virtual void showCSDDialog(ObjectPtr objectPtr = 0);
+    virtual void showCSDDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
 
     virtual void showEventMonitorDialog(ObjectPtr objectPtr = 0);
 


More information about the Kst mailing list