PDA

View Full Version : PlotWin with scroll on real time



looki
7th August 2008, 15:04
Hi,
I need help to construct a window like the attached one.
There should be a realtime plot with scroll view per default. I will scroll at the hole plotted curve all the time.
I read/tried all the qwt examples and did the first steps, but the scroll behaviour makes me crazy.
I implement a plot with curveplot and x-axis as
setAxisScaleDraw(QwtPlot::xBottom,xScaleDraw);
the real time plot works, I give the x and y values.
If I try :
setAxisScale(QwtPlot::xBottom, 0, 10, 5);
the start of x axis is ever 0, This i understand.
Have I ever do replot the axis if the curve is outside the canvas?
I thought QWT has implement such behaviour. This should be a normal bahaviour in my eyes.
Or did I not found this.

thanks a lot for help

looki

Uwe
7th August 2008, 16:53
You can manage the axis by yourself ( QwtPlot::setAxisScale, QwtPlot::setAxisScaleDiv ) or you enable autoscaling (QwtPlot::setAxisAutoScaling), so that the axis is adjusted to the range of the attached curves ( in fact it is adjusted to the bounding rectangle of all plot items, with an QwtPlotItem::AutoScale attribute ).

Whenever the scales or the curve attributes have changed a replot is necessary to make these changes visible. You can enable the autoReplot mode or you call replot manually, what might avoid useless replots in situations, where you need to change more than one attribute.

Uwe

looki
7th August 2008, 17:06
I tried with autoScale and it works in that way -> x-axis will be larger
thats nice, but not for me.

I update the plot every second, for example. after 10 seconds the x range is 0 ... 11 after 30 seconds 0 ... 31
but I want to see only a 10 second range: 0 ... 10 1...11 2...12 ...
and will scroll back to 0...10 on capturing.
If I go back to last printed value e.g. 15 s the window should scroll automaticly further

I think this will work within qwt ...

thanks for further discussion - help

Uwe
7th August 2008, 19:07
As far as I understand you want to show a 10s interval starting from a value that depends on the time ( and some other stuff I didn't understand ) - similar to the cpuplot example.

Then all you need to do is to increment the scales by one each second ( using setAxisScale(t, t +10.0, ...).

Uwe

looki
8th August 2008, 09:15
Uwe,
thanks,
that sounds good and is simple ... why do I have not this idea?!?! :)

but it's possible to implement a scroll bar per default? it works with zoom.
I need a default x-scrollbar so I can scroll through the hole plot every time ....


looki

Uwe
8th August 2008, 16:40
but it's possible to implement a scroll bar per default?
Sure, put a QScrollBar somewhere and connect its signals to slots, where you shift the range of the x-axis ( using setAxisScaleDiv() ).

F.e look at the event_filter example, that uses a QwtWheel for scrolling. Another sources for inspiration could be the ScrollZoomer/ScrollBar classes of the realtime example - but don't use them as they are, when you don't need a zoomer.

Uwe