Results 1 to 6 of 6

Thread: Problem with the reimplementation of the zoom function of a QwtPlotZoomer

  1. #1
    Join Date
    Jul 2012
    Location
    Paris, France
    Posts
    8
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem with the reimplementation of the zoom function of a QwtPlotZoomer

    Hi,

    I explain my problem :

    I have a large set of data to display on a qwtplot, so I make a first selection in my data and attach in the plot a QwtPlotCurve which has the same size as the pixels available in the canvas. I subclassed the QwtPlotZoomer to make the same thing when the user zooms. But I also want the right click on a plot to make the plot back to its last state, so when the user zoom I keep the rect in a list, and when the user right clicks (zoom function of the QwtPlotZoomer with a parameter of -1), I find the rectangle of the last state of the QwtPlot in my list and call the function same function zoom with this rectangle. The probleme is the following :

    The zoom works well, but when I want to zoom back, the scales on the plot first disappear (It seems like axis scales or [0, 0] and [0, 0]), and then I have the return to the last state I wanted. And when I zoom a lot of time and want to zoom back, when I am back to the first state (and so can't zoom back anymore), I have the same problem, (axis scales are [0, 0] in both directions), and it stays like it.

    I tried to use setZoomBase(), but didn't succeed.

    Do you know how to fix it ?

    Is there another function called after the zoom(-1) function ?

    Thank you for you help.

  2. #2
    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: Problem with the reimplementation of the zoom function of a QwtPlotZoomer

    Quote Originally Posted by Valsylver View Post
    I have a large set of data to display on a qwtplot, so I make a first selection in my data and attach in the plot a QwtPlotCurve which has the same size as the pixels available in the canvas.
    Maybe its is good enough to enable polygon clipping ( QwtPlotCurve::ClipPolygons ) - but of course when you know, that your samples are x-ordered you can find a faster implementation.

    Quote Originally Posted by Valsylver View Post
    I subclassed the QwtPlotZoomer to make the same thing when the user zooms.
    I recommend to overload the following method instead:

    Qt Code:
    1. void QwtSeriesData<QPointF>::setRectOfInterest( const QRectF & ).
    To copy to clipboard, switch view to plain text mode 
    Uwe

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

    Valsylver (16th July 2012)

  4. #3
    Join Date
    Jul 2012
    Location
    Paris, France
    Posts
    8
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with the reimplementation of the zoom function of a QwtPlotZoomer

    Thanks Uwe for your answer.

    I don't understand very well how the setRectOfInterest(QRectF) method works.
    Am I supposed to subclass the QwtSeriesData class and to reimplement the setRectOfInterest method to set the data of my QwtPlotCurve ? In this case, is this setRectOfInterest function called every time the user zooms on the plot ?

  5. #4
    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: Problem with the reimplementation of the zoom function of a QwtPlotZoomer

    Quote Originally Posted by Valsylver View Post
    Am I supposed to subclass the QwtSeriesData class and to reimplement the setRectOfInterest method to set the data of my QwtPlotCurve ?
    Guess you want to derive from one of the available subclasses of QwtSeriesData ( depending on which you are using today ) - and yes, then overload setRectOfInterest.

    In this case, is this setRectOfInterest function called every time the user zooms on the plot ?
    Better - it is called every time the scales are modified, where zooming is only one of the many possible reasons. Note that you could also overload QwtPlotCurve::updateScaleDiv(), if this is easier for your implementation.

    I don't know how your samples are organized, but maybe all you need to do is to adjust a start and an end index in your data object having an effect on what points are returned from the data object. It's worth to spend some time on the idea of the QwtSeriesData class !

    HTH,
    Uwe

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

    Valsylver (16th July 2012)

  7. #5
    Join Date
    Jul 2012
    Location
    Paris, France
    Posts
    8
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with the reimplementation of the zoom function of a QwtPlotZoomer

    Thanks Uwe, it worked very well.

    I have another question.

    On my plot, I put 2 cursors (instance of QwtPlotMarker), and make them movable by overloading the MouseMoveEvent of the plot. In the label of these cursors, I write the x and y position. When the data size of my Curve is higher than the pixels available on the canvas, it's not a problem to find the y position. But, when the user zooms in such a way that there are less points than the number of pixels of the canvas, I'd like the cursors to be able to move between points and make a linear regression to find the y position in this case.

    So, Is there a means of knowing where the points are drawn on the canvas (a kind of map of pixels) ?

    Thanks
    Last edited by Valsylver; 17th July 2012 at 12:59.

  8. #6
    Join Date
    Jul 2012
    Location
    Paris, France
    Posts
    8
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with the reimplementation of the zoom function of a QwtPlotZoomer

    I finally found another way to do that.

    Thanks again Uwe

Similar Threads

  1. Replies: 3
    Last Post: 10th October 2011, 16:55
  2. Replies: 3
    Last Post: 18th May 2011, 16:56
  3. Replies: 1
    Last Post: 13th May 2011, 18:12
  4. Replies: 1
    Last Post: 30th July 2010, 07:50
  5. Problem with QwtPlotZoomer
    By seguprasad in forum Qt Programming
    Replies: 1
    Last Post: 21st November 2007, 08:31

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.