
Originally Posted by
r2com
In this thread I am talking about example where I generate data in memory and then plot all of it.
This is a totally different situation, than an oscilloscope as you could do some preprocessing - creating different level of details - outside the render loop in advance.
But anyway: I stripped down your demo to the relevant code and replaced the QwtSyntheticPointData by calculating the points in advance ( qSin is an expensive operation and doing it 1000000 times in the render cycle is more expensive than rendering itself ). I also modified the y ranges as with your settings lines will be short only - not challenging the render engine enough.
#include <QApplication>
#include <QElapsedTimer>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_plot_canvas.h>
{
public:
MyPlot()
{
const int numPoints = 1000000;
#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>
class MyPlot: public QwtPlot
{
public:
MyPlot()
{
const int numPoints = 1000000;
QwtPlotCanvas* canvas = new QwtPlotCanvas();
#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
Now running this code on my system ( Intel(R) Core(TM) i7-3770T CPU @ 2.50GHz, 4988.50 + onboard graphics ) - something middle class - I have the following output:
When enabling QwtPlotCanvas::OpenGLBuffer - this is a mode, where the plot is rendered to a FBO translating it to a QImage later - I have the following:
I also tried Qt4 with the X11 paint engine:
Finally I tried QwtPlotOpenGLCanvas:
Having a range of 19ms to 65ms for 1000000 doesn't sound totally bad to me.
O.k. doing the tests 1,2 and 4 without FilterPointsAggressive:
QSize(1920, 1132) 1764
QSize(1920, 1132) 64
QSize(1920, 1132) 99
The first value is of course totally bad, but pumping in 1000000 points to the raster paint engine is something it can't handle with good performance. The OpenGL values look o.k.
Sorry, but I don't understand your initial complaints - to me it looks like the FilterPointsAggressive mode does a pretty good job - especially in combination with QwtPlotCanvas::OpenGLBuffer, where you don't have any of the problems of the OpenGL based canvases.
Uwe
Bookmarks