Results 1 to 6 of 6

Thread: Axis won't stay at new scale setting

  1. #1

    Default Axis won't stay at new scale setting

    Hi all,

    After applying setAxisScale() to a QwtPlot and doing a replot() everything scales fine, but when I next call a plotzoomer moveBy() the plot moves but rescales back to the original. What is the proper way to permanently apply the axis rescaling?

    Thanks!

  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: Axis won't stay at new scale setting

    If you change the scales behind the back of the zoomer you have to adjust its internal zoom stack.

    Uwe

  3. #3

    Default Re: Axis won't stay at new scale setting

    I will post some of my code shortly but does this approach sounds correct:

    1) get the stack of the zoomer
    2) pop the last rectangle
    3) push an updated rectangle onto the stack
    4) assign the updated stack to the zoomer

    Or is there a more efficient way to update the zoomer after plot has been rescaled?

    Rescaling should take effect only on the latest zoom rectangle, the previous ones in the stack don't need to be updated.
    Last edited by Maxicatten; 23rd March 2009 at 20:28.

  4. #4

    Unhappy Re: Axis won't stay at new scale setting

    Code below. The issue is I don't know how to get the current visible rescaled rectangle from the plot without going to the zoomer.

    Qt Code:
    1. // rescale the main plot
    2. setAxisScale(QwtPlot::yLeft,lowPlotY,highPlotY);
    3.  
    4. // how to get the current visible rescaled plot rectangle??
    5. QwtDoubleRect boundRect = ????
    6.  
    7. // get the zoomer stack
    8. QStack<QwtDoubleRect> tmpStack = plot_zoomer->zoomStack();
    9.  
    10. // get rid of the latest non scaled rectangle
    11. tmpStack.pop();
    12.  
    13. // add rescaled rectangle
    14. tmpStack.push(boundRect);
    15.  
    16. plot_zoomer->setZoomStack(tmpStack);
    17.  
    18. replot();
    19.  
    20. // doesn't work, rescales back to original
    21. plot_zoomer->moveBy(valdx,0);
    To copy to clipboard, switch view to plain text mode 

  5. #5

    Default Re: Axis won't stay at new scale setting

    Anyone?

  6. #6

    Default Re: Axis won't stay at new scale setting

    Uwe,

    Thanks again! I fixed the problem. A few notes for anyone else who may face
    issues here:

    1) setZoomStack() function does not take affect until setMaxStackDepth() is used
    on a zoomer with some random value. This may be a bug that is fixed in a later
    version.

    2) Flicker issue fixed by removing zoom(-1) and instead grabbing the zoomer
    stack, popping the top rectangle and pushing an updated ractangle, then doing
    setZoomStack()

    Some sample code below,

    // setup zoomer
    symbol_canvas = canvas();

    plot_zoomer = new QwtPlotZoomer(symbol_canvas);

    // set maxstackdepth to make setzoomstack function work
    plot_zoomer->setMaxStackDepth(50);

    QwtScaleDiv * xscalediv = axisScaleDiv(QwtPlot::xBottom);

    double rleft = xscalediv->lBound(); // lowerBound() in later qwt version

    double rtop = lowPlotY; // a variable set earlier

    double rwidth = xscalediv->hBound() - xscalediv->lBound(); // upperBound() in
    later qwt version

    double rheight = highPlotY - lowPlotY;

    // create a new rectangle
    QwtDoubleRect boundRect(rleft, rtop, rwidth, rheight);

    // grab the zoomer stack
    QStack<QwtDoubleRect> tmpStack = plot_zoomer->zoomStack();

    // get rid of the current rectangle
    tmpStack.pop();

    // push the updated rectangle
    tmpStack.push(boundRect);

    // set the new stack
    plot_zoomer->setZoomStack(tmpStack);

Similar Threads

  1. Setting scale proportion
    By KosyakOFF in forum Qwt
    Replies: 0
    Last Post: 8th May 2008, 05:28
  2. qwtscalewidget: setting scale to the widget..
    By halberdier83 in forum Qwt
    Replies: 3
    Last Post: 4th December 2007, 08:08

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.