c++ - Direct paint to QwtPlot slows down with size of samples -


not simple question. on project collect 3d data points national instruments device , plot them qwtplot in real time trough qwtplotspectrocurve (color gradient plot). because it's real time use qwtplotdirectpainter paint latest points acquired. rate of acquision 500 3dpts/s (and should able fast 2000 3dpts/s). i'll acquire 500x500 = 250 000 pts, 1000x1000 = 1 000 000 pts in total.

the issue have paint job slows down qvector array gets more , more points. wasn't expecting i'm using directpainter job. i'd expect constant rate.

here's flow of program.

a dedicated class holds base elements:

qvector<qwtpoint3d> trace; // data holder qwtplotspectrocurve tracecurvedata; // color gradient painting qwtplotdirectpainter dirpainter; // paints last points  int newpoints=0; // count new points in need of beeing plotted  inconstructor(){ // in constructor of class holds of     tracecurvedata.setrenderthreadcount(0);     tracecurvedata.attach(this); // class inherits qwtplot  } 

a main loop acquires new points, appending them trace data holder. @ same time keeps track of new points in need of plotting:

while(acquiring){     if(newpoint){ // if device has new point me         trace.append(qwtpoint3d(newx(),newy(),newz()));         newpoints++;     } } 

a qtimer running in background , triggers each 50ms executing following routine:

void timertimeout(){ // when qtimer times out plot new points accumulated     int sizeofdata = trace.size();     tracecurvedata.setsamples(trace); // seems deep copy.     dirpainter.drawseries(&tracecurvedata, sizeofdata-newpoints, sizeofdata);     newpoints=0; // reset counter. } 

three things see can issue:

  • setsamples() seems deep copying trace array each time. explain slower performance. reason need call setsamples() every time want paint new points, otherwise dirpainter won't work , nothing @ gets painted.

  • trace.size(), qvector, may not optimized , takes longer , longer count elements in array. doubt it.

  • dirpainter.drawseries() takes longer , longer access qvector's last elements grows. in linkedlist type of memory arrangement, qvector not, doubt well.

that said, know how properly? feel there wrong program flow. in particular constant need setsamples().

i linked central classes of qwt issue documentation. hope info provide suffices. if not let me know , i'll make better.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -