Results 1 to 6 of 6

Thread: Zooming on PushButton Press event

  1. #1
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Zooming on PushButton Press event

    Hi there. I looked through QWT docs but didn't find good example of how I can perform zooming: idea is simple - make zooming on QPushbutton pressEvent like one, which perform when I use a mousewheel.

    Right now I use some buggy code like this:

    Zoom in example

    if (myPlot->axisEnabled(QwtPlot::yLeft))
    {
    QwtDoubleRect tempQwtRect(myPlotZoomer[0]->zoomRect());
    tempQwtRect.setWidth(tempQwtRect.width()/1.1);
    tempQwtRect.setHeight(tempQwtRect.height()/1.1);
    myPlotZoomer[0]->zoom(tempQwtRect);
    }
    if (myPlot->axisEnabled(QwtPlot::yRight))
    {
    QwtDoubleRect tempQwtRect2(myPlotZoomer[1]->zoomRect());
    tempQwtRect2.setWidth(tempQwtRect2.width()/1.1);
    tempQwtRect2.setHeight(tempQwtRect2.height()/1.1);
    myPlotZoomer[1]->zoom(tempQwtRect2);
    }

    but it goes downward and left form centre. Thanks for your answers beforehand.

  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 on PushButton Press event

    Hi there. I looked through QWT docs but didn't find good example of how I can perform zooming:
    Have a look at QwtPlotZoomer, QwtPlotPanner and QwtPlotMagnifier. These classes should offer all, what you need to implement your own flavour of navigation.
    idea is simple - make zooming on QPushbutton pressEvent like one, which perform when I use a mousewheel.
    QwtPlotMagnifier::rescale handles wheel events. If you don't want to use the Qwt navigation helpers, you can simply copy + adopt the code into the slot, that is connected to your pushbutton.

    Uwe

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

    KosyakOFF (10th April 2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Zooming on PushButton Press event

    Thanks Uwe, copying + adopting the code into the slot helped to solve the problem .

  5. #4
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Zooming on PushButton Press event

    I will ask another question in this thread, because it's connected with previous one - I perform some smoothing algorithm on data, which is used to form a curve.

    After updating curbve data and doing the plot->replot() QWT automaticly recalculates scales and in some occasions changes the zoom.

    So it looks like this: I set a smoothing parameter in new dialog window and press Apply button (dialog not closing so I can press Apply many times to observe recent changes in curve structure). But rezooming of the plot spoils the proccess, because it's becoming not so clear what effect was after I pressed Apply last time.

    Sorry if I described situation not so well. =(

  6. #5
    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 on PushButton Press event

    Quote Originally Posted by KosyakOFF View Post
    After updating curve data and doing the plot->replot() QWT automaticly recalculates scales ...
    Only, when autoscaling is enabled. As soon as you assign specific scales ( f.e when zooming) autoscaling gets disabled.

    Uwe

  7. #6
    Join Date
    Apr 2008
    Posts
    32
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: Zooming on PushButton Press event

    Thank you very much, gee... I forgot to turn autoscaling off

Similar Threads

  1. Replies: 1
    Last Post: 24th October 2007, 18:34
  2. Draw QtCanvasElipse on mouse press event position
    By YuriyRusinov in forum Newbie
    Replies: 1
    Last Post: 31st May 2006, 11:57

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.