Hello!

In one graph of one of my applications, I have a QwtPlot showing some curves while the X axis is visible and should be size-fixed. The plot data is shown coming at real time (once per second) from right to left, showing data correspondent to the lest 600 seconds.

Once the 600 is full (and technically even before that, but lets simplify), the situation I have is a graph that is almost always the same, with the only difference that once per second the first point (left to right) is deleted/not shown anymore, the last point is a new one (i.e. the y is different) and all other plot data is simply shifted one point to the left.

Now, in order to do this, I'm calling QwtPlot::replot(), which means that the QPixmap canvas is completely erased and repainted (i.e. recalculated) again despite the fact that 99% of it is simply the same as before, only shifted in one position. This not to mention the huge vector operation I need to do backwards with a for that shifts all the points one position and add the new one:

Qt Code:
  1. void newPointDynamic(const re8k_ict_graphical_data& yValue)
  2. {
  3. const int calculationLimit = d_samples.size() - 1;
  4.  
  5. for (int aaa = 0; aaa < calculationLimit; aaa++)
  6. d_samples[aaa].setY(d_samples[aaa+1].ry());
  7.  
  8. d_samples.last().setY(yValue);
  9. }
To copy to clipboard, switch view to plain text mode 

As you may notice, quite a huge amount of calculation and recalculation. My first question is: isn't there a improved way of doing this thing? :T

For instance I thought about using the BackingStore (i.e. cache) paint attribute, but I'm not sure it's actually improving anything (doing backtests in my circumstances is quite odd). After all, since technically speaking the canvas is totally different on each new replot, saving something in the cache this way would be fruitless (isn't that truth?).

Another option, based on what I read somewhere else, would be to cache the part of the canvas I know that would be the same in the new replot (1 to 600) and then just paint it over the left-most side of the canvas (0 to 599). That would leave only one point at the right to be updated, what I could do by using a QwtPlot with a specific repaint area (as shown by Uwe here: http://www.qtcentre.org/threads/5910...tPlot-replot()). The problem is that I have no idea about how to do it :P Not to mention I'm not sure it would be such an improvement...


Any suggestions or answers will be appreciated. Thanks!

Momergil