QwtPlotZoomer URGENT PROBLEM
Brought to you by:
rathmann
From: Raul C. <vid...@gm...> - 2007-09-25 14:55:58
|
Hi Qwt users. I tried to add a zoom feature to a big existing project. Unfortunately the plot canvas is not only written in Qwt but with a mix of Qt/Qwt so sometime I get strange behaviour. I added a class named MoPlotZoomer to the plot object so: This is the .h -------------------------------------------------------------------------------------- #ifndef __MOPLOTZOOMER_H__ #define __MOPLOTZOOMER_H__ #include <qwt_plot_zoomer.h> class QwtPlotZoomer; class MoPlotZoomer : public QwtPlotZoomer{ public: //default ctor MoPlotZoomer(QwtPlotCanvas *canvas); //dtor virtual ~MoPlotZoomer(); protected: //nothing private: //nothing }; #endif //__MOPLOTZOOMER_H__ -------------------------------------------------------------------------------------- And this is the .cpp -------------------------------------------------------------------------------------- #include "MoPlotZoomer.h" //default ctor MoPlotZoomer::MoPlotZoomer(QwtPlotCanvas *canvas) : QwtPlotZoomer(canvas) { setSelectionFlags(QwtPicker::DragSelection | QwtPicker::CornerToCorner); setTrackerMode(QwtPicker::AlwaysOff); setRubberBand(QwtPicker::NoRubberBand); // RightButton: zoom out by 1 // Ctrl+RightButton: zoom out to full size setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton, Qt::ControlModifier); setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton); } //dtor MoPlotZoomer::~MoPlotZoomer() { } -------------------------------------------------------------------------------------- The plot object is named MoPlot2D and I added the routine addZoomer() to add the zoom and pan feature. void MoPlot2D::addZoomer() { //enable zooming zoomer = new MoPlotZoomer( qwtplot->canvas() ); zoomer->setRubberBand(QwtPicker::RectRubberBand); zoomer->setRubberBandPen(QColor(Qt::green)); zoomer->setTrackerMode(QwtPicker::ActiveOnly); zoomer->setTrackerPen(QColor(Qt::white)); //enable panner panner = new QwtPlotPanner( qwtplot->canvas() ); panner->setMouseButton(Qt::MidButton); qwtplot->replot(); zoomer->setZoomBase(); } Some time I get strange behaiour: when I zoom in seems that I loose the plot informations and I can't see nothing. I loose the axis values and in the canvas the curve is not present. And more: When I zoom out to the original size, the plot is not as at the begin, the axis are different. So I think that if I store the axis informations when I zoom in, I can restore them when I zoom out to the original and set the plot axis. I would like to execute a routine when I zoom in, zoom out by 1 and zoom out to the original. I need to catch that events. Can anyone say to me HOW? Please? regards raul |