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

Barth Netterfield netterfield at astro.utoronto.ca
Fri Jul 10 22:39:15 CEST 2009


SVN commit 994600 by netterfield:

Fix plot dialog setting Y mean centered zoom mode.
X mean centered zoom mode not fixed yet.



 M  +0 -1      plotaxis.cpp  
 M  +46 -8     plotitem.cpp  
 M  +33 -3     plotitem.h  
 M  +6 -1      plotitemdialog.cpp  
 M  +9 -2      sharedaxisboxitem.cpp  
 M  +1 -0      sharedaxisboxitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.cpp #994599:994600
@@ -949,7 +949,6 @@
   qDebug() << "MajorTickCount:" << M << "Range:" << R
            << "\n\tranges:" << r1 << r2 << r5
            << "\n\tspaces:" << d1 << d2 << d5
-           << "\n\tenforce min tick mode:" << enforceMin
            << endl;
 #endif
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #994599:994600
@@ -250,10 +250,10 @@
   registerShortcut(_zoomYTied);
   connect(_zoomYTied, SIGNAL(triggered()), this, SLOT(zoomYTied()));
 
-  _zoomYMeanCentered = new QAction(tr("Y-Zoom Mean-centered"), this);
-  _zoomYMeanCentered->setShortcut(Qt::Key_A);
-  registerShortcut(_zoomYMeanCentered);
-  connect(_zoomYMeanCentered, SIGNAL(triggered()), this, SLOT(zoomYMeanCentered()));
+  _zoomMeanCentered = new QAction(tr("Zoom Mean-centered Y"), this);
+  _zoomMeanCentered->setShortcut(Qt::Key_A);
+  registerShortcut(_zoomMeanCentered);
+  connect(_zoomMeanCentered, SIGNAL(triggered()), this, SLOT(zoomMeanCentered()));
 
   _zoomXMaximum = new QAction(tr("X-Zoom Maximum"), this);
   _zoomXMaximum->setShortcut(Qt::CTRL+Qt::Key_M);
@@ -381,7 +381,7 @@
   _zoomMenu->addAction(_zoomMaximum);
   _zoomMenu->addAction(_zoomMaxSpikeInsensitive);
   _zoomMenu->addAction(_zoomPrevious);
-  _zoomMenu->addAction(_zoomYMeanCentered);
+  _zoomMenu->addAction(_zoomMeanCentered);
   _zoomMenu->addAction(_zoomTied);
   _zoomMenu->addAction(_adjustImageColorscale);
 
@@ -2651,6 +2651,20 @@
 }
 
 
+void PlotItem::zoomMeanCentered(bool force) {
+#if DEBUG_ZOOM
+  qDebug() << "zoomMeanCentered" << endl;
+#endif
+  if (isInSharedAxisBox() && !force) {
+    sharedAxisBox()->zoomMeanCentered(this);
+  } else {
+    ZoomCommand *cmd = new ZoomMeanCenteredCommand(this, force);
+    _undoStack->push(cmd);
+    cmd->redo();
+  }
+}
+
+
 void PlotItem::zoomYMeanCentered(bool force) {
 #if DEBUG_ZOOM
   qDebug() << "zoomYMeanCentered" << endl;
@@ -3577,7 +3591,7 @@
 /*
  * X axis zoom to Auto, Y axis zoom to Mean Centered.
  */
-void ZoomYMeanCenteredCommand::applyZoomTo(PlotItem *item, bool applyX, bool applyY) {
+void ZoomMeanCenteredCommand::applyZoomTo(PlotItem *item, bool applyX, bool applyY) {
   if (applyX && applyY) {
     item->xAxis()->setAxisZoomMode(PlotAxis::Auto);
     item->yAxis()->setAxisZoomMode(PlotAxis::MeanCentered);
@@ -3595,14 +3609,38 @@
 }
 
 
-void ZoomYMeanCenteredCommand::applyZoomTo(ViewItem *item, bool applyX, bool applyY) {
+void ZoomMeanCenteredCommand::applyZoomTo(ViewItem *item, bool applyX, bool applyY) {
   SharedAxisBoxItem *shareBox = qobject_cast<SharedAxisBoxItem*>(item);
   if (shareBox) {
     if (applyX && applyY) {
-      shareBox->zoomYMeanCentered(0);
+      shareBox->zoomMeanCentered(0);
     } else if (applyX) {
       shareBox->zoomXMaximum(0);
     } else if (applyY) {
+      shareBox->zoomMeanCentered(0);
+    }
+  }
+}
+
+/*
+ * X axis zoom unchanged, Y axis zoom to Mean Centered.
+ */
+void ZoomYMeanCenteredCommand::applyZoomTo(PlotItem *item, bool applyX, bool applyY) {
+  Q_UNUSED(applyX);
+
+  if (applyY) {
+    item->yAxis()->setAxisZoomMode(PlotAxis::MeanCentered);
+    QRectF compute = item->computedProjectionRect();
+    item->setProjectionRect(QRectF(item->projectionRect().x(), compute.y(), item->projectionRect().width(), compute.height()));
+  }
+}
+
+
+void ZoomYMeanCenteredCommand::applyZoomTo(ViewItem *item, bool applyX, bool applyY) {
+  Q_UNUSED(applyX);
+  SharedAxisBoxItem *shareBox = qobject_cast<SharedAxisBoxItem*>(item);
+  if (shareBox) {
+    if (applyY) {
       shareBox->zoomYMeanCentered(0);
     }
   }
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #994599:994600
@@ -268,7 +268,7 @@
     void zoomXTied();
     void zoomYTied();
 
-    void zoomYMeanCentered(bool force = false);
+    //void zoomXMeanCentered(bool force = false);
     void zoomXMaximum(bool force = false);
     void zoomXNoSpike(bool force = false);
     void zoomXAutoBorder(bool force = false);
@@ -279,6 +279,8 @@
     void zoomNormalizeXtoY(bool force = false);
     void zoomLogX(bool force = false, bool autoLog = true, bool enableLog = false);
 
+    void zoomMeanCentered(bool force = false);
+    void zoomYMeanCentered(bool force = false);
     void zoomYLocalMaximum(bool force = false);
     void zoomYMaximum(bool force = false);
     void zoomYNoSpike(bool force = false);
@@ -448,7 +450,7 @@
     QAction *_zoomTied;
     QAction *_zoomXTied;
     QAction *_zoomYTied;
-    QAction *_zoomYMeanCentered;
+    QAction *_zoomMeanCentered;
     QAction *_zoomXMaximum;
     QAction *_zoomXAutoBorder;
     QAction *_zoomXNoSpike;
@@ -513,6 +515,8 @@
     friend class ZoomMaximumCommand;
     friend class ZoomGeneralCommand;
     friend class ZoomMaxSpikeInsensitiveCommand;
+    friend class ZoomMeanCenteredCommand;
+    //friend class ZoomXMeanCenteredCommand;
     friend class ZoomYMeanCenteredCommand;
     friend class ZoomXMaximumCommand;
     friend class ZoomYLocalMaximumCommand;
@@ -635,17 +639,43 @@
     virtual void applyZoomTo(ViewItem *item, bool applyX = true, bool applyY = true);
 };
 
+class KST_EXPORT ZoomMeanCenteredCommand : public ZoomCommand
+{
+  public:
+    ZoomMeanCenteredCommand(PlotItem *item, bool forced = false)
+        : ZoomCommand(item, QObject::tr("Zoom Mean Centered"), forced) {}
+    virtual ~ZoomMeanCenteredCommand() {}
+
+    virtual void applyZoomTo(PlotItem *item, bool applyX = true, bool applyY = true);
+    virtual void applyZoomTo(ViewItem *item, bool applyX = true, bool applyY = true);
+};
+
+/*
+class KST_EXPORT ZoomXMeanCenteredCommand : public ZoomCommand
+{
+  public:
+    ZoomXMeanCenteredCommand(PlotItem *item, bool forced = false)
+        : ZoomCommand(item, QObject::tr("Zoom Mean Centered"), forced) {}
+    virtual ~ZoomXMeanCenteredCommand() {}
+
+    virtual void applyZoomTo(PlotItem *item, bool applyX = true, bool applyY = true);
+    virtual void applyZoomTo(ViewItem *item, bool applyX = true, bool applyY = true);
+};
+
+*/
+
 class KST_EXPORT ZoomYMeanCenteredCommand : public ZoomCommand
 {
   public:
     ZoomYMeanCenteredCommand(PlotItem *item, bool forced = false)
-        : ZoomCommand(item, QObject::tr("Zoom Y Mean Centered"), forced) {}
+        : ZoomCommand(item, QObject::tr("Zoom Mean Centered"), forced) {}
     virtual ~ZoomYMeanCenteredCommand() {}
 
     virtual void applyZoomTo(PlotItem *item, bool applyX = true, bool applyY = true);
     virtual void applyZoomTo(ViewItem *item, bool applyX = true, bool applyY = true);
 };
 
+
 class KST_EXPORT ZoomXMaximumCommand : public ZoomCommand
 {
   public:
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #994599:994600
@@ -642,6 +642,8 @@
       item->zoomXAutoBorder();
     } else if (xZoomMode == PlotAxis::SpikeInsensitive) {
       item->zoomXNoSpike();
+    } else if (xZoomMode == PlotAxis::MeanCentered) {
+
     }
   }
   if (xZoomMode == PlotAxis::MeanCentered || xZoomMode == PlotAxis::FixedExpression) {
@@ -656,9 +658,12 @@
       item->zoomYNoSpike();
     }
   }
-  if (yZoomMode == PlotAxis::MeanCentered || yZoomMode == PlotAxis::FixedExpression) {
+  if (/*yZoomMode == PlotAxis::MeanCentered || */ yZoomMode == PlotAxis::FixedExpression) {
     item->zoomYRange(newProjectionRect);
   }
+  if (yZoomMode == PlotAxis::MeanCentered) {
+      item->zoomYMeanCentered();
+  }
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.cpp #994599:994600
@@ -485,6 +485,14 @@
 }
 
 
+void SharedAxisBoxItem::zoomMeanCentered(PlotItem* originPlotItem) {
+#if DEBUG_ZOOM
+  qDebug() << "zoomMeanCentered" << endl;
+#endif
+  _yAxisZoomMode = PlotAxis::MeanCentered;
+  applyZoom(computeRect(PlotAxis::Auto, PlotAxis::MeanCentered), originPlotItem, false, true);
+}
+
 void SharedAxisBoxItem::zoomYMeanCentered(PlotItem* originPlotItem) {
 #if DEBUG_ZOOM
   qDebug() << "zoomYMeanCentered" << endl;
@@ -494,7 +502,6 @@
   applyZoom(computeRect(PlotAxis::Auto, PlotAxis::MeanCentered), originPlotItem, false, true);
 }
 
-
 void SharedAxisBoxItem::zoomXMaximum(PlotItem* originPlotItem) {
 #if DEBUG_ZOOM
   qDebug() << "zoomXMaximum" << endl;
@@ -965,7 +972,7 @@
         zoomYNoSpike(0);
         break;
       case PlotAxis::MeanCentered:
-        zoomYMeanCentered(0);
+        zoomMeanCentered(0);
         break;
       default:
         break;
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.h #994599:994600
@@ -66,6 +66,7 @@
     void zoomYRange(const QRectF &projection, PlotItem* originPlotItem);
     void zoomMaximum(PlotItem* originPlotItem);
     void zoomMaxSpikeInsensitive(PlotItem* originPlotItem);
+    void zoomMeanCentered(PlotItem* originPlotItem);
 
     void zoomXMaximum(PlotItem* originPlotItem);
     void zoomXNoSpike(PlotItem* originPlotItem);


More information about the Kst mailing list