PDA

View Full Version : zoomer->zoomRect() is upside-down?



alketi
19th May 2013, 01:04
I have a waveform that goes from +1 to -1 on the y-axis.

mRect = zoomer->zoomRect();

Results in:

mRect.top() = -1;
mRect.bottom() = 1;

This is upside-down.

Is this expected behavior?

wysota
19th May 2013, 08:28
Does it change if you start the zooming action from the bottom and drag the zommer rect up?

Uwe
19th May 2013, 10:00
This is upside-down. Is this expected behavior?
It is: rect.top() is the same as rect.y() and rect.bottom() is the same as rect.y() + rect.height() - that's how QRect(F) is designed.

QRect(F) was made having screen coordinates in mind ( here 0,0 is top/left ), but for almost any other coordinate system the terminology bottom/top is counter intuitive. But IMO this is not reason enough for not using QRect(F) for Qwt.

Uwe

alketi
19th May 2013, 16:35
Thank you Uwe.

If you're inclined, I would suggest putting a note about this in the QwtPlotZoomer zoomRect() documentation, to prevent others from being similarly confused

wysota
19th May 2013, 22:00
Thank you Uwe.

If you're inclined, I would suggest putting a note about this in the QwtPlotZoomer zoomRect() documentation, to prevent others from being similarly confused

This is a feature of QRect and not QwtPlotZoomer.

alketi
20th May 2013, 00:15
Hi Wysota,

I understand this is normal behavior for QRect, which perhaps makes sense when orienting to (0,0). However, it's use in QwtPlotZoomer is counter-intuitive, which is why I recommended documenting it as a note to users.

If it were documented in Qwt, I would have saved myself an hour or two of debug, and not needed to ask the community for help, which has also taken time from you and Uwe.

Cheers :)

Uwe
20th May 2013, 09:05
However, it's use in QwtPlotZoomer is counter-intuitive,...
Don't see anything specific in QwtPlotZoomer - beside it was the place where you struggled.

QRect is used in Qt and Qwt almost always and everywhere - alone in the API of Qwt you find ~258 occurrences. If it would be one or two APIs I would add a comment, but in this particular case it is something a developer simply has to know when working with Qt.

Uwe