Results 1 to 4 of 4

Thread: how to use QwtplotCurve::fillcurve Fill area above baseline and below the curve

  1. #1
    Join Date
    Apr 2013
    Posts
    13
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how to use QwtplotCurve::fillcurve Fill area above baseline and below the curve

    something like http://www.halliburton.com/public/la...promaxvsp3.jpg

    I have tried following code ,but it is not what I want
    Qt Code:
    1. void QwtPlotCurveAnteo::fillCurve(QPainter *painter,
    2. const QwtScaleMap &xMap,
    3. const QwtScaleMap &yMap,
    4. const QRectF & canvasRect,
    5. QPolygonF & polygon) const
    6. {
    7. painter->save();
    8. painter->setClipRect(xMap.transform(baseline()),0,100,1000,
    9. Qt::ReplaceClip);
    10.  
    11. QwtPlotCurve::fillCurve(painter, xMap, yMap, canvasRect, polygon);
    12.  
    13. painter->setClipRect(xMap.transform(baseline()),0,100,1000,
    14. Qt::NoClip);
    15. painter->restore();
    16.  
    17. return;
    18. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: how to use QwtplotCurve::fillcurve Fill area above baseline and below the curve

    It should be something like this:

    Qt Code:
    1. virtual void YourCurve::fillCurve(QPainter *painter,
    2. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    3. const QRectF & canvasRect, QPolygonF & polygon) const
    4. {
    5. double x = xMap.transform( baseline() );
    6. if ( x >= canvasRect.right() )
    7. return;
    8.  
    9. x = qMax( x, canvasRect.left() );
    10.  
    11. const QRectF clipRect( x, canvasRect.top(), canvasRect.right() - x, canvasRect.height() );
    12.  
    13. painter->save();
    14. painter->setClipRect( clipRect, Qt::IntersectClip );
    15.  
    16. QwtPlotCurve::fillCurve( painter, xMap, yMap, canvasRect, polygon );
    17.  
    18. painter->restore();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Uwe

  3. #3
    Join Date
    Apr 2013
    Posts
    13
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to use QwtplotCurve::fillcurve Fill area above baseline and below the curve

    but it just looks like this :
    2013-05-03 10:34:24的屏幕截图.jpg
    maybe the problem is not here...

  4. #4
    Join Date
    May 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how to use QwtplotCurve::fillcurve Fill area above baseline and below the curve

    Hi all,
    I try to fill the curve below and over the baseline with different color. I try to use the code that I found here and for clipping different regions it's ok.
    But I'm not been able to fill it with different color could someone help me. I try with setBrush(...) but nothing happen.
    Thanks miky.

    Qt Code:
    1. void Curve::fillCurve(QPainter *painter,
    2. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    3. const QRectF & canvasRect, QPolygonF & polygon) const
    4. {
    5. painter->save();
    6. QBrush *brush1 = new QBrush (Qt::green, Qt::SolidPattern);
    7. painter->setBrush(*brush1);
    8. painter->setClipRect(0,yMap.transform(baseline()),1000,1000,
    9. Qt::ReplaceClip);
    10. // QwtPlotCurve::fillCurve(painter, xMap, yMap, canvasRect, polygon);
    11.  
    12. painter->setClipRect(0,0,1000,yMap.transform(baseline()),
    13. Qt::ReplaceClip);
    14. QwtPlotCurve::fillCurve(painter, xMap, yMap, canvasRect, polygon);
    15. painter->restore();
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 5
    Last Post: 17th December 2014, 13:07
  2. Replies: 10
    Last Post: 7th March 2012, 19:22
  3. Fill area of QPainterPath
    By vides2012 in forum Qt Programming
    Replies: 6
    Last Post: 17th June 2011, 14:00
  4. Replies: 4
    Last Post: 29th April 2010, 07:11
  5. Replies: 1
    Last Post: 28th January 2010, 13:57

Tags for this Thread

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.