I have QwtPlot and QwtPlotMagnifier. I can zoom only x axes. When I zoom in I can see only a portion of my curve. How can I obtain which portion of curve I see in the plot canvas? That is, xMin and xMax of the drowed portion?
thanks
I have QwtPlot and QwtPlotMagnifier. I can zoom only x axes. When I zoom in I can see only a portion of my curve. How can I obtain which portion of curve I see in the plot canvas? That is, xMin and xMax of the drowed portion?
thanks
IIRC you can use invTransform(int axisID, int pos) on the QwtPlot to return the double value of the x-axis for start and finish.
The plot goes from 1 to 1000 (int), so 1 will be xMin and 1000 will be xMax.
I'm sure Uwe will be along to confirm shortly!
Cheers
I tried with 1000 as xMax, but it seems that is incorrect...
I tried using QwtScaleMap::transform(), applied with different windows size, and it seems thax xMax and xMin are pixel positions.
So I don't think I can successfully use invTransform, because I don't know xMin and xMax.
thanks
Last edited by mastupristi; 9th July 2009 at 12:29. Reason: updated contents
The way I currently do it (although I'm a bit rusty) is to link the signal zoomed(const QwtDoubleRect &) to a function and then you can take the left() and right() of the resultant QwtDoubleRect to give the xMin and xMax.
Not sure if this signal exists for the QwtMagnifier.
a) All navigation operations (zooming, panning) ... finally end in a call of QwtPlot::setAxisScale() changing the scales of the scale widgets. Whenever a scale widget gets a new scale it emits QwtScaleWidget::scaleDivChanged(). With plot->axisScaleDiv() you can get the current scale divisions with all ticks and the left/right borders.
b) With plot->canvas()->contentsRect() you find the area of the plot canvas in widget coordinates. With plot->canvasMap()->invTransform() you can translate it into plot coordinates.
Uwe
Bookmarks