Hi,
Im drawning a qwtPlot with a X_axis that moves every 10 ms. The goal is to try and replicate real time moving of the axe.
It is similar to the example "oscilloscope" except I move the axis interval every 10ms.
I want to always leave a few seconds after the actual time so the user always know what is coming.
Here is a screenshot of it working (bottom graph)
https://www.dropbox.com/s/cztkhrm3cu...ivTimeDraw.png
My problem:
The moving of the scale is not too bad (a little laggy) but the main problem comes when a new TimeScaleDraw label appear on the right (i.e "01:00" in the example above is coming soon).
When a new label needs to be writen on the right, it draws itself in one shot and it's pertubating the graph flow.
It's hard to explain without a video but it would be fine if the label be shown gradually from the right (setting the min size or fixed size label somewhere?)
I suspect the problem is with the TimeScalDraw label because if I use standard QwtScaleDraw with number like oscilloscope, I don't get the tick problem lag.
Code:
////////////////////////////////////////////////////////////////////////////////
/// TimeScaleDraw
////////////////////////////////////////////////////////////////////////////////
public:
TimeScaleDraw
( const QTime &base
): baseTime( base )
{
}
virtual QwtText label
( double v
) const { QTime upTime
= baseTime.
addSecs( static_cast<int>
( v
) );
return upTime.toString();
}
private:
};
////////////////////////////////////////////////////////////////////////////////
/// TimeScaleDraw
////////////////////////////////////////////////////////////////////////////////
class TimeScaleDraw: public QwtScaleDraw {
public:
TimeScaleDraw( const QTime &base ):
baseTime( base )
{
}
virtual QwtText label( double v ) const {
QTime upTime = baseTime.addSecs( static_cast<int>( v ) );
return upTime.toString();
}
private:
QTime baseTime;
};
To copy to clipboard, switch view to plain text mode
Event that is triggered every 10ms or so:
void WorkoutPlotPower::moveInterval(double timeNow) {
d_interval = QwtInterval( timeNow - 15 ,
timeNow + 15);
setAxisScale
( QwtPlot::xBottom, d_interval.
minValue(), d_interval.
maxValue() );
}
void WorkoutPlotPower::moveInterval(double timeNow) {
d_interval = QwtInterval( timeNow - 15 ,
timeNow + 15);
setAxisScale( QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue() );
}
To copy to clipboard, switch view to plain text mode
Hope I can fix this or i'll have to rethink the real-time graph idea
Merci!
Bookmarks