PDA

View Full Version : Change a QwtPlotZoomer zoom base without rescale if zooming



Troudhyl
12th May 2011, 09:31
Hello,

Is there a way to change the zoom base without rescaling ? Better than this:


class PlotZoomer : public QwtPlotZoomer
{
public:
explicit PlotZoomer(QwtPlotCanvas *canvas);

void setZoomBase( const QRectF &base );
};

PlotZoomer::PlotZoomer(QwtPlotCanvas *canvas) :
QwtPlotZoomer(canvas)
{
}

void PlotZoomer::setZoomBase(const QRectF &base)
{
if ( !plot() )
return;
int currentIndex = zoomRectIndex();
QStack<QRectF>* stack = new QStack<QRectF>();
*stack = zoomStack();
stack->replace(0, base);
setZoomStack(*stack, 0);
zoom(currentIndex);
}

I code an oscilloscope-like which receive data continuously. And I want to add a QwtPlotMagnifier and QwtPlotZoomer. The x scale move to follow data, but if we zoom, the screen should stay "freezed" even if we would be up-to-date when unzooming.

Sorry for my English :rolleyes:

Edit: My solution works well in fact ^^

Uwe
13th May 2011, 18:12
Don't use new for your stack - your code produces memory leaks.

uwe