[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Tue Sep 30 03:17:32 CEST 2003
CVS commit by staikos:
Implement the rest of #64894. There is still room for improvement (right now
it only handles integral x coordinates, it's probably not the most efficient,
etc), but it works.
CCMAIL: 64894-done at bugs.kde.org
M +26 -14 kstview.cpp 1.51
--- kdeextragear-2/kst/kst/kstview.cpp #1.50:1.51
@@ -370,4 +370,5 @@ void KstView::update() {
void KstView::updateMouse() {
int plot = MouseInfo->getPlotNum();
+ QString msg;
KstPlot* pPlot;
if (plot >= 0 && (pPlot = KST::plotList.at(plot))) {
@@ -383,11 +384,4 @@ void KstView::updateMouse() {
}
- QString msg;
- if (_dataMode) {
- ypos = -1;
- // Use curve name FIXME
- QString plotName = pPlot->tagName();
- msg = i18n("%3 (%1, %2)").arg(xpos,0,'G').arg(ypos,0,'G').arg(plotName);
- } else {
ypos = (double)(pos.y() - plot_rect.top())/(double)plot_rect.height();
ypos = ypos * (ymin - ymax) + ymax;
@@ -396,11 +390,29 @@ void KstView::updateMouse() {
ypos = pow(10.0, ypos);
}
- msg = i18n("(%1, %2)").arg(xpos,0,'G').arg(ypos,0,'G');
- }
+ if (_dataMode) {
+ double newypos = ypos;
+ KstBaseCurvePtr curve;
+ double delta = 9e99;
+
+ for (KstBaseCurveList::Iterator i = pPlot->Curves.begin(); i != pPlot->Curves.end(); ++i) {
+ double xpt, ypt;
+ (*i)->getPoint(int(xpos), xpt, ypt);
+ if (fabs(ypos - ypt) < delta) {
+ delta = fabs(ypos - ypt);
+ newypos = ypt;
+ curve = *i;
+ }
+ }
+ if (curve.data()) {
+ msg = i18n("%3 (%1, %2)").arg(int(xpos)).arg(newypos,0,'G').arg(curve->tagName());
emit newDataMsg(msg);
- } else {
- emit newDataMsg(QString::null);
+ return;
+ }
}
+
+ msg = i18n("(%1, %2)").arg(xpos,0,'G').arg(ypos,0,'G');
+ }
+ emit newDataMsg(msg);
}
More information about the Kst
mailing list