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.
Re: Problem with the reimplementation of the zoom function of a QwtPlotZoomer
Quote:
Originally Posted by
Valsylver
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
I subclassed the QwtPlotZoomer to make the same thing when the user zooms.
I recommend to overload the following method instead:
Code:
void QwtSeriesData<QPointF>
::setRectOfInterest( const QRectF & ).
Uwe
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 ?
Re: Problem with the reimplementation of the zoom function of a QwtPlotZoomer
Quote:
Originally Posted by
Valsylver
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.
Quote:
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
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
Re: Problem with the reimplementation of the zoom function of a QwtPlotZoomer
I finally found another way to do that.
Thanks again Uwe