Qwt User's Guide 6.3.0

Loading...
Searching...
No Matches
qwt_picker.h
1/******************************************************************************
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_PICKER
11#define QWT_PICKER
12
13#include "qwt_global.h"
14#include "qwt_event_pattern.h"
15
16#include <qobject.h>
17
18 class QwtPickerMachine;
19 class QwtWidgetOverlay;
20 class QwtText;
21 class QWidget;
22 class QMouseEvent;
23 class QWheelEvent;
24 class QKeyEvent;
25 class QPainter;
26 class QPen;
27 class QFont;
28 class QRegion;
29 class QPainterPath;
30 class QPoint;
31 class QRect;
32 class QSize;
33 class QPolygon;
34
103 class QWT_EXPORT QwtPicker : public QObject, public QwtEventPattern
104{
105 Q_OBJECT
106
107 Q_ENUMS( RubberBand DisplayMode ResizeMode )
108
109 Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled )
110 Q_PROPERTY( ResizeMode resizeMode READ resizeMode WRITE setResizeMode )
111
112 Q_PROPERTY( DisplayMode trackerMode READ trackerMode WRITE setTrackerMode )
113 Q_PROPERTY( QPen trackerPen READ trackerPen WRITE setTrackerPen )
114 Q_PROPERTY( QFont trackerFont READ trackerFont WRITE setTrackerFont )
115
116 Q_PROPERTY( RubberBand rubberBand READ rubberBand WRITE setRubberBand )
117 Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen )
118
119 public:
127 enum RubberBand
128 {
130 NoRubberBand = 0,
131
133 HLineRubberBand,
134
136 VLineRubberBand,
137
139 CrossRubberBand,
140
142 RectRubberBand,
143
145 EllipseRubberBand,
146
148 PolygonRubberBand,
149
154 UserRubberBand = 100
155 };
156
161 enum DisplayMode
162 {
164 AlwaysOff,
165
167 AlwaysOn,
168
170 ActiveOnly
171 };
172
181 enum ResizeMode
182 {
184 Stretch,
185
187 KeepSize
188 };
189
190 explicit QwtPicker( QWidget* parent );
191 explicit QwtPicker( RubberBand rubberBand,
192 DisplayMode trackerMode, QWidget* );
193
194 virtual ~QwtPicker();
195
196 void setStateMachine( QwtPickerMachine* );
197 const QwtPickerMachine* stateMachine() const;
198 QwtPickerMachine* stateMachine();
199
200 void setRubberBand( RubberBand );
201 RubberBand rubberBand() const;
202
203 void setTrackerMode( DisplayMode );
204 DisplayMode trackerMode() const;
205
206 void setResizeMode( ResizeMode );
207 ResizeMode resizeMode() const;
208
209 void setRubberBandPen( const QPen& );
210 QPen rubberBandPen() const;
211
212 void setTrackerPen( const QPen& );
213 QPen trackerPen() const;
214
215 void setTrackerFont( const QFont& );
216 QFont trackerFont() const;
217
218 bool isEnabled() const;
219 bool isActive() const;
220
221 virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE;
222
223 QWidget* parentWidget();
224 const QWidget* parentWidget() const;
225
226 virtual QPainterPath pickArea() const;
227
228 virtual void drawRubberBand( QPainter* ) const;
229 virtual void drawTracker( QPainter* ) const;
230
231 virtual QRegion trackerMask() const;
232 virtual QRegion rubberBandMask() const;
233
234 virtual QwtText trackerText( const QPoint& pos ) const;
235 QPoint trackerPosition() const;
236 virtual QRect trackerRect( const QFont& ) const;
237
238 QPolygon selection() const;
239
240 public Q_SLOTS:
241 void setEnabled( bool );
242
243 Q_SIGNALS:
251 void activated( bool on );
252
259 void selected( const QPolygon& polygon );
260
267 void appended( const QPoint& pos );
268
276 void moved( const QPoint& pos );
277
285 void removed( const QPoint& pos );
293 void changed( const QPolygon& selection );
294
295 protected:
296 virtual QPolygon adjustedPoints( const QPolygon& ) const;
297
298 virtual void transition( const QEvent* );
299
300 virtual void begin();
301 virtual void append( const QPoint& );
302 virtual void move( const QPoint& );
303 virtual void remove();
304 virtual bool end( bool ok = true );
305
306 virtual bool accept( QPolygon& ) const;
307 virtual void reset();
308
309 virtual void widgetMousePressEvent( QMouseEvent* );
310 virtual void widgetMouseReleaseEvent( QMouseEvent* );
311 virtual void widgetMouseDoubleClickEvent( QMouseEvent* );
312 virtual void widgetMouseMoveEvent( QMouseEvent* );
313 virtual void widgetWheelEvent( QWheelEvent* );
314 virtual void widgetKeyPressEvent( QKeyEvent* );
315 virtual void widgetKeyReleaseEvent( QKeyEvent* );
316 virtual void widgetEnterEvent( QEvent* );
317 virtual void widgetLeaveEvent( QEvent* );
318
319 virtual void stretchSelection(
320 const QSize& oldSize, const QSize& newSize );
321
322 virtual void updateDisplay();
323
324 const QwtWidgetOverlay* rubberBandOverlay() const;
325 const QwtWidgetOverlay* trackerOverlay() const;
326
327 const QPolygon& pickedPoints() const;
328 QRect trackerRect( const QSize& ) const;
329
330 private:
331 void init( QWidget*, RubberBand rubberBand, DisplayMode trackerMode );
332
333 void setMouseTracking( bool );
334
335 class PrivateData;
336 PrivateData* m_data;
337};
338
339#endif
QwtEventPattern
A collection of event patterns.
Definition qwt_event_pattern.h:31
QwtPicker
QwtPicker provides selections on a widget.
Definition qwt_picker.h:104
QwtPicker::DisplayMode
DisplayMode
Display mode.
Definition qwt_picker.h:162
QwtPicker::AlwaysOn
@ AlwaysOn
Display always.
Definition qwt_picker.h:167
QwtPicker::AlwaysOff
@ AlwaysOff
Display never.
Definition qwt_picker.h:164
QwtPicker::selected
void selected(const QPolygon &polygon)
QwtPicker::activated
void activated(bool on)
QwtPicker::RubberBand
RubberBand
Definition qwt_picker.h:128
QwtPicker::VLineRubberBand
@ VLineRubberBand
A vertical line ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:136
QwtPicker::CrossRubberBand
@ CrossRubberBand
A crosshair ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:139
QwtPicker::EllipseRubberBand
@ EllipseRubberBand
An ellipse ( only for QwtPickerMachine::RectSelection )
Definition qwt_picker.h:145
QwtPicker::PolygonRubberBand
@ PolygonRubberBand
A polygon ( only for QwtPickerMachine::PolygonSelection )
Definition qwt_picker.h:148
QwtPicker::HLineRubberBand
@ HLineRubberBand
A horizontal line ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:133
QwtPicker::RectRubberBand
@ RectRubberBand
A rectangle ( only for QwtPickerMachine::RectSelection )
Definition qwt_picker.h:142
QwtPicker::ResizeMode
ResizeMode
Definition qwt_picker.h:182
QwtPicker::Stretch
@ Stretch
All points are scaled according to the new size,.
Definition qwt_picker.h:184
QwtPicker::appended
void appended(const QPoint &pos)
QwtPicker::moved
void moved(const QPoint &pos)
QwtPicker::removed
void removed(const QPoint &pos)
QwtPicker::changed
void changed(const QPolygon &selection)
QwtPickerMachine
A state machine for QwtPicker selections.
Definition qwt_picker_machine.h:29
QwtText
A class representing a text.
Definition qwt_text.h:52
QwtWidgetOverlay
An overlay for a widget.
Definition qwt_widget_overlay.h:41