source: ntrip/trunk/BNC/qwt/qwt_plot_zoomer.h@ 10573

Last change on this file since 10573 was 9383, checked in by stoecker, 4 years ago

update to qwt verion 6.1.1 to fix build with newer Qt5

File size: 4.2 KB
Line 
1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
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 *****************************************************************************/
9
10#ifndef QWT_PLOT_ZOOMER_H
11#define QWT_PLOT_ZOOMER_H
12
13#include "qwt_global.h"
14#include "qwt_plot_picker.h"
15#include <qstack.h>
16
17/*!
18 \brief QwtPlotZoomer provides stacked zooming for a plot widget
19
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.
24
25 Zooming can be repeated as often as possible, limited only by
26 maxStackDepth() or minZoomSize(). Each rectangle is pushed on a stack.
27
28 The default setting how to select rectangles is
29 a QwtPickerDragRectMachine with the following bindings:
30
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.
34
35 - QwtEventPattern::KeySelect1\n
36 The first key press selects the first, the second key press
37 selects the second point.
38
39 - QwtEventPattern::KeyAbort\n
40 Discard the selection in the state, where the first point
41 is selected.
42
43 To traverse the zoom stack the following bindings are used:
44
45 - QwtEventPattern::MouseSelect3, QwtEventPattern::KeyUndo\n
46 Zoom out one position on the zoom stack
47
48 - QwtEventPattern::MouseSelect6, QwtEventPattern::KeyRedo\n
49 Zoom in one position on the zoom stack
50
51 - QwtEventPattern::MouseSelect2, QwtEventPattern::KeyHome\n
52 Zoom to the zoom base
53
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.
59
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
66
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.
70
71 \note The realtime example includes an derived zoomer class that adds
72 scrollbars to the plot canvas.
73
74 \sa QwtPlotPanner, QwtPlotMagnifier
75*/
76
77class QWT_EXPORT QwtPlotZoomer: public QwtPlotPicker
78{
79 Q_OBJECT
80public:
81 explicit QwtPlotZoomer( QWidget *, bool doReplot = true );
82 explicit QwtPlotZoomer( int xAxis, int yAxis,
83 QWidget *, bool doReplot = true );
84
85 virtual ~QwtPlotZoomer();
86
87 virtual void setZoomBase( bool doReplot = true );
88 virtual void setZoomBase( const QRectF & );
89
90 QRectF zoomBase() const;
91 QRectF zoomRect() const;
92
93 virtual void setAxis( int xAxis, int yAxis );
94
95 void setMaxStackDepth( int );
96 int maxStackDepth() const;
97
98 const QStack<QRectF> &zoomStack() const;
99 void setZoomStack( const QStack<QRectF> &,
100 int zoomRectIndex = -1 );
101
102 uint zoomRectIndex() const;
103
104public Q_SLOTS:
105 void moveBy( double dx, double dy );
106 virtual void moveTo( const QPointF & );
107
108 virtual void zoom( const QRectF & );
109 virtual void zoom( int offset );
110
111Q_SIGNALS:
112 /*!
113 A signal emitting the zoomRect(), when the plot has been
114 zoomed in or out.
115
116 \param rect Current zoom rectangle.
117 */
118
119 void zoomed( const QRectF &rect );
120
121protected:
122 virtual void rescale();
123
124 virtual QSizeF minZoomSize() const;
125
126 virtual void widgetMouseReleaseEvent( QMouseEvent * );
127 virtual void widgetKeyPressEvent( QKeyEvent * );
128
129 virtual void begin();
130 virtual bool end( bool ok = true );
131 virtual bool accept( QPolygon & ) const;
132
133private:
134 void init( bool doReplot );
135
136 class PrivateData;
137 PrivateData *d_data;
138};
139
140#endif
Note: See TracBrowser for help on using the repository browser.