Hello!

I'm trying to use QwtPlotDirectPainter to improve the plotting of a embedded device-based Qt interface using Qwt. I used one of the Qwt example implementations of the QwtPlotDirectPainter class and the code I wrote was:

Qt Code:
  1. void fastReplot(const int updatePos)
  2. {
  3. if (updatePos == 0)
  4. replot();
  5. else //if (!canvas()->testAttribute(Qt::WA_PaintOnScreen))
  6. {
  7. foreach(QwtPlotCurveSpecial* poCurve, curveList)
  8. {
  9. if (!poCurve->isVisible())
  10. continue;
  11.  
  12. const QwtScaleMap xMap = canvasMap(poCurve->xAxis());
  13. const QwtScaleMap yMap = canvasMap(poCurve->yAxis());
  14.  
  15. QRegion clipRegion;
  16. QRect rect(0,0,1.0,axisScaleDiv(poCurve->yAxis()).interval().width());
  17.  
  18. const QPointF center = QwtScaleMap::transform(xMap, yMap, QPointF(updatePos,axisScaleDiv(poCurve->yAxis()).interval().width()/2.0));
  19. rect.moveCenter(center.toPoint());
  20.  
  21. clipRegion += rect;
  22.  
  23. directPainter->setClipRegion(clipRegion);
  24.  
  25. directPainter->drawSeries(poCurve, updatePos, updatePos);
  26. }
  27. }
  28. }
To copy to clipboard, switch view to plain text mode 

To explain better: a data package is received by a socket connection with the Y coordinates which are put inside a static sized QVector<double>. A int value coordinates the position in the QVector where the new data should be placed. When this new data arrives, a signal connected to fastReplot(int) is emitted with the position in the vector where the new data was stored. My desire was to repaint only a small part of the plot which corresponds with the coordinate of the last updated data in the vector. The problem, though, is that the image is coming with some error:

Screenshot from 2014-05-06 10:03:50.png

In the image above, the curve should all be like it is on the left.

How to solve this? What is wrong in my code?

Thanks,

Momergil




Note: QwtPlotCurveSpecial is a variant of QwtPlotCurve