PDA

View Full Version : Curve name tooltip needs for QwtPlotCurve on Canvas



umituzun84
27th April 2011, 12:26
Hi All;

I need something much special for me. I have lots of curves on my canvas so generally I can't locate target curve on the canvas, so I need tooltip for every curve when I placed my cursor as close as needed.

At first grasp, I found following solution;

-I will get the cursor's coordinate and dispatch this coordinate to each curve.

-These curves will start to calculate closest grade by binary search and line equations of 2 points.

-By kind of these calculations and finding operation I will get "closest rate" for each curve, then I will compare each rate and find most closest one.

-Then I will compare this closest rate with my threshold which can elect out of defined range.

-If threshold operation passes too, I can make decision that my curve is this most closest point's owner curve.

As you can see this bulk of operations for each curve is too complex and can make my system slow down.

So have you any much fast and reasonable way acvieve kind of this goal?

Thanks in advance.
Regards.

Ãœmit Uzun

Uwe
27th April 2011, 14:13
When you have too many points and identifying the closest point gets too slow for iterating over all points you need to introduce some sort of spatial index.

The best implementation depends on the details of your plot, but I once used a quadtree for an application with a plot with curves with symbols and no lines. If you have to identify vectors ( f.e for curve lines ) you might have to use something like a R-Tree.

But it's long ago since I left university - maybe there are other standard algorithms available today, better ask google.

Uwe