#include <QApplication>
#include <QElapsedTimer>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_canvas.h>
#include <qwt_plot_opengl_canvas.h>
#include <QtMath>
#include <QDebug>
#include <QtOpenGL>
{
public:
MyPlot()
{
const int numPoints = 10;
//QwtPlotCanvas* canvas = new QwtPlotCanvas();
QwtPlotOpenGLCanvas *canvas = new QwtPlotOpenGLCanvas(); // NEW OpenGL Canvas
#if 0
#endif
setCanvas( canvas );
setCanvasBackground( Qt::white );
setAxisScale
( QwtPlot::yLeft,
-1.5,
1.5 );
setAxisScale
( QwtPlot::xBottom,
0.0, numPoints
);
curve->setTitle( "Some Points" );
curve
->setPaintAttribute
(QwtPlotCurve::FilterPointsAggressive,
true);
for ( int i = 0; i < numPoints; i++ )
curve->setSamples( points );
curve->attach( this );
}
virtual void drawCanvas
( QPainter *painter
) {
QElapsedTimer timer;
timer.start();
qDebug() << size() << timer.elapsed();
}
};
int main( int argc, char **argv )
{
MyPlot plot;
plot.resize( 600, 400 );
plot.show();
return a.exec();
}
#include <QApplication>
#include <QElapsedTimer>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_canvas.h>
#include <qwt_plot_opengl_canvas.h>
#include <QtMath>
#include <QDebug>
#include <QtOpenGL>
class MyPlot: public QwtPlot
{
public:
MyPlot()
{
const int numPoints = 10;
//QwtPlotCanvas* canvas = new QwtPlotCanvas();
QwtPlotOpenGLCanvas *canvas = new QwtPlotOpenGLCanvas(); // NEW OpenGL Canvas
#if 0
canvas->setPaintAttribute( QwtPlotCanvas::OpenGLBuffer, true );
#endif
setCanvas( canvas );
setCanvasBackground( Qt::white );
setAxisScale( QwtPlot::yLeft, -1.5, 1.5 );
setAxisScale( QwtPlot::xBottom, 0.0, numPoints );
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setTitle( "Some Points" );
curve->setPaintAttribute(QwtPlotCurve::FilterPointsAggressive, true);
QPolygonF points;
for ( int i = 0; i < numPoints; i++ )
points += QPointF( i, qSin( i ) );
curve->setSamples( points );
curve->attach( this );
}
virtual void drawCanvas( QPainter *painter )
{
QElapsedTimer timer;
timer.start();
QwtPlot::drawCanvas( painter );
qDebug() << size() << timer.elapsed();
}
};
int main( int argc, char **argv )
{
QApplication a( argc, argv );
MyPlot plot;
plot.resize( 600, 400 );
plot.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks