Results 1 to 3 of 3

Thread: Determine the curve under the plot point clicked

  1. #1
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default 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?

  2. #2
    Join Date
    Jul 2010
    Posts
    37
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.
    Last edited by corrado1972; 4th May 2011 at 13:21. Reason: semantic fixing

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,278
    Thanked 872 Times in 820 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

Similar Threads

  1. Replies: 2
    Last Post: 28th April 2011, 08:42
  2. Replies: 2
    Last Post: 3rd December 2010, 05:52
  3. Replies: 4
    Last Post: 29th April 2010, 06:11
  4. Replies: 1
    Last Post: 9th December 2009, 17:14
  5. get the point of a fitted curve
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 2nd January 2009, 04:03

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.