Results 1 to 2 of 2

Thread: Problem with QwtPlotCurve::drawLines() function

  1. #1
    Join Date
    Nov 2014
    Posts
    23
    Thanks
    4

    Default Problem with QwtPlotCurve::drawLines() function

    I have a scenario where i have to plot a curve with different color based on time....I am using QwtPlotCurve::drawLines() to acheive this color segments.... The problem is "from" and "to" argument variable(marked in bold) in drawLines() takes only int type but i need to pass float type....

    virtual void drawLines (QPainter *p, const QwtScaleMap &xMap,const QwtScaleMap &yMap, const QRectF &canvasRect, int from, int to) const;

    any suggestions please.......

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

    Default Re: Problem with QwtPlotCurve::drawLines() function

    from/to are indexes no coordinates !

    Guess what you want to do is to overload QwtPlotCurve::drawLines(), where you split your index intervals according to your coordinates. As your points are ordered by time are you can use qwtUpperSampleIndex() to calculate the indexes corresponding to your time intervals.

    Something like this:

    Qt Code:
    1. class YourCurve: public QwtPlotCurve
    2. {
    3. public:
    4. virtual void drawLines( QPainter *painter,
    5. const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    6. const QRectF &canvasRect, int from, int to ) const
    7. {
    8. for_all_your_intervals()
    9. {
    10. int idx1 = indexOf( interval.min() );
    11. int idx2 = indexOf( interval.max() );
    12.  
    13. painter->setPen( ... );
    14. QwtPlotCurve::drawLines( painter, xMap, yMap, canvasRect, idx1 idx2 );
    15. }
    16. };
    To copy to clipboard, switch view to plain text mode 
    Uwe

Similar Threads

  1. Replies: 8
    Last Post: 9th February 2014, 12:37
  2. issue with drawLines
    By Maluko_Da_Tola in forum Newbie
    Replies: 2
    Last Post: 1st November 2013, 12:00
  3. Replies: 8
    Last Post: 18th October 2012, 07:23
  4. Replies: 1
    Last Post: 11th May 2012, 08:02
  5. Replies: 1
    Last Post: 1st December 2010, 11:02

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.