PDA

View Full Version : Noobish problems with QwtPlotPanner



YaK
2nd November 2008, 05:21
Hi. The troubles are:
1) when i move the plot by mouse, it could be moved far away from any needed area. How can i tell Qwt the EXACT plotting zone?
2) when the plot is being dragged and not dropped,only the part, the previously visible part is drawn. How can it be fixed?



#include <QtGui/QApplication>
#include <QVector>

#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_panner.h>

#include <qwt_plot_grid.h>
#include <qwt_plot_canvas.h>

#define NUM_OF_POINTS 1000
int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QwtPlot* megaPlot = new QwtPlot(QwtText("MegaPlot"));
QwtPlotCurve* megaCurve = new QwtPlotCurve("MEGALINE");
double x[NUM_OF_POINTS], y[NUM_OF_POINTS];
for(int i = 0; i < NUM_OF_POINTS; i++)
{
x[i] = i;
y[i] = i*i;
}
megaCurve->setData(x,y,NUM_OF_POINTS);
megaCurve->attach(megaPlot);

QwtPlotGrid* megaGrid = new QwtPlotGrid;
megaGrid->enableXMin(true);
megaGrid->enableYMin(true);
megaGrid->attach(megaPlot);

megaPlot->resize(640,480);

QwtPlotPanner* megaPanner = new QwtPlotPanner(megaPlot->canvas());
megaPanner->setMouseButton(Qt::RightButton);

megaPlot->show();
return a.exec();
}

Uwe
3rd November 2008, 11:13
1) when i move the plot by mouse, it could be moved far away from any needed area. How can i tell Qwt the EXACT plotting zone?
QwtPlot::setAxisScale().


2) when the plot is being dragged and not dropped,only the part, the previously visible part is drawn. How can it be fixed?
For simple scenarios replotting might be fast enough for mouse movements, but for many others its way to expensive. That's why the panner grabs the content into a pixmap at the beginning of the pan operation and only replots once at the end.

If your replots are fast you can implement your own type of panning ( translating mouse movements into axis changes ), but you can't tell QwtPlotPanner to do it for you.

Uwe