Results 1 to 2 of 2

Thread: QwtPlotZoomer does not seem to work with negative axes

  1. #1
    Join Date
    Jan 2010
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QwtPlotZoomer does not seem to work with negative axes

    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

  2. #2
    Join Date
    Jan 2010
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QwtPlotZoomer does not seem to work with negative axes

    Solved problem

    My mistake. I missed the intersection operation in zoom() with the first element on the zoomStack, which I guess is set by the setZoomBase().

Similar Threads

  1. is it posible to invert the axes?
    By jbca in forum Qwt
    Replies: 2
    Last Post: 18th January 2010, 16:34
  2. Plot Axes
    By mcarter in forum Qwt
    Replies: 0
    Last Post: 5th December 2009, 00:47
  3. Fixed size axes
    By wim12 in forum Qwt
    Replies: 4
    Last Post: 15th May 2009, 13:37
  4. Default axes after calling zoom(0)
    By Paladin12 in forum Qwt
    Replies: 3
    Last Post: 9th December 2008, 00:40
  5. Replies: 2
    Last Post: 4th August 2008, 09:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.