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

Barth Netterfield netterfield at astro.utoronto.ca
Wed Jul 15 01:36:11 CEST 2009


SVN commit 996831 by netterfield:

Update bugs
Fix mean centered mode.
Fix precision in plot dialog range tab.



 M  +0 -6      devel-docs/Kst2Specs/Bugs  
 M  +18 -1     devel-docs/Kst2Specs/FixedBugs  
 M  +3 -1      devel-docs/Kst2Specs/Wishlist  
 M  +49 -6     src/libkstapp/plotitem.cpp  
 M  +12 -8     src/libkstapp/plotitem.h  
 M  +7 -5      src/libkstapp/plotitemdialog.cpp  
 M  +6 -6      src/libkstapp/rangetab.cpp  
 M  +9 -0      src/libkstapp/sharedaxisboxitem.cpp  
 M  +1 -0      src/libkstapp/sharedaxisboxitem.h  


--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Bugs #996830:996831
@@ -59,9 +59,3 @@
 
 Then kst closes and and I get the help in the console (cygwin) in the windows cmd.exe I don’t get any help…
 
---------------------
-
-plot dialog bugs:
-  -doesn't properly fill zoom mode with 'mean centered'.
-  -doesn't fill range with enough significant figures
-*cbn*
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/FixedBugs #996830:996831
@@ -964,4 +964,21 @@
 
 
 Intelligent and useful window title:
-  If a kst file has been opened, the window title should be kst <kstfile>
\ No newline at end of file
+  If a kst file has been opened, the window title should be kst <kstfile>
+
+plot dialog bug:  -doesn't properly fill zoom mode with 'mean centered'.
+
+--------------------
+
+Plot Bug:
+  Mean Centered X range doesn't seem to work:
+  create a plot with a curve
+  Mean centered X range -> apply.  Does the right thing.
+  Now advance one screen.  Plot does not advance.
+
+--------------------
+
+plot dialog bugs:
+  -doesn't fill range with enough significant figures
+*cbn*
+
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Wishlist #996830:996831
@@ -1,5 +1,7 @@
 
-When a new plot is added to an tab which already has plots in it (eg, from the Placement widget), then the label font sizes should be based on the label font sizes of the plots already in the tab.  (either 'vote' or use the first one).
+When a new plot is added to an tab which already has plots in it (eg, from the Placement widget), 
+then the label font sizes should be based on the label font sizes of the plots already in the tab.  
+(either 'vote' or use the first one).
 All font properties replicated.  Use the first one.
 
 ---------
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #996830:996831
@@ -571,9 +571,14 @@
     #endif
     sharedAxisBox()->updateZoomForDataUpdate();
   } else {
-    if (xAxis()->axisZoomMode() == PlotAxis::Auto) {
-      if (yAxis()->axisZoomMode() == PlotAxis::AutoBorder || yAxis()->axisZoomMode() == PlotAxis::Auto
-          || yAxis()->axisZoomMode() == PlotAxis::SpikeInsensitive || yAxis()->axisZoomMode() == PlotAxis::MeanCentered) {
+    if ((xAxis()->axisZoomMode() == PlotAxis::Auto) ||
+        (xAxis()->axisZoomMode() == PlotAxis::MeanCentered) ||
+        (xAxis()->axisZoomMode() == PlotAxis::AutoBorder) ||
+        (xAxis()->axisZoomMode() == PlotAxis::SpikeInsensitive)) {
+      if ((yAxis()->axisZoomMode() == PlotAxis::AutoBorder) ||
+          (yAxis()->axisZoomMode() == PlotAxis::Auto) ||
+          (yAxis()->axisZoomMode() == PlotAxis::SpikeInsensitive) ||
+          (yAxis()->axisZoomMode() == PlotAxis::MeanCentered)) {
   #if DEBUG_UPDATE_CYCLE > 1
         qDebug() << "\t\t\tUP - Updating Plot Projection Rect - X and Y Maximum";
   #endif
@@ -2665,20 +2670,34 @@
 }
 
 
-void PlotItem::zoomYMeanCentered(bool force) {
+void PlotItem::zoomYMeanCentered(qreal dY, bool force) {
 #if DEBUG_ZOOM
   qDebug() << "zoomYMeanCentered" << endl;
 #endif
   if (isInSharedAxisBox() && !force) {
     sharedAxisBox()->zoomYMeanCentered(this);
   } else {
-    ZoomCommand *cmd = new ZoomYMeanCenteredCommand(this, force);
+    ZoomCommand *cmd = new ZoomYMeanCenteredCommand(this, dY, force);
     _undoStack->push(cmd);
     cmd->redo();
   }
 }
 
 
+void PlotItem::zoomXMeanCentered(qreal dX, bool force) {
+#if DEBUG_ZOOM
+  qDebug() << "zoomXMeanCentered" << endl;
+#endif
+  if (isInSharedAxisBox() && !force) {
+    sharedAxisBox()->zoomXMeanCentered(this);
+  } else {
+    ZoomCommand *cmd = new ZoomXMeanCenteredCommand(this, dX, force);
+    _undoStack->push(cmd);
+    cmd->redo();
+  }
+}
+
+
 void PlotItem::zoomXMaximum(bool force) {
 #if DEBUG_ZOOM
   qDebug() << "zoomXMaximum" << endl;
@@ -3631,7 +3650,7 @@
   if (applyY) {
     item->yAxis()->setAxisZoomMode(PlotAxis::MeanCentered);
     QRectF compute = item->computedProjectionRect();
-    item->setProjectionRect(QRectF(item->projectionRect().x(), compute.y(), item->projectionRect().width(), compute.height()));
+    item->setProjectionRect(QRectF(item->projectionRect().x(), compute.y(), item->projectionRect().width(), _dY));
   }
 }
 
@@ -3647,6 +3666,30 @@
 }
 
 /*
+ * X axis zoom to Mean Centered, Y axis unchanged.
+ */
+void ZoomXMeanCenteredCommand::applyZoomTo(PlotItem *item, bool applyX, bool applyY) {
+  Q_UNUSED(applyY);
+
+  if (applyX) {
+    item->xAxis()->setAxisZoomMode(PlotAxis::MeanCentered);
+    QRectF compute = item->computedProjectionRect();
+    item->setProjectionRect(QRectF(compute.x(), item->projectionRect().y(), _dX, item->projectionRect().height()));
+  }
+}
+
+
+void ZoomXMeanCenteredCommand::applyZoomTo(ViewItem *item, bool applyX, bool applyY) {
+  Q_UNUSED(applyY);
+  SharedAxisBoxItem *shareBox = qobject_cast<SharedAxisBoxItem*>(item);
+  if (shareBox) {
+    if (applyX) {
+      shareBox->zoomXMeanCentered(0);
+    }
+  }
+}
+
+/*
  * X axis zoom to auto, Y zoom not changed.
  */
 void ZoomXMaximumCommand::applyZoomTo(PlotItem *item, bool applyX, bool applyY) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #996830:996831
@@ -280,7 +280,8 @@
     void zoomLogX(bool force = false, bool autoLog = true, bool enableLog = false);
 
     void zoomMeanCentered(bool force = false);
-    void zoomYMeanCentered(bool force = false);
+    void zoomYMeanCentered(qreal dY, bool force = false);
+    void zoomXMeanCentered(qreal dX, bool force = false);
     void zoomYLocalMaximum(bool force = false);
     void zoomYMaximum(bool force = false);
     void zoomYNoSpike(bool force = false);
@@ -516,7 +517,7 @@
     friend class ZoomGeneralCommand;
     friend class ZoomMaxSpikeInsensitiveCommand;
     friend class ZoomMeanCenteredCommand;
-    //friend class ZoomXMeanCenteredCommand;
+    friend class ZoomXMeanCenteredCommand;
     friend class ZoomYMeanCenteredCommand;
     friend class ZoomXMaximumCommand;
     friend class ZoomYLocalMaximumCommand;
@@ -650,29 +651,32 @@
     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) {}
+    ZoomXMeanCenteredCommand(PlotItem *item, qreal dX, bool forced = false)
+        : ZoomCommand(item, QObject::tr("Zoom X Mean Centered"), forced), _dX(dX)  {}
     virtual ~ZoomXMeanCenteredCommand() {}
 
     virtual void applyZoomTo(PlotItem *item, bool applyX = true, bool applyY = true);
     virtual void applyZoomTo(ViewItem *item, bool applyX = true, bool applyY = true);
+  private:
+    qreal _dX;
 };
 
-*/
 
 class KST_EXPORT ZoomYMeanCenteredCommand : public ZoomCommand
 {
   public:
-    ZoomYMeanCenteredCommand(PlotItem *item, bool forced = false)
-        : ZoomCommand(item, QObject::tr("Zoom Mean Centered"), forced) {}
+    ZoomYMeanCenteredCommand(PlotItem *item, qreal dY, bool forced = false)
+        : ZoomCommand(item, QObject::tr("Zoom Y Mean Centered"), forced), _dY(dY) {}
     virtual ~ZoomYMeanCenteredCommand() {}
 
     virtual void applyZoomTo(PlotItem *item, bool applyX = true, bool applyY = true);
     virtual void applyZoomTo(ViewItem *item, bool applyX = true, bool applyY = true);
+  private:
+    qreal _dY;
 };
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #996830:996831
@@ -642,13 +642,15 @@
       item->zoomXAutoBorder();
     } else if (xZoomMode == PlotAxis::SpikeInsensitive) {
       item->zoomXNoSpike();
-    } else if (xZoomMode == PlotAxis::MeanCentered) {
-
     }
   }
-  if (xZoomMode == PlotAxis::MeanCentered || xZoomMode == PlotAxis::FixedExpression) {
+  if (xZoomMode == PlotAxis::FixedExpression) {
     item->zoomXRange(newProjectionRect);
   }
+  if (xZoomMode == PlotAxis::MeanCentered) {
+      item->zoomXMeanCentered(_rangeTab->xRange());
+  }
+
   if (_rangeTab->yModeDirty()) {
     if (yZoomMode == PlotAxis::Auto) {
       item->zoomYMaximum();
@@ -658,11 +660,11 @@
       item->zoomYNoSpike();
     }
   }
-  if (/*yZoomMode == PlotAxis::MeanCentered || */ yZoomMode == PlotAxis::FixedExpression) {
+  if (yZoomMode == PlotAxis::FixedExpression) {
     item->zoomYRange(newProjectionRect);
   }
   if (yZoomMode == PlotAxis::MeanCentered) {
-      item->zoomYMeanCentered();
+      item->zoomYMeanCentered(_rangeTab->yRange());
   }
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/rangetab.cpp #996830:996831
@@ -54,13 +54,13 @@
 void RangeTab::setupRange() {
   Q_ASSERT(_plotItem);
 
-  _xRange->setText(QString::number(fabs(_plotItem->xMax() - _plotItem->xMin())));
-  _xMin->setText(QString::number(_plotItem->xMin()));
-  _xMax->setText(QString::number(_plotItem->xMax()));
+  _xRange->setText(QString::number(fabs(_plotItem->xMax() - _plotItem->xMin()),'g', 13));
+  _xMin->setText(QString::number(_plotItem->xMin(),'g', 13));
+  _xMax->setText(QString::number(_plotItem->xMax(),'g', 13));
 
-  _yRange->setText(QString::number(fabs(_plotItem->yMax() - _plotItem->yMin())));
-  _yMin->setText(QString::number(_plotItem->yMin()));
-  _yMax->setText(QString::number(_plotItem->yMax()));
+  _yRange->setText(QString::number(fabs(_plotItem->yMax() - _plotItem->yMin()),'g', 13));
+  _yMin->setText(QString::number(_plotItem->yMin(),'g', 13));
+  _yMax->setText(QString::number(_plotItem->yMax(),'g', 13));
 
   switch (_plotItem->xAxis()->axisZoomMode()) {
     case PlotAxis::Auto:
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.cpp #996830:996831
@@ -502,6 +502,15 @@
   applyZoom(computeRect(PlotAxis::Auto, PlotAxis::MeanCentered), originPlotItem, false, true);
 }
 
+void SharedAxisBoxItem::zoomXMeanCentered(PlotItem* originPlotItem) {
+#if DEBUG_ZOOM
+  qDebug() << "zoomXMeanCentered" << endl;
+#endif
+  _xAxisZoomMode = PlotAxis::MeanCentered;
+  originPlotItem->zoomXMeanCentered(true);
+  applyZoom(computeRect(PlotAxis::MeanCentered, PlotAxis::MeanCentered), originPlotItem, true, false);
+}
+
 void SharedAxisBoxItem::zoomXMaximum(PlotItem* originPlotItem) {
 #if DEBUG_ZOOM
   qDebug() << "zoomXMaximum" << endl;
--- branches/work/kst/portto4/kst/src/libkstapp/sharedaxisboxitem.h #996830:996831
@@ -68,6 +68,7 @@
     void zoomMaxSpikeInsensitive(PlotItem* originPlotItem);
     void zoomMeanCentered(PlotItem* originPlotItem);
 
+    void zoomXMeanCentered(PlotItem* originPlotItem);
     void zoomXMaximum(PlotItem* originPlotItem);
     void zoomXNoSpike(PlotItem* originPlotItem);
     void zoomXAutoBorder(PlotItem* originPlotItem);


More information about the Kst mailing list