[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Mon Nov 21 17:04:56 CET 2005


SVN commit 482057 by staikos:

- add the missing substituteScalars flag support in the renderer
- activate scalar substitution flag in the labels
- disable it where needed in the plot object

  -> makes tick offsets work again


 M  +3 -0      kst2dplot.cpp  
 M  +2 -0      kstplotlabel.cpp  
 M  +2 -0      kstviewlabel.cpp  
 M  +7 -1      labelrenderer.cpp  
 M  +10 -0     labelrenderer.h  


--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #482056:482057
@@ -515,6 +515,9 @@
   _fullTickLabel->setInterpreted(false); // much faster
   _xTickLabel->setInterpreted(false); // much faster
   _yTickLabel->setInterpreted(false); // much faster
+  _fullTickLabel->setDoScalarReplacement(false); // much faster
+  _xTickLabel->setDoScalarReplacement(false); // much faster
+  _yTickLabel->setDoScalarReplacement(false); // much faster
   _zoomPaused = false;
   setDirty(true);
   _oldSize.setWidth(0);
--- trunk/extragear/graphics/kst/kst/kstplotlabel.cpp #482056:482057
@@ -133,6 +133,7 @@
 
 void KstPlotLabel::drawToPainter(Label::Parsed *lp, QPainter& p) {
   RenderContext rc(_fontName, _absFontSize, &p);
+  rc.setSubstituteScalars(_replace);
 
   int tx = 0, ty = 0; // translation
   rc.x = -_textWidth / 2;
@@ -149,6 +150,7 @@
 
 void KstPlotLabel::computeTextSize() {
   RenderContext rc(_fontName, _absFontSize, 0L);
+  rc.setSubstituteScalars(_replace);
   renderLabel(rc, _parsed->chunk);
   _textWidth = rc.x;
   _ascent = rc.ascent;
--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #482056:482057
@@ -234,6 +234,7 @@
   }
 
   RenderContext rc(_fontName, _absFontSize, &p);
+  rc.setSubstituteScalars(_replace);
   rc.precision = _dataPrecision;
   double rotationRadians = M_PI * (int(_rotation) % 360) / 180;
   double absin = fabs(sin(rotationRadians));
@@ -298,6 +299,7 @@
 
 void KstViewLabel::computeTextSize(Label::Parsed *lp) {
   RenderContext rc(_fontName, _absFontSize, 0L);
+  rc.setSubstituteScalars(_replace);
   rc.precision = _dataPrecision;
 #ifdef BENCHMARK
   QTime t;
--- trunk/extragear/graphics/kst/kst/labelrenderer.cpp #482056:482057
@@ -63,7 +63,13 @@
       continue;
     }
 
-    if (fi->scalar) { // Do scalar/string substitution
+    if (!rc.substitute && (fi->scalar || fi->vector)) {
+      QString txt = QString("[") + fi->text + "]";
+      if (rc.p) {
+        rc.p->drawText(rc.x, rc.y, txt);
+      }
+      rc.x += rc.fontWidth(txt);
+    } else if (fi->scalar) { // Do scalar/string substitution
       QString txt;
       if (!fi->text.isEmpty() && fi->text[0] == '=') {
         // Parse and evaluate as an equation
--- trunk/extragear/graphics/kst/kst/labelrenderer.h #482056:482057
@@ -31,6 +31,7 @@
     x = y = xMax = xStart = 0;
     ascent = descent = 0;
     precision = 8;
+    substitute = true;
     setFont(QFont(fontName, fontSize));
   }
 
@@ -82,6 +83,14 @@
     }
   }
 
+  inline bool substituteScalars() const {
+    return substitute;
+  }
+
+  inline void setSubstituteScalars(bool on) {
+    substitute = on;
+  }
+
   int x, y; // Coordinates we're rendering at
   int xMax, xStart;
   int ascent, descent;
@@ -89,6 +98,7 @@
   int size;
   QPainter *p;
   int precision;
+  bool substitute;
   
   private:
     QFont _font;


More information about the Kst mailing list