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
20class QwtText;
21class QWidget;
22class QMouseEvent;
23class QWheelEvent;
24class QKeyEvent;
25class QPainter;
26class QPen;
27class QFont;
28class QRegion;
29class QPainterPath;
30class QPoint;
31class QRect;
32class QSize;
33class QPolygon;
34
103class QWT_EXPORT QwtPicker : public QObject, public QwtEventPattern
104{
105 Q_OBJECT
106
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:
128 {
130 NoRubberBand = 0,
131
134
137
140
143
146
149
154 UserRubberBand = 100
155 };
156
162 {
165
168
170 ActiveOnly
171 };
172
182 {
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
A collection of event patterns.
QwtPicker provides selections on a widget.
Definition qwt_picker.h:104
DisplayMode
Display mode.
Definition qwt_picker.h:162
@ AlwaysOn
Display always.
Definition qwt_picker.h:167
@ AlwaysOff
Display never.
Definition qwt_picker.h:164
void selected(const QPolygon &polygon)
void activated(bool on)
@ VLineRubberBand
A vertical line ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:136
@ CrossRubberBand
A crosshair ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:139
@ EllipseRubberBand
An ellipse ( only for QwtPickerMachine::RectSelection )
Definition qwt_picker.h:145
@ PolygonRubberBand
A polygon ( only for QwtPickerMachine::PolygonSelection )
Definition qwt_picker.h:148
@ HLineRubberBand
A horizontal line ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:133
@ RectRubberBand
A rectangle ( only for QwtPickerMachine::RectSelection )
Definition qwt_picker.h:142
@ Stretch
All points are scaled according to the new size,.
Definition qwt_picker.h:184
void appended(const QPoint &pos)
void moved(const QPoint &pos)
void removed(const QPoint &pos)
void changed(const QPolygon &selection)
A state machine for QwtPicker selections.
A class representing a text.
Definition qwt_text.h:52
An overlay for a widget.