PDA

View Full Version : Retrieve Curve values



nenukino
23rd January 2008, 21:58
HI all,

I have several QwtPlotCurve objects and a QwtPlotPicker object on my graph, QwtPlotPicker send the x,y value inside the canvas where I click , and I would like to know if there is a way to retrieve the real values of the curve using the values (coordinates x,y ) send by QwtPlotPicker object.

look at the picture attached, when I click inside the canvas I need to display next to each curve the value where the mark intersect the curve.

If someone had done something like this I really appreciate any help.

Uwe
24th January 2008, 08:07
Use QwtPlotCurve::closestPoint() to find the next point. The rest should be school mathematics.

Note that the implementation of QwtPlotCurve::closestPoint iterates over all points and is slow for many points. You might get faster lookups by implementing your own algo, f.e binary search for points with increasing/decreasing x-values or using a quadtree ...

Uwe

Krish
26th February 2008, 14:33
Hello! Nenukino,
Even i am planning to get the co-ordinates of the curve whenever i click on it. As you said in your post thath: -

I have several QwtPlotCurve objects and a QwtPlotPicker object on my graph, QwtPlotPicker send the x,y value inside the canvas where I click.

Can you please let me know how do i get that like do i have to use: -
"QwtText QwtPlotPicker::trackerText(const QPoint & pos)const"
OR
"QPoint QwtPlotPicker::transform(const QwtDoublePoint & pos)const"
And how to give the parameter 'pos' to the 1st option?

I will be obliged if helped with proper syntax & arguments.-----> Thanks in advance.