Determine the curve under the plot point clicked
(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?
Re: Determine the curve under the plot point clicked
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.
Re: Determine the curve under the plot point clicked
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.