Results 1 to 4 of 4

Thread: Synchronizing zoom settings between QwtPlotZoomer and QwtPlotMagnifier for a touch

  1. #1
    Join Date
    Nov 2010
    Posts
    122
    Thanks
    62
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Smile Synchronizing zoom settings between QwtPlotZoomer and QwtPlotMagnifier for a touch

    Synchronizing zoom settings between QwtPlotZoomer and QwtPlotMagnifier for a touchscreen interfaceplot.jpg

    I have an application which uses a class derived from
    QwtPlot. It is for a touchscreen interface, so separation
    of events associated with a mouse (such as left, middle, or
    right buttons or scroller) do not apply. See the attached
    screenshot for some idea of the layout and control buttons for the plot.

    I need to provide support for three types of zooming, roughly
    analogous in behavior of QwtPlotZoomer, QwtPlotPanner, and
    QwtPlotMagnifier.

    There are three operating modes for zooming based on the control
    button selected from the UI, which are from left to right in the
    screenshot:

    Zoom Mode
    Pan Mode
    Zoom Extent
    Zoom In
    Zoom Out

    The zoom "mode" is selected by either the Zoom or Pan mode buttons
    which are mutually exclusive. These seem to work fine, I can zoom
    in with the rectangle and pan with the mouse. The setEnabled methods
    on these classes allows for mutually exclusive behavior.

    Now my question has to do with how to implement zoom in and zoom out
    in concert with the existing zoom value from using the zoom rectangle,
    that is keeping these settings somewhat synchronized.

    How can I determine the zoom factor that is currently active as a
    function of using the zoom rectangle as the beginning point or scale
    factor to use when selecting either Zoom In or Zoom Out?
    I need to be able to zoom in and out from this active setting.

    Since the rescale() method of QwtPlotMagnifier is private, I assume
    I need to derive from this class and create a method for my implementation,
    and perhaps customize its behavior.

    Anybody try something like this or have any general direction?

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

    Default Re: Synchronizing zoom settings between QwtPlotZoomer and QwtPlotMagnifier for a touc

    Quote Originally Posted by bob2oneil View Post
    How can I determine the zoom factor that is currently active as a function of using the zoom rectangle as the beginning point or scale factor to use when selecting either Zoom In or Zoom Out?
    The zoomer has the zoom stack, what is the list of rectangles in the zoom history. The zoom base ( the first entry in this list ) is your "beginning point". If you want to have the rectangles of the panning in the zoom stack ( zoom forward/backward ) too you have to manipulate the stack manually.

    Don't use QwtPlotMagnifier as long as you are not interested in its wheel and mouse handling. Instead implement your own scaling using QwtPlot::axisScaleDiv() and QwtPlot::setAxisScale(). It makes sense to copy the code of QwtPlotMagnifier::rescale to your application - it doesn't depend on the rest of the class.

    Uwe

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

    bob2oneil (17th May 2011)

  4. #3
    Join Date
    Nov 2010
    Posts
    122
    Thanks
    62
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Cool Re: Synchronizing zoom settings between QwtPlotZoomer and QwtPlotMagnifier for a touc

    Hi Uwe, I have a rescale copied from the QwtPlotMagnifier class in place. My implementation for ZoomIn and ZoomOut are as follows. My intention was to keep a scale factor, and basically change by 10% for zoom in/out. What I am noticing in practice with this approach, is that the zoom does not behave as I would expect. For example, if I zoom in 4 times, and zoom out 4 times, I am not often back to where I begin. This is exclusive of the zoom rectangle implementation. Perhaps this approach is not the best. Any thoughts on improving this approach?

    Qt Code:
    1. void Plot::zoomIn()
    2. {
    3. m_scaleFactor -= .1;
    4. if (m_scaleFactor < 0)
    5. m_scaleFactor = 0;
    6.  
    7. rescale(m_scaleFactor);
    8. }
    9.  
    10. void Plot::zoomOut()
    11. {
    12. m_scaleFactor += .1;
    13. //if (m_scaleFactor > 1.0)
    14. // m_scaleFactor = 1.0;
    15.  
    16. rescale(m_scaleFactor);
    17. }
    To copy to clipboard, switch view to plain text mode 

  5. #4
    Join Date
    Nov 2010
    Posts
    122
    Thanks
    62
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Synchronizing zoom settings between QwtPlotZoomer and QwtPlotMagnifier for a touc

    I have a working implementation inspired by Uwe's QMagnifier code base as follows where the zoom factor correspond to the keyFactor in the magnifier class. My personal thanks to Uwe for all of the fine work done on QWT. This type of generous contributions of time and effort to the broader Qt community is often not recognized enough. I can only imagine the amount of many hours/years devoted to Qwt and that of all the support in this forum on Qwt.


    Qt Code:
    1. void Plot::zoomIn()
    2. {
    3. rescale(m_zoomFactor);
    4. }
    5.  
    6. void Plot::zoomOut()
    7. {
    8. rescale(1.0 / m_zoomFactor);
    9. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 21st May 2013, 11:43
  2. Replies: 3
    Last Post: 10th October 2011, 17:55
  3. Replies: 1
    Last Post: 13th May 2011, 19:12
  4. QwtPlotMagnifier initial zoom
    By jomarin in forum Qwt
    Replies: 6
    Last Post: 6th May 2010, 09:29
  5. QwtPlotMagnifier Invert Wheel Zoom
    By jmsbc in forum Qwt
    Replies: 2
    Last Post: 13th March 2009, 00:12

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.