Results 1 to 3 of 3

Thread: Zooming two plots simultaneously

  1. #1
    Join Date
    May 2009
    Posts
    20
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Zooming two plots simultaneously

    I am currently trying to allow two plots (each with the same starting x and y axes and zoom base) to zoom the same amount regardless of which plot is being zoomed in or out.

    Currently I have the code below:
    Qt Code:
    1. zoomerA = new QwtPlotZoomer(plotA->canvas());
    2. zoomerA->setMaxStackDepth(5);
    3.  
    4. zoomerB = new QwtPlotZoomer(plotB->canvas());
    5. zoomerB->setMaxStackDepth(5);
    6.  
    7. connect(zoomerA,SIGNAL(zoomed(const QwtDoubleRect&)),SLOT(updateBZoom()));
    8. connect(zoomerB,SIGNAL(zoomed(const QwtDoubleRect&)),SLOT(updateAZoom()));
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void graphPage::updateBZoom()
    2. {
    3. zoomerB->setZoomStack(zoomerA->zoomStack(),zoomerA->zoomRectIndex());
    4. }
    5.  
    6. void graphPage::updateAZoom()
    7. { zoomerA->setZoomStack(zoomerB->zoomStack(),zoomerB->zoomRectIndex());
    8. }
    To copy to clipboard, switch view to plain text mode 

    With this code it almost works until you get to the last rect in the stack. setZoomStack fails since zoomStack.count() == maxStackDepth() + 1 at this point.

    Is this as simple as changing the code in the setZoomStack function from:
    Qt Code:
    1. if ( d_data->maxStackDepth >= 0 &&
    2. int(zoomStack.count()) > d_data->maxStackDepth )
    3. {
    4. return;
    5. }
    To copy to clipboard, switch view to plain text mode 

    to

    Qt Code:
    1. if ( d_data->maxStackDepth >= 0 &&
    2. int(zoomStack.count()) > d_data->maxStackDepth + 1 )
    3. {
    4. return;
    5. }
    To copy to clipboard, switch view to plain text mode 

    Or am I going about this completely the wrong way?

  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: Zooming two plots simultaneously

    See http://qwt.sourceforge.net/class_qwt...7ba91d6de3a882

    By setting an upper limit for the zoomstack depth you can try to avoid effects like scales with tick labels that differ below the significance of a double. Then assigning a complete stack with a deeper depth is not allowed.

    I guess you misunderstood of the meaning of QwtPlotZoomer::setMaxStackDepth() ?

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    Ban-chan (2nd September 2009)

  4. #3
    Join Date
    May 2009
    Posts
    20
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Zooming two plots simultaneously

    Quote Originally Posted by Uwe View Post
    See http://qwt.sourceforge.net/class_qwt...7ba91d6de3a882

    By setting an upper limit for the zoomstack depth you can try to avoid effects like scales with tick labels that differ below the significance of a double. Then assigning a complete stack with a deeper depth is not allowed.

    I guess you misunderstood of the meaning of QwtPlotZoomer::setMaxStackDepth() ?

    Uwe
    Ah alrighty. I simply removed the setMaxStackDepth parameters from my zoomers and all is working fine now.

Similar Threads

  1. Replies: 4
    Last Post: 21st March 2009, 13:51
  2. Replies: 4
    Last Post: 15th October 2008, 13:24
  3. Scaling and zooming with logarithmic scales
    By Benoît Hubert in forum Qwt
    Replies: 1
    Last Post: 11th September 2008, 09:17

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.