Results 1 to 5 of 5

Thread: qwtplotdirectpainter don´t use penwidth of the curve

  1. #1
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default qwtplotdirectpainter don´t use penwidth of the curve

    Hello!

    This is my first post to this forum. I usually allways find here a solution to my problem, but in this case I don´t...
    I have an Application which uses qwt 6.1.0. I realized a real-time-plot based on the realtime and oscilloscope example. I have now 2 or more realtime curves in the plot and paint this to the canvas by QwtPlotDirectPainter.
    One curve I want to display in different penwidth. The penwidth is working when I do a replot of the plot, but then I have a performance problem.
    Can I set a penwidth so the directpainter paint the curve thicker??

    Andre

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtplotdirectpainter don´t use penwidth of the curve

    Quote Originally Posted by aker View Post
    One curve I want to display in different penwidth. The penwidth is working when I do a replot of the plot, but then I have a performance problem.
    Can I set a penwidth so the directpainter paint the curve thicker?
    QwtPlotDirectPainter calls QwtPlotCurve::drawSeries(), where the curve pen is used for drawing the lines.
    So setting a curve pen ( QwtPlotCurve::setPen() ) will affect the curve in the same way as with using replot().

    Uwe

  3. #3
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: qwtplotdirectpainter don´t use penwidth of the curve

    Hello Uwe,

    sorry but I can´t get it running. I set a pen to the curve with setPen() but only the color changes.
    I tried it with my application and then with the oscilloscope example. Only when I do a replot() the pen uses the penWidth which I want to have.
    This is the code from the example where I set a new pen.
    Qt Code:
    1. d_curve = new QwtPlotCurve();
    2. d_curve->setStyle( QwtPlotCurve::Lines );
    3. // d_curve->setPen( canvas()->palette().color( QPalette::WindowText ) );
    4. d_curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
    5. d_curve->setPaintAttribute( QwtPlotCurve::ClipPolygons, false );
    6. d_curve->setData( new CurveData() );
    7. d_curve->attach( this );
    8.  
    9. QPen p;
    10. p.setColor(Qt::red);
    11. p.setWidthF(5);
    12. d_curve->setPen(p);
    To copy to clipboard, switch view to plain text mode 

    and only when I do a replot after drawSeries() the line have a width of 5.

    Qt Code:
    1. void Plot::updateCurve()
    2. {
    3. CurveData *data = static_cast<CurveData *>( d_curve->data() );
    4. data->values().lock();
    5.  
    6. const int numPoints = data->size();
    7. if ( numPoints > d_paintedPoints )
    8. {
    9. const bool doClip = !canvas()->testAttribute( Qt::WA_PaintOnScreen );
    10. if ( doClip )
    11. {
    12. /*
    13.   Depending on the platform setting a clip might be an important
    14.   performance issue. F.e. for Qt Embedded this reduces the
    15.   part of the backing store that has to be copied out - maybe
    16.   to an unaccelerated frame buffer device.
    17.   */
    18.  
    19. const QwtScaleMap xMap = canvasMap( d_curve->xAxis() );
    20. const QwtScaleMap yMap = canvasMap( d_curve->yAxis() );
    21.  
    22. QRectF br = qwtBoundingRect( *data,
    23. d_paintedPoints - 1, numPoints - 1 );
    24.  
    25. const QRect clipRect = QwtScaleMap::transform( xMap, yMap, br ).toRect();
    26. d_directPainter->setClipRegion( clipRect );
    27. }
    28.  
    29.  
    30. d_directPainter->drawSeries( d_curve,
    31. d_paintedPoints - 1, numPoints - 1 );
    32.  
    33. d_paintedPoints = numPoints;
    34. }
    35.  
    36. data->values().unlock();
    37.  
    38. [COLOR="#FF0000"]replot();[/COLOR]
    39. }
    To copy to clipboard, switch view to plain text mode 

    Can you tell me what I do wrong???

    Andre

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: qwtplotdirectpainter don´t use penwidth of the curve

    Quote Originally Posted by aker View Post
    ...and only when I do a replot after drawSeries() the line have a width of 5.
    The direct painter simply draws on top of the existing plot - nothing gets erased, what has been painted before.

    If you want to apply a modified curve pen to replace parts of a curve, that you have painted before, you have to call replot - calling drawSeries() before is not necessary. There might be optimizations, when drawing with a thicker pen, but in general it is like this.

    Uwe

  5. #5
    Join Date
    Sep 2013
    Posts
    3
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: qwtplotdirectpainter don´t use penwidth of the curve

    Hello Uwe,

    yes you are right! I played around with some things and I also changed the data collection period. The penwidth is thicker but it looks not so smooth than after a complete replot.

    Thank you Uwe!

Similar Threads

  1. QwtPlotPicker with QwtPlotDirectPainter
    By friendbaby in forum Qwt
    Replies: 1
    Last Post: 12th December 2012, 14:43
  2. don’t use but need to run application?
    By banlinhtienphong in forum Installation and Deployment
    Replies: 11
    Last Post: 26th July 2012, 04:42
  3. Replies: 10
    Last Post: 1st April 2012, 08:55
  4. Replies: 0
    Last Post: 26th February 2012, 07:29
  5. Replies: 1
    Last Post: 18th June 2010, 15:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.