Results 1 to 4 of 4

Thread: shifting curve in real time

  1. #1
    Join Date
    Mar 2019
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default shifting curve in real time

    Hi,
    I have a real time charting situation with a new point being added to the curve every 100ms or so.
    The x axis represents the amount of time passed since the point has been added with 0 on the right side and some negative value on the left side.
    So, each time a point is added I want the entire curve to move to the left by the amount of time that has passed, and have the new point added with it's x value at 0.
    Currently I'm doing this by updating the x value of each point in my QVector<QPointF>, adding the new point and calling curve->setSamples() on that data followed by replot.
    The issue is that when the old points shift over rather than moving strictly to the left, they appear to also move ever so slightly up, down or to the right causing the curve to have a very distracting wiggling effect.
    I have tried turning on anti-aliasing for the curves as well as explicitly setting the style to lines and turning off curve fitting.
    Any help would be greatly appreciated

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

    Default Re: shifting curve in real time

    Quote Originally Posted by qtguy12235 View Post
    when the old points shift over rather than moving strictly to the left, they appear to also move ever so slightly up, down or to the right causing the curve to have a very distracting wiggling effect.
    Hard to say something useful without seeing whatever this is. But if you upload a small compilable tarball I will have a look at it.

    uwe

  3. #3
    Join Date
    Mar 2019
    Posts
    2
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: shifting curve in real time

    example.tar.gz
    Here's a small example,
    Thanks Uwe

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

    Default Re: shifting curve in real time

    So by wiggling you mean, that the y axis is changing at the beginning of your test ?

    This is an effect of having the autoscaler being enabled. It can be avoided by setting a fixed scale:

    Qt Code:
    1. plot->setAxisScale( QwtPlot::yLeft, -1, 1 );
    To copy to clipboard, switch view to plain text mode 
    If you need autoscaling you could at least do:

    Qt Code:
    1. void YourScaleEngine::autoScale( int maxNumSteps,
    2. double &x1, double &x2, double &stepSize ) const
    3. {
    4. x1 = qMin( x1, -1 );
    5. x2 = qMax( x2, 1 );
    6.  
    7. QwtLinearScaleEngine::autoScale( maxNumSteps, x1, x2, stepSize );
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 18th October 2015, 10:17
  2. Replies: 2
    Last Post: 6th May 2014, 08:29
  3. shifting curve up or down
    By oliver_mpt in forum Qwt
    Replies: 3
    Last Post: 26th November 2012, 11:17
  4. Qwt real time
    By oddytz1989 in forum Qwt
    Replies: 3
    Last Post: 10th February 2012, 04:41
  5. Best way in Qt to plot curve per real-time reading?
    By Sheng in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2009, 22:33

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.