Results 1 to 4 of 4

Thread: QwtPlotItem bounding rect in widget coordinates

  1. #1
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QwtPlotItem bounding rect in widget coordinates

    Is there a way to get the bounding rect of a QwtPlotItem in widget coordinates?

    The reason I'm asking is I want to create a generic way of selecting QwtPlotItems with the mouse (no matter what type they are)

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotItem bounding rect in widget coordinates

    The bounding rectangle can be mapped to widget coordinates using: QwtPlot::canvasMap() and QwtScaleMap::transform().

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    StrikeByte (16th September 2015)

  4. #3
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotItem bounding rect in widget coordinates

    Hello Uwe thanks for pointing me into the right direction

    At the moment I'm still havinging some problems with the bounding rect of a VLine QwtPlotMarker it only returns a rect with a size of 1x1
    I'm using qwt-6.1-multiaxes

    This is the code I'm using to transform the bounding rect
    Qt Code:
    1. QRectF boundingRect = QwtScaleMap::transform(m_plot->canvasMap((*it)->xAxis()),m_plot->canvasMap((*it)->yAxis()),(*it)->boundingRect());
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotItem bounding rect in widget coordinates

    Basically this is a problem of the implementation of QwtPlotMarker::boundingRect(), that always returns the bounding rectangle of a point ( size is ( 0, 0 ), not ( 1, 1 ) ! ). The correct bounding rectangle for a VLine should be ( 0, -1 ), where the -1 indicates, that the autoscaler shouldn't take care of it vertically. You could fix this by overloading QwtPlotMarker::boundingRect().

    Then your code has to check the horizontal and vertical intervals independently. Then in case of your VLine all clicks at a specific x coordinate do match regardless of the y coordinate.

    Uwe

Similar Threads

  1. Custom shape of bounding rect
    By Kamalpreet in forum Newbie
    Replies: 1
    Last Post: 9th October 2014, 15:59
  2. Replies: 0
    Last Post: 3rd February 2012, 04:08
  3. Replies: 0
    Last Post: 1st July 2010, 18:17
  4. hide bounding rect
    By dreamer in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2008, 09:40
  5. Image format without bounding rect
    By dreamer in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2008, 22:25

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.