PDA

View Full Version : My own scale widget in Qwt



igrms
11th June 2006, 23:35
Anybody knows how to create custom scale widget for plot in Qwt (I need to put on it my own values) ? And how to create multiscale plots (one y scale for each curve) ?

Uwe
12th June 2006, 20:18
1) Custom scales are possible.

If you tell me more details about Qt/Qwt versions and what you want to do in detail, I should be able to help.

2) Multiple Y-Scales

Qwt supports 2 Y scales (left + right) out of the box. If you need more than 2 Y scales you need a very deep understanding how the Qwt classes work together. I know that a couple of people hacked such a beast, but I don't recommend to try it. Better try to find a solution with 2 scales only.

HTH,
Uwe

igrms
12th June 2006, 21:26
1) Custom scales are possible.

If you tell me more details about Qt/Qwt versions and what you want to do in detail, I should be able to help.

2) Multiple Y-Scales

Qwt supports 2 Y scales (left + right) out of the box. If you need more than 2 Y scales you need a very deep understanding how the Qwt classes work together. I know that a couple of people hacked such a beast, but I don't recommend to try it. Better try to find a solution with 2 scales only.

HTH,
Uwe

Thank you, Uwe.

1) I'm using Qt 4.1.3 open source edition and Qwt snapshot 20060130.

Generally what i have to do:

I have three arrays: index, parameter value and time. Parameter value and time are functions of index (time must be linear function). Because of noise in telemetry channel there are many errors in time data. It makes impossible to plot (time, value). I have to plot (index, value) and put time ticks (where it is possible) on the bottom scale.

Generally index is the real stable "time", but user must see minutes and seconds.

2) I think, variant with 2 Y scales is not mine. I need to plot 3 and more curves in that manner. If I will not be able to understand Qwt classes interaction it would be better to find another solution for me (such as multiple plots instead of multiple scales).

Uwe
13th June 2006, 08:17
Generally index is the real stable "time", but user must see minutes and seconds.
Have a look at the cpuplot example of Qwt.

Uwe

igrms
14th June 2006, 21:20
Have a look at the cpuplot example of Qwt.

Uwe

Thank you.

But I need much more control of the scale widget.

Normally my widget must look like this:
0---1---2---3---4---5---6

But in my case time is not perfectly linear and it can look so:
0---1---2--3---4---5---6

This case is very bad. Time counter is surprisely reseted:
0---1---xxxx0---1---2---6 (xxxx --- fail --- descending time)

That is why I need to divide scale, count values and maybe draw it by myself.

Can I do it in Qwt ?

Uwe
15th June 2006, 13:38
Sounds like you need 2 things:

1) Display your own labels
2) Irregular division of your scale

How to do 1) can be seen in the cpuplot example.
For 2) you can use QwtPlot::setAxisScaleDiv. If there is a rule behind how to calculate your scale divison, it might be worth to write it down as a QwtScaleEngine.

HTH,
Uwe

bits
15th June 2006, 18:10
I agree with UVE, in that you have to use QwtPlot::setAxisScaleDiv() to be able to have variable distances between your labels on your scale. For that you need to have some sort of calculation of knowing what your scale would look like at any given instance.

Now displaying label part should be easy.
If you want to display your own labels, you can subclass QwtScaleDraw and reimplement label (double).
Obviously, you will have to tell your QwtPlot about your new QwtScaleDraw implementation by using QwtPlot::setAxisScaleDraw().

Inside label(), you can even have a mapping of the 'double' argument with your label strings.

igrms
15th June 2006, 22:18
Thank you Uwe and bits. I think now I can do what I need with a bottom scale.

And what can I do with multiple Y scales? I would like to try it. I think I'm not only one who need this useful thing.