Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / libs / qwt / src / qwt_plot_zoomer.h
blob1bc05b46a86671dd24001d40d194f2cd3b571670
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
10 #ifndef QWT_PLOT_ZOOMER_H
11 #define QWT_PLOT_ZOOMER_H
13 #include "qwt_global.h"
14 #include "qwt_plot_picker.h"
15 #include <qstack.h>
17 /*!
18 \brief QwtPlotZoomer provides stacked zooming for a plot widget
20 QwtPlotZoomer selects rectangles from user inputs ( mouse or keyboard )
21 translates them into plot coordinates and adjusts the axes to them.
22 The selection is supported by a rubber band and optionally by displaying
23 the coordinates of the current mouse position.
25 Zooming can be repeated as often as possible, limited only by
26 maxStackDepth() or minZoomSize(). Each rectangle is pushed on a stack.
28 The default setting how to select rectangles is
29 a QwtPickerDragRectMachine with the following bindings:
31 - QwtEventPattern::MouseSelect1\n
32 The first point of the zoom rectangle is selected by a mouse press,
33 the second point from the position, where the mouse is released.
35 - QwtEventPattern::KeySelect1\n
36 The first key press selects the first, the second key press
37 selects the second point.
39 - QwtEventPattern::KeyAbort\n
40 Discard the selection in the state, where the first point
41 is selected.
43 To traverse the zoom stack the following bindings are used:
45 - QwtEventPattern::MouseSelect3, QwtEventPattern::KeyUndo\n
46 Zoom out one position on the zoom stack
48 - QwtEventPattern::MouseSelect6, QwtEventPattern::KeyRedo\n
49 Zoom in one position on the zoom stack
51 - QwtEventPattern::MouseSelect2, QwtEventPattern::KeyHome\n
52 Zoom to the zoom base
54 The setKeyPattern() and setMousePattern() functions can be used
55 to configure the zoomer actions. The following example
56 shows, how to configure the 'I' and 'O' keys for zooming in and out
57 one position on the zoom stack. The "Home" key is used to
58 "unzoom" the plot.
60 \code
61 zoomer = new QwtPlotZoomer( plot );
62 zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier );
63 zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier );
64 zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home );
65 \endcode
67 QwtPlotZoomer is tailored for plots with one x and y axis, but it is
68 allowed to attach a second QwtPlotZoomer ( without rubber band and tracker )
69 for the other axes.
71 \note The realtime example includes an derived zoomer class that adds
72 scrollbars to the plot canvas.
74 \sa QwtPlotPanner, QwtPlotMagnifier
77 class QWT_EXPORT QwtPlotZoomer: public QwtPlotPicker
79 Q_OBJECT
80 public:
81 explicit QwtPlotZoomer( QWidget *, bool doReplot = true );
82 explicit QwtPlotZoomer( int xAxis, int yAxis,
83 QWidget *, bool doReplot = true );
85 virtual ~QwtPlotZoomer();
87 virtual void setZoomBase( bool doReplot = true );
88 virtual void setZoomBase( const QRectF & );
90 QRectF zoomBase() const;
91 QRectF zoomRect() const;
93 virtual void setAxis( int xAxis, int yAxis );
95 void setMaxStackDepth( int );
96 int maxStackDepth() const;
98 const QStack<QRectF> &zoomStack() const;
99 void setZoomStack( const QStack<QRectF> &,
100 int zoomRectIndex = -1 );
102 uint zoomRectIndex() const;
104 public Q_SLOTS:
105 void moveBy( double x, double y );
106 virtual void moveTo( const QPointF & );
108 virtual void zoom( const QRectF & );
109 virtual void zoom( int up );
111 Q_SIGNALS:
113 A signal emitting the zoomRect(), when the plot has been
114 zoomed in or out.
116 \param rect Current zoom rectangle.
119 void zoomed( const QRectF &rect );
121 protected:
122 virtual void rescale();
124 virtual QSizeF minZoomSize() const;
126 virtual void widgetMouseReleaseEvent( QMouseEvent * );
127 virtual void widgetKeyPressEvent( QKeyEvent * );
129 virtual void begin();
130 virtual bool end( bool ok = true );
131 virtual bool accept( QPolygon & ) const;
133 private:
134 void init( bool doReplot );
136 class PrivateData;
137 PrivateData *d_data;
140 #endif