PDA

View Full Version : when i clicked on zoom button the YScale is changed to defult 1000



Veeru
28th February 2008, 07:49
Hello All ,

I implimented one Qwtplot application , i would like to zoom the curve which is
drawn according to my values , the problem is when i click on zoom button
it is adjusted to 1000 automatically , qwt version is 5.0.1


what is the Problem for that , pls help me .

Regards
Veeru

Uwe
28th February 2008, 15:45
If you initialize the zoomer before you initialize the scales the zoomer will be initialized by the default scales ( 0 - 1000.0 ).

You didn't write how you have organized your code, but I guess all you need to do is to reinitialize the zoomer ( QwtPlotZoomer::setZoomBase() ) after you have changed your scales.

Uwe

Veeru
29th February 2008, 05:02
Thanks for you

Veeru
29th February 2008, 10:26
If you initialize the zoomer before you initialize the scales the zoomer will be initialized by the default scales ( 0 - 1000.0 ).

You didn't write how you have organized your code, but I guess all you need to do is to reinitialize the zoomer ( QwtPlotZoomer::setZoomBase() ) after you have changed your scales.

Uwe

class Zoomer: public QwtPlotZoomer
{
public:
Zoomer(int xAxis, int yAxis, QwtPlotCanvas *canvas):
QwtPlotZoomer(xAxis, yAxis, canvas)
{
setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner);
setTrackerMode(QwtPicker::AlwaysOff);
setRubberBand(QwtPicker::NoRubberBand);

// RightButton: zoom out by 1
// Ctrl+RightButton: zoom out to full size

#if QT_VERSION < 0x040000
setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlButton);
#else
setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
#endif
setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
}
};




d_zoomer[0] = new Zoomer( QwtPlot::xBottom, QwtPlot::yLeft,
_plotWidget->_canvas);
d_zoomer[0]->setRubberBand(QwtPicker::RectRubberBand);
d_zoomer[0]->setRubberBandPen(QColor(Qt::green));
d_zoomer[0]->setTrackerMode(QwtPicker::ActiveOnly);
d_zoomer[0]->setTrackerPen(QColor(Qt::white));

d_zoomer[1] = new Zoomer(QwtPlot::xBottom, QwtPlot::yLeft,
_plotWidget->_canvas);

//QwtPlotPicker is used to set the RubberBand , ,TrackerPen ,DragSelection
//in the canvas
_dpicker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
QwtPicker::PointSelection | QwtPicker::DragSelection,
QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
_plotWidget->_canvas);
//Set's the RubberBand as CrossRubberBand
_dpicker->setRubberBand(QwtPicker::CrossRubberBand);
//Set's the RubberBandPen to color specified in QColor
_dpicker->setRubberBandPen(QColor(Qt::green));
//Set's the TrackerPen to color specified in QColor
//Tracker pen mean's while we are dragging the mouse on canvas it shows the
//(X , Y) CoOrdinate's pair according to the position where mouse is placed
//and it shows continously
_dpicker->setTrackerPen(QColor(Qt::black));

connect(_dpicker, SIGNAL(moved(const QPoint &)),
SLOT(moved(const QPoint &)));


d_panner = new QwtPlotPanner(_plotWidget->_canvas);
d_panner->setMouseButton(Qt::MidButton);

connect(_btnZoom, SIGNAL(toggled(bool)), SLOT(enableZoomMode(bool)));



void TrafficPlotter::enableZoomMode(bool on)
{
d_panner->setEnabled(on);

d_zoomer[0]->setEnabled(on);
d_zoomer[0]->zoom(0);

d_zoomer[1]->setEnabled(on);
d_zoomer[1]->zoom(0);

_dpicker->setEnabled(!on);

}

Uwe
29th February 2008, 11:04
This code is not the important one.

Check, when you initialize your axes ( or if you are using autoscaling, when you trigger it ). Then adjust the zoomBase of your zoomer ( you might need to do a replot() before, to apply the axes changes )

Uwe