PDA

View Full Version : Qwt Zooming Problem....urgent



Raghaw
2nd September 2009, 15:12
Hi all ,
Iam zooming the plot on button click and doing the same to zoom out. The Problem when i load the graph an press the Zoom In Button the scale resizes and conseqeuently the garphs after zooming appears very small.also for panning purpose i have another button Here is the code for doing the Zoom IN zoom Out and panning.

void plotWidget::Zoom_In() {
QwtPlot::Axis axIDyLat = (QwtPlot::Axis) 0;
QwtPlot::Axis axIDxLong = (QwtPlot::Axis) 2;

ZoomRectangle->setWidth(RectWidth/1.1);
ZoomRectangle->setHeight(RectHgt/1.1);

this->myPlot->setAxisAutoScale(axIDyLat);
this->myPlot->setAxisAutoScale(axIDxLong);

zoomer->zoom(*ZoomRectangle);


}

void plotWidget::Zoom_Out() {
if(zoomer != NULL) {
if(!this->tmpStack.isEmpty())
tmpStack.pop();

zoomer->zoom(-1);
}
}

void plotWidget::PanorZoom() {
QPixmap PanImage(":/DataViewer_Icons/pan_over.gif");
QPixmap ZoomImage(":/DataViewer_Icons/zoom.png");
const QColor c(Qt::darkBlue);

QIcon PanIcon;
QIcon ZoomIcon;

PanIcon.addPixmap(PanImage);
ZoomIcon.addPixmap(ZoomImage);

if((PanOrZoom % 2) == 0) {
this->pushButton_PanorZoom->setIcon(ZoomIcon);
this->groupBox_ZoomInOut->setEnabled(true);
if(zoomer == NULL) {
zoomer = new QwtPlotZoomer(this->myPlot->canvas());
ZoomRectangle = new QwtDoubleRect(this->zoomer->zoomRect());
}
zoomer->setRubberBandPen(c);
zoomer->setTrackerPen(c);

RectWidth = this->zoomer->zoomRect().width();
RectHgt = this->zoomer->zoomRect().height();

ZoomRectangle->setWidth(RectWidth/0.9);
ZoomRectangle->setHeight(RectHgt/0.9 );

zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::LeftButton, Qt::ControlModifier);
//zoomer->zoom(*ZoomRectangle);


if(panner != NULL)
delete panner;
} else {
this->pushButton_PanorZoom->setIcon(PanIcon);
this->groupBox_ZoomInOut->setEnabled(false);

panner = new QwtPlotPanner(this->myPlot->canvas());
panner->setAxisEnabled(QwtPlot::yRight, false);
panner->setMouseButton(Qt::MidButton);

this->tmpStack = zoomer->zoomStack();

delete ZoomRectangle;
delete zoomer;
zoomer = NULL;
ZoomRectangle = NULL;
}
PanOrZoom++;
}

Plesae Tell What iam doing Wrong?