PDA

View Full Version : Problem using setAxisScaleDraw and QwtPlotZoomer



cesroc
10th July 2012, 16:08
Hello,

I have to plot curves using QDateTime as x-axis. I'm using setAxisScaleDraw and using my return as below:



return QDateTime::fromTime_t( v ).toString( "hh:mm:ss" );


It's working fine and plotting everything right. I added a QwtPlotZoomer to my software to perform the zoom possibility, and it's working also fine.

The problem is: when I try to zoom a small part of the curve, for example, if I want to zoom some part that is less than one minute, my x-axis keeps with one minute size and my curve goes to the center of the screen, it doens't use the whole plot area.

Example:

The figure below, I have current and voltage plotted, and I zoomed just one part, represented using blue arrows.

7975

The figure below is the result of the first zoom, showed at figure above:

7976

It's possible to see that QwtPlotZoomer is working fine and also the scaleDraw. I zoomed a big part, then it works fine. The third figure (figure below) shows the result of the last zoom (figure above):

7977

And then I zoomed again the last figure, just a small part. And I get my problem, my last zoom is just 3 seconds, but the x-axis keeps with almost one minute and my graph goes to the center of the plot area (figure below):

7978

My question: is there a limit for the scaleDraw? I tried to use milliseconds, but I couldn't find a way to do that, I don't know exactly how it works. I would like to use always the whole plotting area, and don't have this small piece of curve. Someone has any ideia why it's happening that?

I hope someone can understand my problem and help me, if you have any questions I can try to explain again.

Uwe
10th July 2012, 16:23
Qwt classes only know about doubles - the fact that those are somehow related to date/time values is completely in your code.

Uwe

cesroc
11th July 2012, 09:12
Uwe, sorry, but I didn't understand what you meant.
Can you explain again?
Thanks

Uwe
11th July 2012, 11:01
Uwe, sorry, but I didn't understand what you meant.
Eliminate the effect of using date/time temporarily and use a usual QwtScaleDraw object - so, that you can compare the visual result more easily to what happens when you zoom in.
Then check what rectangles are selected by the zoomer ( use the debugger, or connect to the signals of QwtPlotZoomer/QwtPlotPicker ). Then we have more information about where to look for the problem.

Note that you are using the inofficial patch for more than 4 axes. Maybe this is a problem related to using a wrong axis index because of it.

Uwe

cesroc
12th July 2012, 13:17
Hello Uwe,

If I eliminate the date/time the problem persists. The same result. I checked the rectangles and it's right. I tried to use the rectangle's first and last point as x-axis and It doesn't work. It prints as I showed before, just a small piece on the screen's center. I don't think my problem is because of the patch, because I'm using the MultiYAxis patch, I'm applying just for the y-axis, I don't have and use a patch on my x-axis. I have just the two x-axis that Qwt provides, top and bottom.

Do you have any other idea?

Thanks in advance

Uwe
12th July 2012, 19:37
Please simplify your code as far as possible and find values for the scale, that you can show the problem with a simple call of setAxisScale. Then try the same with a version without using the multi-axes patch.

When the problem is still there upload your demo code as it is and I will have a look at it. If the problem is gone without the multi-axes patch upload a tarball with your patched Qwt version too.

Uwe