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
Re: shifting curve in real time
Quote:
Originally Posted by
qtguy12235
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
1 Attachment(s)
Re: shifting curve in real time
Attachment 13053
Here's a small example,
Thanks Uwe
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:
Code:
plot
->setAxisScale
( QwtPlot::yLeft,
-1,
1 );
If you need autoscaling you could at least do:
Code:
void YourScaleEngine::autoScale( int maxNumSteps,
double &x1, double &x2, double &stepSize ) const
{
x1 = qMin( x1, -1 );
x2 = qMax( x2, 1 );
}