PDA

View Full Version : Dual date scale support and alignment



LaminateFloor
20th October 2014, 14:40
I'm trying to figure out how to support both zero based time and a time offset on the x-axis scale.

The program I'm developing have the option to choose between zero based time where the samples begins at time 00:00 and the clock time where the samples were recorded. The samples are saved as zero based time in the memory. I've managed to inherit the QwtDateScaleDraw so that the when the clock time is used, it shows the text label with the clock time based offset. Everything works fine with this unless you would want an alignment of the clock time based values. So if the graph begins at 23:12:47.250 I don't want the tick of the left most value to be that but aligned to the next appropriate time, 23:12:45 for example. QwtDateScaleEngine already supports this but the zero based time is propagated to the scale even if the text label is different.

The question here is how to best support dual times with both proper text and scale alignment and how to inject the false x-values with the clock time based offset while the plot still believes that it is zero based?

BTW, I cannot change the x-axis values as I have other widgets based on this scale. Then I would have go through all of them too.

Uwe
21st October 2014, 08:38
The program I'm developing have the option to choose between zero based time where the samples begins at time 00:00 and the clock time where the samples were recorded.
Both types of scales display seconds/minutes/hours, but they also differ substantially. That's why implementing a scale system ( scale engine + scale draw ) for displaying elapsed time is on my TODO (http://sourceforge.net/p/qwt/feature-requests/56) list.


The question here is how to best support dual times with both proper text and scale alignment and how to inject the false x-values with the clock time based offset while the plot still believes that it is zero based?.
The proper is to implement a new type of scale engine and scale draw.



The scale draw should be pretty easy. it is simply about mapping your value ( guess: ms elapsed since ) into some string of a format "hh:mm:ss:zzz" - or maybe also showing days.
The scale engine will be more work - but maybe you don't need to implement all features. F.e. I can imagine, that you don't need autoscaling.




HTH,
Uwe

LaminateFloor
21st October 2014, 10:07
Thanks for the reply.

The ability to choose the time offset of x-scale would certainly be a useful feature in the future.

The scale draw was pretty easy and I've done my own class inherited from QwtDateScaleDraw.
I tried to do an own version derived from QwtDateScaleEngine, the only problem was when I adjusted the offset it got propagated to the plot with fake x-values which was a side effect I didn't want. I will try again but use QwtLinearScaleEngine instead. I only need alignment for hours and smaller units.