[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Wed Jun 9 22:59:04 CEST 2004


CVS commit by staikos: 

display more status messages


  M +27 -7     kst2dplot.cpp   1.75


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.74:1.75
@@ -1913,4 +1913,5 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
 
   KstMouseModeType newType = _mouse.mode;
+  QRect pr = GetPlotRegion();
   if (e->state() & Qt::LeftButton && _mouse.zooming()) {
     if (e->state() & Qt::ShiftButton) {
@@ -1922,5 +1923,5 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
       assert(newType != INACTIVE && newType != LABEL_TOOL);
     }
-  } else if (KstApp::inst()->dataMode() && GetPlotRegion().contains(e->pos())) {
+  } else if (KstApp::inst()->dataMode() && pr.contains(e->pos())) {
     double near_x, near_y;
     double newxpos = 0, newypos = 0;
@@ -1929,5 +1930,4 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
     KstBaseCurvePtr curve;
     QPoint pos = e->pos();
-    QRect plot_rect = GetPlotRegion();
 
     double xmin, ymin, xmax, ymax, xpos, ypos, dx_per_pix;
@@ -1935,5 +1935,5 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
 
     // find mouse location in plot units
-    xpos = (double)(pos.x() - plot_rect.left())/(double)plot_rect.width() *
+    xpos = (double)(pos.x() - pr.left())/(double)pr.width() *
            (xmax - xmin) + xmin;
     if (isXLog()) {
@@ -1942,6 +1942,5 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
 
     // convert 1 pixel to plot units.
-    dx_per_pix = (double)(pos.x()+2 - plot_rect.left())/
-                 (double)plot_rect.width() *
+    dx_per_pix = (double)(pos.x()+2 - pr.left()) / (double)pr.width() *
                  (xmax - xmin) + xmin;
     if (isXLog()) {
@@ -1950,5 +1949,5 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
     dx_per_pix -= xpos;
 
-    ypos = (double)(pos.y() - plot_rect.top())/(double)plot_rect.height();
+    ypos = (double)(pos.y() - pr.top())/(double)pr.height();
     ypos = ypos * (ymin - ymax) + ymax;
 
@@ -1986,7 +1985,28 @@ void Kst2DPlot::mouseMoveEvent(QWidget *
       KstApp::inst()->slotUpdateDataMsg(QString::null);
     }
+  } else if (pr.contains(e->pos())) {
+    QPoint pos = e->pos();
+
+    double xmin, ymin, xmax, ymax, xpos, ypos;
+    getLScale(xmin, ymin, xmax, ymax);
+
+    // 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);
+    }
+
+    ypos = (double)(pos.y() - pr.top())/(double)pr.height();
+    ypos = ypos * (ymin - ymax) + ymax;
+
+    if (isYLog()) {
+      ypos = pow(10.0, ypos);
+    }
+    KstApp::inst()->slotUpdateDataMsg(i18n("(%1, %2)").arg(xpos,0,'G').arg(ypos,0,'G'));
+  } else {
+    KstApp::inst()->slotUpdateDataMsg(QString::null);
   }
 
-  QRect pr = GetPlotRegion();
   if (_mouse.mode == XY_ZOOMBOX) {
     if (e->x() > pr.right()) {





More information about the Kst mailing list