Results 1 to 10 of 10

Thread: QwtScaleDraw is not update in realtime graph

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default QwtScaleDraw is not update in realtime graph

    Hi,,
    I've implemented QwtScaleDraw to make a realtime graph like qwt example(cpu usage example):

    Qt Code:
    1. class TimeScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. TimeScaleDraw(const QTime &base):
    5. baseTime(base)
    6. {
    7. }
    8. virtual QwtText label(double v) const
    9. {
    10. QTime upTime = baseTime.addMSecs((int)v);
    11. return upTime.toString();
    12. }
    13.  
    14. QTime baseTime;
    15. };
    To copy to clipboard, switch view to plain text mode 

    I want to update baseTime to current time in every timer interval instead of adding to the array in every cycle.

    i call setAxisScale(QwtPlot::yLeft,timeData[INTERVAL-1],timeData[0]) in every cycle but the timeData array is held to be fix (is 0 to 60 for 60 data to be plotted).)

    Actually i want to my array(data of y axis) be fixed but baseTime will update in every cycle.
    When i do that the labels are not changing. actually the label function is not calling because when i call setAxisScale in timer scale the scale seems to be constant but because the basetime is changing so it must update itself!!

    How can i make this class to update itslef(call the label function whenever i call setAxisScale(QwtPlot::yLeft,timeData[INTERVAL-1],timeData[0]))( the timeData array is fix))
    Last edited by alizadeh91; 3rd September 2012 at 15:33.

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

    Default Re: QwtScaleDraw is not update in realtime graph

    See QwtAbstractScaleDraw::invalidateCache: http://qwt.sourceforge.net/class_qwt...05aa5295409aa6

    Uwe

  3. #3
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtScaleDraw is not update in realtime graph

    Thanks Uwe, As i said i override it but the problem is when i want to send current time to its implemented class(QwtScaleDraw) and when my array for y axis is fix and is not changing the y-axis also is not changing and updating. But i don't understand how to do that?

    Forget to say my graph is vertically so i said y-axis!!


    Added after 5 minutes:


    Uwe, What i want to do : I've add QwtPlotGrid to realtime example of qwt. And the girds will moving as time. i want to fix labels to don't move as time. So i want instead of incrementing the array in timer, send current time in timer and add it by a constant array.
    Last edited by alizadeh91; 3rd September 2012 at 20:12.

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

    Default Re: QwtScaleDraw is not update in realtime graph

    Quote Originally Posted by alizadeh91 View Post
    As i said i override it ...
    What has nothing to do with my link about QwtAbstractScaleDraw::invalidateCache ...

    Qt Code:
    1. class TimeScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. ....
    5.  
    6. void setBaseTime( const QTime &time )
    7. {
    8. m_baseTime = time;
    9. invalidateCache();
    10. }
    11.  
    12. ....
    13. private:
    14. QTime m_baseTime;
    15. };
    To copy to clipboard, switch view to plain text mode 

    Then the next replot will update the tick labels.

    Uwe

  5. The following user says thank you to Uwe for this useful post:

    alizadeh91 (4th September 2012)

  6. #5
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtScaleDraw is not update in realtime graph

    You are my hero man

  7. #6
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtScaleDraw is not update in realtime graph

    I'm sorry uwe!! but it won't work!!! it's not rescalling the axis.??

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

    Default Re: QwtScaleDraw is not update in realtime graph

    What it does is to return different labels for the same values depending on the base time - without rescaling.
    When you want to rescale I didn't get what you want to do.

    Uwe

Similar Threads

  1. Refreshing a Custom QwtScaleDraw
    By grantbj74 in forum Qwt
    Replies: 6
    Last Post: 28th March 2012, 05:20
  2. Replies: 1
    Last Post: 13th October 2011, 16:52
  3. Replies: 2
    Last Post: 14th September 2011, 07:53
  4. QwtScaleDraw align label to xaxis
    By kja in forum Qwt
    Replies: 1
    Last Post: 21st November 2010, 19:55
  5. Replies: 1
    Last Post: 14th October 2010, 18:56

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
  •  
Qt is a trademark of The Qt Company.