Results 1 to 2 of 2

Thread: Can an Axis' Labels be Redrawn?

  1. #1
    Join Date
    Sep 2015
    Location
    Ontario, Canada
    Posts
    28
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Can an Axis' Labels be Redrawn?

    Is there a way to redraw the labels on an axis' ticks to update the labels along it like how you can replot a QwtPlot to update the curves being drawn within?

    I have a subclassed QwtScaleDraw that returns a time associated with a value v ranged from [0-PLOTUPPERBOUND] along the x-axis when it is passed label(v) and it is working but the x-axis labels are only updated after the initial setAxisScale and I haven't found out how to continue updating them after this point. I have data coming in to the plot in real time, and I'd like to have the x-axis labels also update in real time to show the time the data came in (underneath the time string the x values are static numbers of the range [0-PLOTUPPERBOUND] ). Right now if I create a new plot after the data collection has begun then I'll see the x-axis labels be updated to the current moment, but I want them to continue to update in realtime with the collected data after this point.

    I've tried using the method in the cpuplot example where the axis is continuously shifted along with the data but the problem with using that method here is that it ends up breaking the qwtPlotZoomer I'm using within the plot unless I pause the plot's updating because every call to setAxisScale while updating will undo any zoom along the x-axis (the y-axis zoom remains) when new data comes in and the axes are shifted.

    My subclassed QwtScaleDraw is below though it's almost exactly the same as the one from the cpuPlot example:

    Qt Code:
    1. class TimeScaleDraw: public QwtScaleDraw
    2. {
    3. public:
    4. TimeScaleDraw( QTime *base )
    5. : baseTime( base )
    6. {
    7. }
    8. virtual QwtText label( double v ) const
    9. {
    10. // QTime upTime = baseTime->addMSecs( static_cast<int>( v * 50 ) );
    11. // return upTime.toString("hh:mm:ss.zzz");
    12. return baseTime[PLOTUPPERBOUND - ((int)v % PLOTUPPERBOUND)].toString("hh:mm:ss.zzz");
    13. }
    14. private:
    15. QTime *baseTime;
    16. };
    To copy to clipboard, switch view to plain text mode 

  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: Can an Axis' Labels be Redrawn?

    Because of performance reasons there is a cache, that needs to be invalidated, when changing the value->text mapping: http://qwt.sourceforge.net/class_qwt...05aa5295409aa6.

    Uwe

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

    TEAmerc (4th November 2015)

Similar Threads

  1. Qwt dynamic x axis labels
    By K4ELO in forum Qwt
    Replies: 4
    Last Post: 15th March 2013, 21:06
  2. QwtPlot axis labels
    By Kutuska in forum Qwt
    Replies: 7
    Last Post: 29th August 2012, 16:08
  3. Labels on axis.
    By eugene in forum Qwt
    Replies: 5
    Last Post: 6th August 2010, 13:30
  4. Axis with more labels
    By rakkar in forum Qwt
    Replies: 1
    Last Post: 11th October 2009, 09:26
  5. Relocating axis labels
    By malcom2073 in forum Qwt
    Replies: 0
    Last Post: 9th May 2008, 13:01

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.