[Kst] [Bug 118726] Axes: expression vs fixed limits and save/restore problem

George Staikos staikos at kde.org
Mon Sep 18 16:36:57 CEST 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=118726         
staikos kde org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From staikos kde org  2006-09-18 16:36 -------
SVN commit 586024 by staikos:

This makes expressions work in the zoom stack as expected, and even to an
extent across the plot dialog.  It's a bit strange to have undo work across
the dialog and in the main view, but after playing with it, I can see why it
feels more intuitive.
BUG: 118726


 M  +30 -14    kst2dplot.cpp  
 M  +2 -2      kstplotdialog_i.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #586023:586024
 @ -979,7 +979,12  @
   bool first;
   int count;
 
-  switch (_xScaleMode) {
+  KstScaleModeType t = _xScaleMode;
+  if (t == EXPRESSION && _xMinParsedValid && _xMaxParsedValid && _xMinParsed->isConst() && _xMaxParsed->isConst()) {
+    t = FIXED;
+  }
+
+  switch (t) {
     case AUTOBORDER:  // set scale so all of all curves fits
     case AUTO:  // set scale so all of all curves fits
       XMin = 0.0;
 @ -1182,7 +1187,12  @
       break;
   }
 
-  switch (_yScaleMode) {
+  t = _yScaleMode;
+  if (t == EXPRESSION && _yMinParsedValid && _yMaxParsedValid && _yMinParsed->isConst() && _yMaxParsed->isConst()) {
+    t = FIXED;
+  }
+
+  switch (t) {
     case AUTOBORDER:  // set scale so all of all curves fits
     case AUTO:  // set scale so all of all curves fits
       YMin = 0.0;
 @ -2897,6 +2907,10  @
   ps->yscalemode = _yScaleMode;
   ps->xlog = _xLog;
   ps->ylog = _yLog;
+  ps->xMinExp = _xMinExp;
+  ps->xMaxExp = _xMaxExp;
+  ps->yMinExp = _yMinExp;
+  ps->yMaxExp = _yMaxExp;
 
   _plotScaleList.append(ps);
 }
 @ -2914,6 +2928,16  @
     _yScaleMode = ps->yscalemode;
     _xLog = ps->xlog;
     _yLog = ps->ylog;
+    _xMinExp = ps->xMinExp;
+    _xMaxExp = ps->xMaxExp;
+    _yMinExp = ps->yMinExp;
+    _yMaxExp = ps->yMaxExp;
+    _xMinParsedValid = reparse(_xMinExp, &_xMinParsed);
+    _xMaxParsedValid = reparse(_xMaxExp, &_xMaxParsed);
+    _yMinParsedValid = reparse(_yMinExp, &_yMinParsed);
+    _yMaxParsedValid = reparse(_yMaxExp, &_yMaxParsed);
+    optimizeXExps();
+    optimizeYExps();
     return true;
   }
   return false;
 @ -6396,11 +6420,8  @
 void Kst2DPlot::optimizeXExps() {
   if (_xMinParsedValid && _xMaxParsedValid && _xMinParsed->isConst() && _xMaxParsed->isConst()) {
     Equation::Context ctx;
-    double min, max;
-
-    setXScaleMode(FIXED);
-    min = _xMinParsed->value(&ctx);
-    max = _xMaxParsed->value(&ctx);
+    double min = _xMinParsed->value(&ctx);
+    double max = _xMaxParsed->value(&ctx);
     if (min > max) {
       double tmp = max;
       max = min;
 @ -6414,7 +6435,6  @
         min -= fabs(min) * 0.01;
       }
     }
-    setXScale(min, max);
   }
 }
 
 @ -6422,11 +6442,8  @
 void Kst2DPlot::optimizeYExps() {
   if (_yMinParsedValid && _yMaxParsedValid && _yMinParsed->isConst() && _yMaxParsed->isConst()) {
     Equation::Context ctx;
-    double min, max;
-
-    setYScaleMode(FIXED);
-    min = _yMinParsed->value(&ctx);
-    max = _yMaxParsed->value(&ctx);
+    double min = _yMinParsed->value(&ctx);
+    double max = _yMaxParsed->value(&ctx);
     if (min > max) {
       double tmp = max;
       max = min;
 @ -6440,7 +6457,6  @
         min -= fabs(min) * 0.01;
       }
     }
-    setYScale(min, max);
   }
 }
 
--- trunk/extragear/graphics/kst/src/libkstapp/kstplotdialog_i.cpp #586023:586024
 @ -832,7 +832,6  @
 
 void KstPlotDialogI::applyRange(Kst2DPlotPtr plot) {
   Kst2DPlotList plots;
-  Kst2DPlotPtr  plotExtra;
 
   if (rangeThisPlot->isChecked()) {
     plots += plot;
 @ -846,7 +845,7  @
   }
 
   for (uint i = 0; i < plots.size(); i++) {
-    plotExtra = plots[i];
+    Kst2DPlotPtr plotExtra = plots[i];
 
     // do X Scale
     if (XAC->isChecked()) {
 @ -898,6 +897,7  @
       KstDebug::self()->log(i18n( "Internal error: No Y scale type checked in %1." ).arg(Select->currentText()), KstDebug::Error);
     }
     plotExtra->setDirty();
+    plotExtra->pushScale();
   }
 }


More information about the Kst mailing list