Results 1 to 11 of 11

Thread: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

  1. #1
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Hello, I am implementing a curve widget in which the user can drag the curve by mouse move operations. The problem is the returned x dimension is not accurate in plot coordinates, there is no problem in the mapped y coordinate. There is always a shift or gap in the x dimension of the selected point(I guess this gap is about the width of the y-Axis ruler), please see the problem and the gap in my image attachment. Also I attach the code below.
    I am using QwtPlotPicker::getInvTransform as,

    Qt Code:
    1. class myCurveWidget : public QwtPlot
    2. {
    3. /////////
    4. }
    5.  
    6. class myCurvePicker : public QwtPlotPicker
    7. {
    8. //////////
    9. }
    10.  
    11. QPointF myCurveWidget::mapMousePoint(QPoint mousePoint)
    12. {
    13. myCurvePicker picker(this->canvas());
    14.  
    15. QPointF mappedPt = picker.getInvTransform(mousePoint);
    16.  
    17. if(mappedPt.x() < 0)
    18. mappedPt.setX(0);
    19. else if(mappedPt.x() > 255)
    20. mappedPt.setX(255);
    21. if(mappedPt.y() < 0)
    22. mappedPt.setY(0);
    23. else if(mappedPt.y() > 255)
    24. mappedPt.setY(255);
    25.  
    26. return mappedPt;
    27. }
    To copy to clipboard, switch view to plain text mode 

    How can I map to exact plot coordinates?
    Attached Images Attached Images

  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: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Quote Originally Posted by hakiim35 View Post
    I am using QwtPlotPicker::getInvTransform ...
    This method doesn't exist in the Qwt library.

    Uwe

  3. #3
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Strange. I am using the 5.2.1 version and it does exist in that version. So what would you advise me to use?

  4. #4
    Join Date
    May 2011
    Posts
    21
    Thanks
    1
    Thanked 5 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    The last version I think ^^.

  5. #5
    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: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Quote Originally Posted by hakiim35 View Post
    Strange. I am using the 5.2.1 version and it does exist in that version. So what would you advise me to use?
    QwtPlotPicker has a method invTransform - if you see a method getInvTransform you are probably working with a version, that has been patched by someone. Try to find the author of this patch and ask him/her what it is about.

    Uwe

  6. #6
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Ok, I think I must explain where getInvTransform() comes from. As you said QwtPlotPicker has invTransform() method, but it is protected so I can't call it from my other classes, so the method getInvTransform() is a very simple public method calling invTransform() of its basic class 'QwtPlotPicker', so that other classes can use it.
    So, now, do you have any idea about why invTransform() returns x-value including the width of y-axis ruler part?

  7. #7
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    use

    Qt Code:
    1. QPointF mappedPt = picker.getInvTransform(mousePoint) - picker.getInvTransform(0);
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Hello, I tried but it didnt give correct result. I guess, the value you subtracted is the zero point in pixel coordinates, but I want to get the zero point in plot coordinates..

  9. #9
    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: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Don't use a picker here - it's a QObject, that needs event processing - something, that is not happening the way you wrote your code.

    Instead do something like this:

    Qt Code:
    1. QPointF myCurveWidget::mapMousePoint(QPoint mousePoint)
    2. {
    3. const double x = canvasMap( QwtPlot::xBottom ).invTransform( mousePoint.x() );
    4. const double y = canvasMap( QwtPlot::yLeft ).invTransform( mousePoint.y() );
    5.  
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 

    I'm not 100% sure if this already solves your problem, but at least it's better than using a picker and it should be easier to find out what is going on. If the bug is still there you should check p1, p2, s1, s2 of the maps to see if there are pending updates of the scales because of a missing replot.

    Uwe

  10. #10
    Join Date
    Jul 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Hello, it didnt help either..but I will try to investigate it deeper..
    By the way, isnt it possible to retrieve the width of the vertical ruler on the left part of the widget?

  11. #11
    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: QwtPlotPicker::getInvTransform does not map to correct plot coordinates

    Quote Originally Posted by hakiim35 View Post
    Hello, it didnt help either..but I will try to investigate it deeper..
    Again: check p1, p2, s1, s2 !

    Uwe

Similar Threads

  1. Replies: 1
    Last Post: 9th August 2010, 19:44
  2. Replies: 4
    Last Post: 18th March 2010, 10:11
  3. Replies: 0
    Last Post: 20th November 2009, 15:30
  4. QwtPlotPicker questions
    By ttvo in forum Qwt
    Replies: 7
    Last Post: 28th February 2009, 09:44
  5. Replies: 4
    Last Post: 25th October 2007, 12:23

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.