Version: 0.94 (using KDE KDE 3.1) Installed from: RedHat RPMs OS: Linux When DataMode is activated, the lower right mouse data box changes to show data for the nearest curve. However, although the x-data changes, the y-data stays constant, no matter where on the plot you move the mouse. How to reproduce: Plot a curve in kst (make sure it changes some in y over the visible range of the plot). Activate DataMode. Move mouse around. Expected Behavior: Lower right coordinates show coordinate pair cooresponding to nearest position of curve to mouse.
I can't reproduce this bug when --enable-debug is passed to ./configure at compile time, only in other binaries.
Subject: Re: [Kst] New: DataMode doesn't show correct y-axis data On Wednesday 12 November 2003 13:11, Matthew Truch wrote: > When DataMode is activated, the lower right mouse data box changes to show > data for the nearest curve. However, although the x-data changes, the > y-data stays constant, no matter where on the plot you move the mouse. > > How to reproduce: Plot a curve in kst (make sure it changes some in y over > the visible range of the plot). Activate DataMode. Move mouse around. > > Expected Behavior: Lower right coordinates show coordinate pair > cooresponding to nearest position of curve to mouse. I can't reproduce this.
Ah I see what's wrong
Subject: kdeextragear-2/kst/kst CVS commit by staikos: Interpolate y axis manually in data mode CCMAIL: 68040-done@bugs.kde.org M +9 -1 kstview.cpp 1.57 --- kdeextragear-2/kst/kst/kstview.cpp #1.56:1.57 @@ -405,5 +405,13 @@ void KstView::updateMouse() { for (KstBaseCurveList::Iterator i = pPlot->Curves.begin(); i != pPlot->Curves.end(); ++i) { double xpt = 0.0, ypt = 0.0; - (*i)->getPoint((*i)->sampleCount() * xpos / ((*i)->maxX() - (*i)->minX()), xpt, ypt); + double pt = (*i)->sampleCount() * xpos / ((*i)->maxX() - (*i)->minX()); + (*i)->getPoint(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(pt + 1, xpt2, ypt2); + ypt += (pt - xpt) * (ypt2 - ypt) / (xpt2 - xpt); + if (fabs(ypos - ypt) < delta) { delta = fabs(ypos - ypt);
I think that data mode should snap to the nearest actual data point, and not interpolate... Mat?
Quoth CBN: "I think that data mode should snap to the nearest actual data point, and not interpolate... Mat?" I agree. We want to see actual data in datamode.
Ok, we pretty much revert the last changes applied here. :-)
Hm this makes for interesting behaviour with multiple curves on a plot. Anyhow, I have this mostly implemented. I will also add the point indicator as discussed.
Subject: kdeextragear-2/kst/kst CVS commit by staikos: data mode reverted to old behaviour with minor fixes CCMAIL: 68040-done@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;