Results 1 to 4 of 4

Thread: QwtPlotMagnifier zooming around the mouse pointer

  1. #1
    Join Date
    Feb 2012
    Location
    Stuttgart / Germany
    Posts
    35
    Thanks
    6
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QwtPlotMagnifier zooming around the mouse pointer

    Hello,

    I have a qwtPlot with 8 QwtPlotCurve, each one has a QwtPlotMagnifier to perform the zoom in/out on my y axes. I would like to change the behaviour and zoom in and out around my mouse position.

    It is working fine now, but when I zoom in it can happen that my curve goes out of the screen and the user needs to scroll to bring it back, and then I wanted to zoom around the mouse position to avoid this kind of behaviour.
    Is there any way with QwtPlotMagnifier to do that? I didn't find anything in documentation that make possible to consider mouse position.

    I hope someone can help me.
    Thanks in advance.
    Best Regards.

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

    Default Re: QwtPlotMagnifier zooming around the mouse pointer

    Such a mode is not implemented, but isn't very hard to implement. You could derive from QwtPlotMagnifier overloading the following 2 methods:

    widgetWheelEvent to store the mouse position
    rescale, where you implement zooming around the mouse poistion

    Starting with the code from QwtPlotMagnifier ::rescale should help.

    Uwe

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

    cesroc (12th August 2014)

  4. #3
    Join Date
    Feb 2012
    Location
    Stuttgart / Germany
    Posts
    35
    Thanks
    6
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: QwtPlotMagnifier zooming around the mouse pointer

    Hello Uwe,

    Thanks a lot. I found a different way of doing. I install an event filter in my axis and I handle the wheel event.
    It works fine for a normal zooming in and out, but I didn't find the right calculation to have it around the mouse pointer.
    I have the mouse position and everything I need but I didn't figure out yet how to calculate to have the zoom around the pointer.
    Can you help me on that? Do you have an example?

    Thanks in advance.
    Best Regards.

  5. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,228
    Thanked 854 Times in 803 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotMagnifier zooming around the mouse pointer

    Using the maps from QwtPlot::canvasMap() you can translate between widget ( canvas ) and plot coordinates.

    Uwe

    Using the maps from QwtPlot::canvasMap() you can translate between widget ( canvas ) and plot coordinates.

    Uwe

Similar Threads

  1. zooming with ctrl + mouse wheel
    By alperyazir66 in forum Qwt
    Replies: 2
    Last Post: 19th May 2015, 11:46
  2. Smooth zooming with mouse pointer as center
    By gaganbm in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2013, 11:02
  3. Replies: 3
    Last Post: 22nd February 2013, 19:56
  4. zooming when mouse hovers axis-label
    By Andreas in forum Qwt
    Replies: 3
    Last Post: 12th December 2011, 09:04
  5. Replies: 6
    Last Post: 4th November 2011, 06:51

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.