<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Qwt Direct Painter Clipping [SOLVED]]]></title><description><![CDATA[<p dir="auto">I am currently using QwtPlotDirectPainter to plot real time data points onto a QwtPlotCurve. All data that is received from a usb device is being plotted on the graph. Here is my function that does the direct painting of the new data points:<br />
@<br />
// paints multiple points onto the line<br />
// uses direct painter, no replot required<br />
void CustomPlot::appendActiveData(const QVector&lt;QPointF&gt; &amp;points)<br />
{<br />
// append the data point to the curve data<br />
CurveData *curveData = static_cast&lt;CurveData *&gt;(mActive-&gt;data());<br />
curveData-&gt;append(points);</p>
<pre><code>// do clipping if neccesary on specific systems
int count = curveData-&gt;size();
if (!canvas()-&gt;testAttribute(Qt::WA_PaintOnScreen)){
    // Depending on the platform setting a clip might be an important
    // performance issue. F.e. for Qt Embedded this reduces the
    // part of the backing store that has to be copied out - maybe
    // to an unaccelerated frame buffer device.
    const QwtScaleMap xMap = canvasMap(mActive-&gt;xAxis());
    const QwtScaleMap yMap = canvasMap(mActive-&gt;yAxis());

    // get bounding rect
    QRectF boundingRect = qwtBoundingRect(*curveData, (curveData-&gt;size() - points.size()) - 1, count - 1);
    const QRect clipRect = QwtScaleMap::transform(xMap, yMap, boundingRect).toRect();
    mDirectPainter-&gt;setClipRegion(clipRect);
}

// use the direct painter and paint the entire line
// this is still much faster than a 'replot'
mDirectPainter-&gt;drawSeries(mActive, (count - points.size()) - 1, count);
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">Everything works great and is extremely efficient! up until two points right next to each other on the graph have a drastic change in x value on the plot (.001mS apart on a 20 second x scale). The curve seems to not want to paint in between the two points which I think is due to the clipping region.</p>
<p dir="auto">I guess my real question is, how does the clipping work? I haven't really used much manual painting in Qt in general. Here <a href="http://imgur.com/8Vy4Xzz" target="_blank" rel="noopener noreferrer nofollow ugc">http://imgur.com/8Vy4Xzz</a> is an image of the graph for a visual example what is happening.</p>
<p dir="auto">Edit: My issue is somewhat solved. I increased the clipping region to the size of the canvas and now there are no plot points missing during the direct paint.</p>
]]></description><link>https://forum.qt.io/topic/42435/qwt-direct-painter-clipping-solved</link><generator>RSS for Node</generator><lastBuildDate>Sun, 03 May 2026 02:48:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/42435.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Jun 2014 14:23:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qwt Direct Painter Clipping [SOLVED] on Wed, 10 Sep 2014 08:24:59 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I need real time clipped data plotting too. Could you please share your CustomPlot class implementation, so I can use it as an example? Or if you can't share it, at least post some references.</p>
]]></description><link>https://forum.qt.io/post/243233</link><guid isPermaLink="true">https://forum.qt.io/post/243233</guid><dc:creator><![CDATA[Karolis B.]]></dc:creator><pubDate>Wed, 10 Sep 2014 08:24:59 GMT</pubDate></item></channel></rss>