Results 1 to 5 of 5

Thread: Double-Click Zoom out feature

  1. #1
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Double-Click Zoom out feature

    I'm attempting to implement a double-click zoom out feature to mimic Matlab behavior. I've successfully implemented a custom QwtPickerClickPointMachine which catches the double-click of mouse button 1 and I can perform the necessary actions.

    My problem is I still need the zoom capability provided in the QwtPlotZoomer class which I think uses the QwtPickerDragRectMachine as the QwtPickerMachine. When I use the setStateMachine() method on the zoomer instance it replaces the current QwtPickerMachine with my custom PickerMachine, which is exactly as I would expect based on documentation. So I gain my double-click functionality but lose the zoom functionality.

    So my question is how do I use the functionality provided in my custom Picker Machine and the QwtPickerDragRectMachine at the same time within my QwtPlotZoomer? Or is there a much easier approach that I'm just overlooking.

    Any advice is appreciated.
    Thanks!

    FYI: working with qwt6.0.0_rc5

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Double-Click Zoom out feature

    why don't you use a QwtPlotZoomer and call "zoom(0)" when you want to zoom out? your approach sounds a bit complicated to me...

  3. #3
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Double-Click Zoom out feature

    I agree it seems complicated, but customer has requested the double-click zoom out capability because their users are so familiar with current Matlab plot functionality.

    I am already using a zoomer that I pulled and modified slightly from one of the examples:
    Qt Code:
    1. // LeftButton for the zooming
    2. // MidButton for the panning
    3. // RightButton: zoom out by 1
    4. // Ctrl+RightButton: zoom out to full size
    5.  
    6. QwtPlotZoomer* zoomer = new QwtPlotZoomer(canvas());
    7. zoomer->setRubberBandPen(QColor(Qt::red));
    8. zoomer->setTrackerPen(QColor(Qt::red));
    9. zoomer->setMousePattern(QwtEventPattern::MouseSelect2,
    10. Qt::RightButton, Qt::ControlModifier);
    11. zoomer->setMousePattern(QwtEventPattern::MouseSelect3,
    12. Qt::RightButton);
    To copy to clipboard, switch view to plain text mode 

    Now I'm trying to somehow 'capture' a Qt::LeftButton double-click which will then use zoom(0) as you mention.

  4. #4
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Double-Click Zoom out feature

    zooming out via double click is nothing complicated just your ideas with statemachines etc...

    install an event filter on your canvas and react on the doubleclick event. that's the way I do it...

  5. The following user says thank you to FelixB for this useful post:

    novackb (31st January 2011)

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

    Default Re: Double-Click Zoom out feature

    Quote Originally Posted by novackb View Post
    Now I'm trying to somehow 'capture' a Qt::LeftButton double-click which will then use zoom(0) as you mention.
    Qt Code:
    1. class YourZoomer: public QwtPlotZoomer
    2. {
    3. YourZoomer( ... )
    4. {
    5. // disable MouseSelect2 ( default for zooming out )
    6. setMousePattern(QwtEventPattern::MouseSelect2, Qt::NoButton );
    7. }
    8. ...
    9. virtual void widgetMouseDoubleClickEvent( QMouseEvent *me )
    10. {
    11. if ( me->button() == ... )
    12. zoom( 0 );
    13. }
    14. };
    To copy to clipboard, switch view to plain text mode 

    Untested,
    Uwe

  7. The following 2 users say thank you to Uwe for this useful post:

    FelixB (8th February 2011), novackb (1st February 2011)

Similar Threads

  1. Replies: 6
    Last Post: 5th June 2009, 09:38
  2. Replies: 2
    Last Post: 11th January 2009, 23:24
  3. Double click distance
    By jbd in forum Qt Programming
    Replies: 3
    Last Post: 28th December 2007, 22:13
  4. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 04:32
  5. Replies: 5
    Last Post: 12th January 2006, 15:40

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.