Hi
I have just added zooming capabilities to my QwtPlot object using the scroll bar zooming code from the Qwt 6 realtime example (scrollbar.cpp and acrollzoomer.cpp). I put the following three lines of code into my code from that example and hey presto it all seemed to work just like that.

Qt Code:
  1. ScrollZoomer *zoomer = new ScrollZoomer(pPlotTemp->pPlot->canvas());
  2. zoomer->setRubberBandPen(QPen(Qt::red, 2, Qt::SolidLine));
  3. zoomer->setTrackerPen(QPen(Qt::red));
To copy to clipboard, switch view to plain text mode 

However when I selected a region on my plot that included negative values (my y-axis is from -512 to +512) the zoomed area only included the positive range, i.e. I highlighted a rectangle from 200,450 (x,y) top-left to 400,-450 (x,y) bottom-right and all that gets displayed is the region 200,0 to 400,450.

I have tried selecting the region in all possible ways, top-left to bottom-right, bottom-right to top-left, etc. but still the same result.

I did a bit of digging into the zoom code and got all the way into qwt_plot_zoomer.cpp in zoom() and saw that the passed QRectF had my region correctly defined, i.e. 200,-450,200,900 (x, y, w, h). All is well until it calls QRectF::normalized() which according to the manual should

Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.

If width() < 0 the function swaps the left and right corners, and it swaps the top and bottom corners if height() < 0.
Which from my interpretation should rearrange the rectangle definition such that the width and height are made positive but the start x and y can be negative. Well what I actually get is 200,0,200,450, i.e. it just crops out the negative part.

Now this strikes me as being wrong given the function definition and so is probably a QRectF Qt bug. Is my interpretation of this correct? Is there a reason the plot zoomer needs to normalize the zoom rectangle? I guess I can fix it by reimplementing the zoom() function, or anything else that uses normalised() of which there are a few, and write my own version.

Cheers