[Kst] kdeextragear-2/kst

George Staikos staikos at kde.org
Sat Sep 27 01:21:11 CEST 2003


CVS commit by staikos: 

This seems to update the mouse properly.
CCMAIL: 64891-done at bugs.kde.org


  M +23 -0     kst/kstview.cpp   1.47
  M +4 -3      tests/datagenerator.pl   1.2


--- kdeextragear-2/kst/kst/kstview.cpp  #1.46:1.47
@@ -364,4 +364,27 @@ void KstView::update() {
   needrecreate = true;
   paintEvent(NULL);
+  int plot = MouseInfo->getPlotNum();
+  if (plot >= 0) {
+    KstPlot* pPlot = KST::plotList.at(plot);
+    QRect plot_rect = pPlot->GetPlotRegion();
+    QPoint pos = mapFromGlobal(QCursor::pos());
+    double xmin, ymin, xmax, ymax, xpos, ypos;
+    pPlot->getLScale(xmin, ymin, xmax, ymax);
+    xpos = (double)(pos.x() - plot_rect.left())/(double)plot_rect.width();
+    xpos = xpos * (xmax - xmin) + xmin;
+    ypos = (double)(pos.y() - plot_rect.top())/(double)plot_rect.height();
+    ypos = ypos * (ymin - ymax) + ymax;
+
+    if (pPlot->isXLog()) {
+      xpos = pow(10.0, xpos);
+    }
+
+    if (pPlot->isYLog()) {
+      ypos = pow(10.0, ypos);
+    }
+
+    QString msg = i18n("(%1, %2)").arg(xpos,0,'G').arg(ypos,0,'G');
+    emit newDataMsg(msg);
+  }
 }
 

--- kdeextragear-2/kst/tests/datagenerator.pl  #1.1:1.2
@@ -9,9 +9,10 @@
 while (true) {
         print OUTPUT "$i ";
-        print OUTPUT sin($i) + rand(0.4) - 0.2;
+        $ii = $i/10;
+        print OUTPUT sin($ii) + rand(0.4) - 0.2;
         print OUTPUT " ";
-        print OUTPUT cos($i) + rand(0.4) - 0.2;
+        print OUTPUT cos($ii) + rand(0.4) - 0.2;
         print OUTPUT " ";
-        print OUTPUT sin($i * $i) * (cos($i) + rand(0.4) - 0.2);
+        print OUTPUT sin($ii * $ii) * (cos($ii) + rand(0.4) - 0.2);
         print OUTPUT " ";
         print OUTPUT "\n";




More information about the Kst mailing list