PDA

View Full Version : QwtPlot example using a fixed aspect ratio zoomer?



nige
11th April 2011, 20:24
Would anyone have an example of a QwtPlot that uses both a QwtPlotZoomer to give rubber band zooming and a QwtPlotRescaler to maintain a fixed aspect ratio?

Used independently, Rescaler and Zoomer work fine. I would like to combine them so that the axes maintain a fixed aspect ratio within the zoomer rubber band rectangle, but I can't seem to get it right...

nige
19th April 2011, 22:55
No replies to my question, so I did it myself by sub-classing QwtPlot and implementing a void Plot::rescale(QRectF &); function that adjusts the scales to keep a fixed aspect ratio.

That rescale function is then called from void Plot::resizeEvent(QResizeEvent *e);
and also from void MyPlotZoomer::zoom( const QwtDoubleRect & rect );

The code is attached.

Maybe there is a better way using QwtPlotRescaler ... but I couldn't do it

nige
20th April 2011, 12:47
that zip file seems to have been silently emptied (perhaps by our firewall?). Although its showing 2.2kb ? Anyway, here are the three files attached separately.