Results 1 to 2 of 2

Thread: Scaling and zooming with logarithmic scales

  1. #1
    Join Date
    Sep 2008
    Location
    Toulouse
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Scaling and zooming with logarithmic scales

    The application I'm working on uses Qwt to display curves. It lets the user choose between linear and logarithmic scales, for each of the plot axes.

    I have a problem related to zooming and scaling, when I use the logarithmic scale.

    When I don't zoom on a curve, Qwt does auto-scaling for the plot. On an axis with log scale, any negative or null value is considered invalid. So I sub-classed QwtPlotCurve and redefined boundingRect() and draw() in the child class, so that only valid points are drawn and taken into account to define the curve's bounding rectangle. This works fine, and prevents Qwt from setting the log axis' inferior boundary to 1e-100.

    I still have a problem with zooming. When my plot is drawn for the first time, the axes are correctly set thanks to auto-scaling. If I zoom in, it's still ok, but if I zoom out just after, the axes' boundaries take wrong values (for axes with log scale). For example, the inferior boundary is set to 1e-100, which makes all the plot look "flattened" (the inferior boundary should be set to 0.001).

    I have a hint : Qwt uses a stack of rectangles to handle zooming. When a plot is first set up and we attach a QwtPlotZoomer to it, and call setZoomBase() on it, a rectangle is pushed to the zoom stack, on index 0. The value of this rectangle seems to be computed regardless of the scale type (linear or log).
    From what I've observed, it seems like the inferior boundaries for this rectangle are (x=0.0, y=0.0). So when I zoom out totally and this rectangle is "popped" from the stack, 0.0 on log scale is translated to "minus infinity", that is, 1e-100, which become the inferior boundary.

    How to tell Qwt to take into account the plot's bounding rectangle when I set up the zoomer, so that it scales correctly when I zoom out ? Thanks for advice.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Scaling and zooming with logarithmic scales

    I have a hint : Qwt uses a stack of rectangles to handle zooming. When a plot is first set up and we attach a QwtPlotZoomer to it, and call setZoomBase() on it, a rectangle is pushed to the zoom stack, on index 0. The value of this rectangle seems to be computed regardless of the scale type (linear or log).
    Nothing is computed: it simply stores the min/max values of the corresponding scales as they are.
    From what I've observed, it seems like the inferior boundaries for this rectangle are (x=0.0, y=0.0).
    Then these are the inferior boundaries of the scales.

    I guess you are calling QwtPlotZoomer::setZoomBase too early - before your scales are initialized properly.

    Uwe

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.