[Kst] kdeextragear-2/kst/kst

Andrew Walker arwalker at sumusltd.com
Tue Oct 12 20:35:24 CEST 2004


CVS commit by arwalker: 

Display the mouse position and data point value in the interpreted x-axis value when appropriate.


  M +43 -9     kst2dplot.cpp   1.280


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.279:1.280
@@ -2780,10 +2780,18 @@ void Kst2DPlot::updateMousePos(QPoint po
   _copy_x = xpos;
   _copy_y = ypos;
+
+  if (_isXAxisInterpreted) {
+    QString label;
+    uint length;
+    
+    genAxisTickLabelFullPrecision(label, length, xpos, isXLog(), true);
+    KstApp::inst()->slotUpdateDataMsg(i18n("(%1, %2)").arg(label).arg(ypos,0,'G',iYPrecision));
+  } else {
   KstApp::inst()->slotUpdateDataMsg(i18n("(%1, %2)").arg(xpos,0,'G',iXPrecision).arg(ypos,0,'G',iYPrecision));
+  }
 }
 
 
 void Kst2DPlot::highlightNearestDataPoint(bool bRepaint, QWidget *view, const QPoint& pos) {
-  // find mouse location in plot units
   if (!_highlighting) {
     _highlighting = true;
@@ -2798,6 +2806,8 @@ void Kst2DPlot::highlightNearestDataPoin
     getLScale(xmin, ymin, xmax, ymax);
 
-    xpos = (double)(pos.x() - pr.left())/(double)pr.width() *
-           (xmax - xmin) + xmin;
+    //
+    // find mouse location in plot units
+    //
+    xpos = (double)(pos.x() - pr.left())/(double)pr.width() * (xmax - xmin) + xmin;
     if (isXLog()) {
       xpos = pow(10.0, xpos);
@@ -2807,6 +2817,5 @@ void Kst2DPlot::highlightNearestDataPoin
     // convert 1 pixel to plot units.
     //
-    dx_per_pix = (double)(pos.x()+2 - pr.left()) / (double)pr.width() *
-                 (xmax - xmin) + xmin;
+    dx_per_pix = (double)(pos.x()+2 - pr.left()) / (double)pr.width() * (xmax - xmin) + xmin;
     if (isXLog()) {
       dx_per_pix = pow(10.0, dx_per_pix);
@@ -2846,5 +2855,13 @@ void Kst2DPlot::highlightNearestDataPoin
         drawDotAt(p, newxpos, newypos, curve);
       }
+      if (_isXAxisInterpreted) {
+        QString label;
+        uint length;
+
+        genAxisTickLabelFullPrecision(label, length, newxpos, isXLog(), true);
+        msg = i18n("%3 (%1, %2)").arg(label).arg(newypos,0,'G').arg(curve->tagName());
+      } else {
       msg = i18n("%3 (%1, %2)").arg(newxpos,0,'G').arg(newypos,0,'G').arg(curve->tagName());
+      }
     } else {
       _copy_x = KST::NOPOINT;
@@ -2869,5 +2886,20 @@ void Kst2DPlot::highlightNearestDataPoin
       if (found) {
         if (!msg.isEmpty()) {
+          if (_isXAxisInterpreted) {
+            QString label;
+            uint length;
+
+            genAxisTickLabelFullPrecision(label, length, xpos, isXLog(), true);
+            msg = QString("%5, %4 (%1, %2, %3)").arg(label).arg(ypos,0,'G').arg(Z,0,'G').arg(_images[i+1]->tagName()).arg(msg);
+          } else {
           msg = QString("%5, %4 (%1, %2, %3)").arg(xpos,0,'G').arg(ypos,0,'G').arg(Z,0,'G').arg(_images[i+1]->tagName()).arg(msg);
+          }
+        } else {
+          if (_isXAxisInterpreted) {
+            QString label;
+            uint length;
+
+            genAxisTickLabelFullPrecision(label, length, xpos, isXLog(), true);
+            msg = QString("%4 (%1, %2, %3)").arg(label).arg(ypos,0,'G').arg(Z,0,'G').arg(_images[i+1]->tagName());
         } else {
           msg = QString("%4 (%1, %2, %3)").arg(xpos,0,'G').arg(ypos,0,'G').arg(Z,0,'G').arg(_images[i+1]->tagName());
@@ -2875,4 +2907,6 @@ void Kst2DPlot::highlightNearestDataPoin
       }
     }
+    }
+
     KstApp::inst()->slotUpdateDataMsg(msg);
     _highlighting = false;





More information about the Kst mailing list