Version: 1.2.0_devel (using KDE KDE 3.4.0) Installed from: Fedora RPMs OS: Linux Sometimes, especially when dealing with large numbers, there is not enough precision shown in the statusbar when in data mode to tell that you have moved to a new data point. Datamode seems to only display 6 significant figures, which is not always enough. Expected behavior: kst will display enough significant figures to show movement between data points, based on (in part) the current zoom level and the gradations and size of the data.
SVN commit 462040 by staikos: - remove some apparently dead code - increase data mode precision. Rounding really isn't right. I tried to make a fast heuristic for determining the precision automatically but I think it's too much work and not worth the effort. BUG: 111044 M +23 -50 kst2dplot.cpp --- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #462039:462040 @@ -3730,22 +3730,36 @@ } +template<class T> +inline T kstClamp(const T& x, const T& low, const T& high) { + if (x < low) return low; + else if (high < x) return high; + else return x; +} + + void Kst2DPlot::highlightNearestDataPoint(bool bRepaint, QWidget *view, const QPoint& pos) { QString msg; + int precision = 15; - if (Curves.count() > 0) { + if (!Curves.isEmpty()) { QString name; double newxpos, newypos; double xmin, ymin; double xmax, ymax; - uint length; - if (getNearestDataPoint(pos, newxpos, newypos, name, xmin, ymin, xmax, ymax)) { + if (getNearestDataPoint(pos, newxpos, newypos, name, xmin, xmax, ymin, ymax)) { QString xlabel; QString ylabel; QString msgXOffset; QString msgYOffset; +#if 0 + // Determine if we need to expand precision + precision = kstClamp(int(ceil(log10(1.0 / (xmax - xmin)))) + 2, precision, 15); + precision = kstClamp(int(ceil(log10(1.0 / (ymax - ymin)))) + 2, precision, 15); +#endif + if (_copy_x != newxpos || _copy_y != newypos) { QPainter p(view); @@ -3759,6 +3773,7 @@ } if (_isXAxisInterpreted) { + uint length; genAxisTickLabelFullPrecision(_xAxisInterpretation, _xAxisDisplay, _xAxisTimezoneLocal, _xAxisTimezoneHrs, xlabel, length, newxpos, isXLog(), true); @@ -3772,13 +3787,14 @@ } } } else { - xlabel = QString::number(newxpos,'G'); + xlabel = QString::number(newxpos, 'G', precision); if (_cursorOffset) { - msgXOffset = QString::number(newxpos-_cursor_x,'G'); + msgXOffset = QString::number(newxpos - _cursor_x, 'G', precision); } } if (_isYAxisInterpreted) { + uint length; genAxisTickLabelFullPrecision(_yAxisInterpretation, _yAxisDisplay, _yAxisTimezoneLocal, _yAxisTimezoneHrs, ylabel, length, newypos, isYLog(), true); @@ -3792,9 +3808,9 @@ } } } else { - ylabel = QString::number(newypos,'G'); + ylabel = QString::number(newypos, 'G', precision); if (_cursorOffset) { - msgYOffset = QString::number(newypos-_cursor_y,'G'); + msgYOffset = QString::number(newypos - _cursor_y, 'G', precision); } } @@ -3804,49 +3820,6 @@ msg = i18n("Curve name, (x, y)", "%3 (%1, %2)").arg(xlabel).arg(ylabel).arg(name); } } - -// // display the z value of the topmost image underneath cursor, if available... -// if (_images.count() > 0) { -// double zValue; -// double xpos = 0.0; -// double ypos = 0.0; -// bool found = false; -// int i = _images.count() - 1; -// -// while (i >= 0 && !found) { -// if (_images[i]->getNearestZ(xpos, ypos, zValue)) { -// found = true; -// } -// i--; -// } -// -// if (found) { -// QString xlabel, ylabel; -// uint length; -// -// if (_isXAxisInterpreted) { -// genAxisTickLabelFullPrecision(_xAxisInterpretation, _xAxisDisplay, -// _xAxisTimezoneLocal, _xAxisTimezoneHrs, -// xlabel, length, xpos, isXLog(), true); -// } else { -// xlabel = QString::number(xpos,'G'); -// } -// -// if (_isYAxisInterpreted) { -// genAxisTickLabelFullPrecision(_yAxisInterpretation, _yAxisDisplay, -// _yAxisTimezoneLocal, _yAxisTimezoneHrs, -// ylabel, length, ypos, isYLog(), true); -// } else { -// ylabel = QString::number(ypos,'G'); -// } -// -// if (!msg.isEmpty()) { -// msg = i18n("Label, Image name (x, y, z)", "%5, %4 (%1, %2, %3)" ).arg(xlabel).arg(ylabel).arg(zValue,0,'G').arg(_images[i+1]->tagName()).arg(msg); -// } else { -// msg = i18n("Image name (x, y, z)", "%4 (%1, %2, %3)" ).arg(xlabel).arg(ylabel).arg(zValue,0,'G').arg(_images[i+1]->tagName()); -// } -// } -// } } KstApp::inst()->slotUpdateDataMsg(msg);