[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Tue Dec 23 06:17:44 CET 2003


CVS commit by staikos: 

data mode reverted to old behaviour with minor fixes

CCMAIL: 68040-done at bugs.kde.org


  M +10 -11    kstview.cpp   1.60


--- kdeextragear-2/kst/kst/kstview.cpp  #1.59:1.60
@@ -371,5 +371,5 @@ void KstView::updateMouse() {
   int plot = MouseInfo->getPlotNum();
   QString msg;
-  KstPlot* pPlot;
+  KstPlot *pPlot;
 
   if (plot >= 0 && (pPlot = KST::plotList.at(plot))) {
@@ -400,4 +400,5 @@ void KstView::updateMouse() {
     if (_dataMode) {
       double newypos = ypos;
+      double newxpos = xpos;
       KstBaseCurvePtr curve;
       double delta = 9e99;
@@ -405,15 +406,13 @@ void KstView::updateMouse() {
       for (KstBaseCurveList::Iterator i = pPlot->Curves.begin(); i != pPlot->Curves.end(); ++i) {
         double xpt = 0.0, ypt = 0.0;
-        double pt = (*i)->sampleCount() * xpos / ((*i)->maxX() - (*i)->minX());
-        (*i)->getPoint((int)pt, xpt, ypt);
-
-        // We have to get the previous point and interpolate y here, otherwise
-        // datamode y coordinates don't look right.
-        double xpt2 = 0.0, ypt2 = 0.0;
-        (*i)->getPoint((int)pt + 1, xpt2, ypt2);
-        ypt += (pt - xpt) * (ypt2 - ypt) / (xpt2 - xpt);
-
+        int pt = int((*i)->sampleCount() * xpos / ((*i)->maxX() - (*i)->minX()));
+        (*i)->getPoint(pt, xpt, ypt);
         if (fabs(ypos - ypt) < delta) {
           delta = fabs(ypos - ypt);
+          // Notice: This is not exactly the inverse of pt(xpos) since there
+          //         is float->int->float conversion.  This is by design and
+          //         varies for each i.  This is how we get the proper x
+          //         position for the corresponding "newypos".
+          newxpos = double(pt) * ((*i)->maxX() - (*i)->minX()) / (*i)->sampleCount();
           newypos = ypt;
           curve = *i;
@@ -421,5 +420,5 @@ void KstView::updateMouse() {
       }
       if (curve.data()) {
-        msg = i18n("%3 (%1, %2)").arg(xpos).arg(newypos,0,'G').arg(curve->tagName());
+        msg = i18n("%3 (%1, %2)").arg(newxpos).arg(newypos,0,'G').arg(curve->tagName());
         emit newDataMsg(msg);
         return;





More information about the Kst mailing list