Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Qwt Direct Painter Clipping [SOLVED]

Qwt Direct Painter Clipping [SOLVED]

Scheduled Pinned Locked Moved 3rd Party Software
2 Posts 2 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vezprog
    wrote on last edited by
    #1

    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:
    @
    // paints multiple points onto the line
    // uses direct painter, no replot required
    void CustomPlot::appendActiveData(const QVector<QPointF> &points)
    {
    // append the data point to the curve data
    CurveData *curveData = static_cast<CurveData *>(mActive->data());
    curveData->append(points);

    // do clipping if neccesary on specific systems
    int count = curveData->size();
    if (!canvas()->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->xAxis());
        const QwtScaleMap yMap = canvasMap(mActive->yAxis());
    
        // get bounding rect
        QRectF boundingRect = qwtBoundingRect(*curveData, (curveData->size() - points.size()) - 1, count - 1);
        const QRect clipRect = QwtScaleMap::transform(xMap, yMap, boundingRect).toRect();
        mDirectPainter->setClipRegion(clipRect);
    }
    
    // use the direct painter and paint the entire line
    // this is still much faster than a 'replot'
    mDirectPainter->drawSeries(mActive, (count - points.size()) - 1, count);
    

    }
    @

    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.

    I guess my real question is, how does the clipping work? I haven't really used much manual painting in Qt in general. Here http://imgur.com/8Vy4Xzz is an image of the graph for a visual example what is happening.

    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.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Karolis B.
      wrote on last edited by
      #2

      Hello,
      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved