PDA

View Full Version : Improving performance with QwtPlotCurve::Lines



jaray
3rd November 2015, 15:01
In my current project I am needing to plot out time series data for 25-50 msec sampled at 62.5 Mhz. qwt handles it wonderfully when the samples are spaced further apart (as in not just baseline noise), however there are times when I do get baseline noise. When this happens the plotting interface really begins to struggle. I tracked down the issue to setStyle(QwtPlotCurve::Lines). By using setStyle(QwtPlotCurve::Dots) instead, the performance drastically improved. Any tips on improving performance using Lines? Data reduction will need to be implemented at some point, but for now I need the raw samples.


directPainter_m = new QwtPlotDirectPainter();


setAutoReplot( false );
setCanvas( new Canvas() );
zoom_m = new QwtPlotZoomer(canvas());

plotLayout()->setAlignCanvasToScales( true );

QwtPlotGrid *grid = new QwtPlotGrid();
grid->setPen(QPen(Qt::gray, 1, Qt::DotLine));
grid->setXAxis(0);
grid->setYAxis(0);
grid->enableX(true);
grid->enableXMin(false);
grid->enableY(true);
grid->enableYMin(false);
grid->attach(this);

plotOrigin_m = new QwtPlotMarker();
plotOrigin_m->setLineStyle( QwtPlotMarker::HLine );
plotOrigin_m->setValue(0.0,0.0);
plotOrigin_m->setLinePen( Qt::gray, 0.0, Qt::DashLine );
plotOrigin_m->attach( this );

plotCurve_m = new QwtPlotCurve();
//plotCurve_m->setRenderThreadCount(0);
plotCurve_m->setSymbol(NULL);
plotCurve_m->setStyle( QwtPlotCurve::Dots );
plotCurve_m->setPen( canvas()->palette().color( QPalette::WindowText ) );
plotCurve_m->setRenderHint( QwtPlotItem::RenderAntialiased, false );
plotCurve_m->setPaintAttribute( QwtPlotCurve::ClipPolygons, true );
plotCurve_m->setPaintAttribute( QwtPlotCurve::FilterPoints , false );
plotCurve_m->setPaintAttribute( QwtPlotCurve::MinimizeMemory , false );


setAxisTitle( QwtPlot::xBottom, xLabel_m);
setAxisTitle( QwtPlot::yLeft, yLabel_m);

connect(zoom_m, SIGNAL(selected(QRectF)), this, SIGNAL(selectedrect(QRectF)));

Uwe
3rd November 2015, 15:53
What refresh rate do you need ( sample rate != refresh rate !! )
How many points do you have and how many of them are visible
Is it possible to paint incrementally ( no shifting of the axes )
What OS and which Qt version



Uwe

jaray
4th November 2015, 14:58
What refresh rate do you need ( sample rate != refresh rate !! )
How many points do you have and how many of them are visible
Is it possible to paint incrementally ( no shifting of the axes )
What OS and which Qt version

Uwe

What refresh rate do you need
Not important. Once the data has been received by the system and plotted, it remains static until the next test is performed.

How many points do you have and how many of them are visible
For normal testing, I will be need 25-30 msec of data. This would mean that I have about 2 million points at any given time. Upon zooming in I will be looking at portions of the plot < 1 msec so less than 62500 point.

Is it possible to paint incrementally ( no shifting of the axes )
I am not exactly sure of what this means, but like I said before, once that data is received and plotted, the only requirement from the plot is zooming based on mouse dragging.

What OS and which Qt version
The current build is using Qt 5.4.1 and qwt 6.1.2 on windows 7 with planned deployment on windows 7.

Uwe
6th November 2015, 07:25
Well you have 2 approaches:



minimize the costs of rendering lines
reduce what needs to be painted



By minimizing the costs I mean stuff like using a pen width of 1, no antialiasing, trying to use a hardware accelerated backend etc.

But when talking about 2 million lines, you will have to do some reduction. One candidate is Douglas Peucker offered by QwtWeedingCurveFitter ( expensive algo, so don't use it as curve fitter - instead pass the reduced point set ).
If you don't mind to use Qwt from svn you could try QwtPlotCurve::FilterPointsAggressive. This algo is pretty fast and should have a significant effect in your case.

Uwe