PDA

View Full Version : Determine the curve under the plot point clicked



corrado1972
3rd May 2011, 12:22
(QWT 6.0.0): the example event_filter shown me how to determine which curve has been clicked, using the distance from the point clicked and the nearest point of the curve.

I want to trigger when a user click onto the whole curve, not only on its points: is it possible?

corrado1972
4th May 2011, 13:06
After my researches into the Qwt code, I understood that a QwtPlotCurve don't keep trace of the points covered by its entire lines: the curve knows only its points/samples. Unfortunately there is no method to knows if a canvas point is intercepting the line of a curve that is connecting one curve point to the next one curve point.

Continuing to working with event_filter, I discovered a property of QwtPlotCanvas, the FocusIndicator: as the guide says, the focusindicator can be set to ItemFocusIndicator, and this is described as: The focus is related to an item (curve, point, ...) on the canvas. It is up to the application to display a focus indication using f.e. highlighting.

Is this a way to intercept a mouse click on a curve ?
I tried this into event_filter, but the event is ever fired by the Canvas, not by one child item like a curve.

Uwe
5th May 2011, 06:53
I recommend to have a look into a book about algorithms. In the end it is about the question: what is the closest distance between a point and a polygon. Then you can iterate over all curves decide what curve has the smallest distance and if this distance is below a tolerance you accept as a match.

When you have decided which algo to use and know the parameters you need I will tell you how to get them.

Uwe

PS: better don't try to find a solution on your own - you are not the first one who needs something like this.