Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_picker.h
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (4 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_picker.h (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_picker.h
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 9 9 10 10 #ifndef QWT_PICKER 11 #define QWT_PICKER 111 #define QWT_PICKER 12 12 13 13 #include "qwt_global.h" 14 #include "qwt_text.h"15 14 #include "qwt_event_pattern.h" 15 16 16 #include <qobject.h> 17 #include <qpen.h> 18 #include <qfont.h> 19 #include <qrect.h> 20 #include <qpainterpath.h> 21 17 18 class QwtPickerMachine; 19 class QwtWidgetOverlay; 20 class QwtText; 22 21 class QWidget; 23 22 class QMouseEvent; 24 23 class QWheelEvent; 25 24 class QKeyEvent; 26 class QwtPickerMachine; 27 class QwtWidgetOverlay; 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; 28 34 29 35 /*! 30 \brief QwtPicker provides selections on a widget 31 32 QwtPicker filters all enter, leave, mouse and keyboard events of a widget 33 and translates them into an array of selected points. 34 35 The way how the points are collected depends on type of state machine 36 that is connected to the picker. Qwt offers a couple of predefined 37 state machines for selecting: 38 39 - Nothing\n 36 \brief QwtPicker provides selections on a widget 37 38 QwtPicker filters all enter, leave, mouse and keyboard events of a widget 39 and translates them into an array of selected points. 40 41 The way how the points are collected depends on type of state machine 42 that is connected to the picker. Qwt offers a couple of predefined 43 state machines for selecting: 44 45 - Nothing\n 40 46 QwtPickerTrackerMachine 41 - Single points\n 47 - Single points\n 42 48 QwtPickerClickPointMachine, QwtPickerDragPointMachine 43 - Rectangles\n 49 - Rectangles\n 44 50 QwtPickerClickRectMachine, QwtPickerDragRectMachine 45 - Polygons\n 51 - Polygons\n 46 52 QwtPickerPolygonMachine 47 53 48 While these state machines cover the most common ways to collect points 49 it is also possible to implement individual machines as well. 50 51 QwtPicker translates the picked points into a selection using the 52 adjustedPoints() method. adjustedPoints() is intended to be reimplemented 53 to fix up the selection according to application specific requirements. 54 (F.e. when an application accepts rectangles of a fixed aspect ratio only.) 55 56 Optionally QwtPicker support the process of collecting points by a 57 rubber band and tracker displaying a text for the current mouse 58 position. 59 60 \par Example 61 \code 62 #include <qwt_picker.h>63 #include <qwt_picker_machine.h>54 While these state machines cover the most common ways to collect points 55 it is also possible to implement individual machines as well. 56 57 QwtPicker translates the picked points into a selection using the 58 adjustedPoints() method. adjustedPoints() is intended to be reimplemented 59 to fix up the selection according to application specific requirements. 60 (F.e. when an application accepts rectangles of a fixed aspect ratio only.) 61 62 Optionally QwtPicker support the process of collecting points by a 63 rubber band and tracker displaying a text for the current mouse 64 position. 65 66 \par Example 67 \code 68 #include <qwt_picker.h> 69 #include <qwt_picker_machine.h> 64 70 65 71 QwtPicker *picker = new QwtPicker(widget); … … 67 73 picker->setTrackerMode(QwtPicker::ActiveOnly); 68 74 picker->setRubberBand(QwtPicker::RectRubberBand); 69 \endcode 70 \endpar 71 72 The state machine triggers the following commands: 73 74 - begin()\n 75 \endcode 76 77 The state machine triggers the following commands: 78 79 - begin()\n 75 80 Activate/Initialize the selection. 76 - append()\n 81 - append()\n 77 82 Add a new point 78 - move() \n 83 - move() \n 79 84 Change the position of the last point. 80 - remove()\n 85 - remove()\n 81 86 Remove the last point. 82 - end()\n 87 - end()\n 83 88 Terminate the selection and call accept to validate the picked points. 84 89 85 The picker is active (isActive()), between begin() and end(). 86 In active state the rubber band is displayed, and the tracker is visible 87 in case of trackerMode is ActiveOnly or AlwaysOn. 88 89 The cursor can be moved using the arrow keys. All selections can be aborted 90 using the abort key. (QwtEventPattern::KeyPatternCode) 91 92 \warning In case of QWidget::NoFocus the focus policy of the observed 90 The picker is active (isActive()), between begin() and end(). 91 In active state the rubber band is displayed, and the tracker is visible 92 in case of trackerMode is ActiveOnly or AlwaysOn. 93 94 The cursor can be moved using the arrow keys. All selections can be aborted 95 using the abort key. (QwtEventPattern::KeyPatternCode) 96 97 \warning In case of QWidget::NoFocus the focus policy of the observed 93 98 widget is set to QWidget::WheelFocus and mouse tracking 94 99 will be manipulated while the picker is active, 95 100 or if trackerMode() is AlwayOn. 96 */ 97 98 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern 101 */ 102 103 class QWT_EXPORT QwtPicker : public QObject, public QwtEventPattern 99 104 { 100 105 Q_OBJECT … … 112 117 Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen ) 113 118 114 public: 115 /*! 116 Rubber band style 117 118 The default value is QwtPicker::NoRubberBand. 119 \sa setRubberBand(), rubberBand() 120 */ 119 public: 120 /*! 121 Rubber band style 122 123 The default value is QwtPicker::NoRubberBand. 124 \sa setRubberBand(), rubberBand() 125 */ 121 126 122 127 enum RubberBand … … 144 149 145 150 /*! 146 Values >= UserRubberBand can be used to define additional 147 rubber bands. 151 Values >= UserRubberBand can be used to define additional 152 rubber bands. 148 153 */ 149 154 UserRubberBand = 100 … … 151 156 152 157 /*! 153 \brief Display mode 154 \sa setTrackerMode(), trackerMode(), isActive() 155 */ 158 \brief Display mode 159 \sa setTrackerMode(), trackerMode(), isActive() 160 */ 156 161 enum DisplayMode 157 162 { … … 167 172 168 173 /*! 169 Controls what to do with the selected points of an active 174 Controls what to do with the selected points of an active 170 175 selection when the observed widget is resized. 171 176 172 The default value is QwtPicker::Stretch. 173 \sa setResizeMode() 174 */ 177 The default value is QwtPicker::Stretch. 178 \sa setResizeMode() 179 */ 175 180 176 181 enum ResizeMode … … 183 188 }; 184 189 185 explicit QwtPicker( QWidget *parent );190 explicit QwtPicker( QWidget* parent ); 186 191 explicit QwtPicker( RubberBand rubberBand, 187 DisplayMode trackerMode, QWidget* );192 DisplayMode trackerMode, QWidget* ); 188 193 189 194 virtual ~QwtPicker(); 190 195 191 void setStateMachine( QwtPickerMachine * );192 const QwtPickerMachine *stateMachine() const;193 QwtPickerMachine *stateMachine();196 void setStateMachine( QwtPickerMachine* ); 197 const QwtPickerMachine* stateMachine() const; 198 QwtPickerMachine* stateMachine(); 194 199 195 200 void setRubberBand( RubberBand ); … … 202 207 ResizeMode resizeMode() const; 203 208 204 void setRubberBandPen( const QPen & );209 void setRubberBandPen( const QPen& ); 205 210 QPen rubberBandPen() const; 206 211 207 void setTrackerPen( const QPen & );212 void setTrackerPen( const QPen& ); 208 213 QPen trackerPen() const; 209 214 210 void setTrackerFont( const QFont & );215 void setTrackerFont( const QFont& ); 211 216 QFont trackerFont() const; 212 217 … … 214 219 bool isActive() const; 215 220 216 virtual bool eventFilter( QObject *, QEvent* );217 218 QWidget *parentWidget();219 const QWidget *parentWidget() const;221 virtual bool eventFilter( QObject*, QEvent* ) QWT_OVERRIDE; 222 223 QWidget* parentWidget(); 224 const QWidget* parentWidget() const; 220 225 221 226 virtual QPainterPath pickArea() const; 222 227 223 virtual void drawRubberBand( QPainter * ) const; 224 virtual void drawTracker( QPainter * ) const; 225 228 virtual void drawRubberBand( QPainter* ) const; 229 virtual void drawTracker( QPainter* ) const; 230 231 virtual QRegion trackerMask() const; 226 232 virtual QRegion rubberBandMask() const; 227 233 228 virtual QwtText trackerText( const QPoint &pos ) const;234 virtual QwtText trackerText( const QPoint& pos ) const; 229 235 QPoint trackerPosition() const; 230 virtual QRect trackerRect( const QFont & ) const;236 virtual QRect trackerRect( const QFont& ) const; 231 237 232 238 QPolygon selection() const; 233 239 234 public Q_SLOTS: 240 public Q_SLOTS: 235 241 void setEnabled( bool ); 236 242 237 Q_SIGNALS: 238 /*! 239 A signal indicating, when the picker has been activated. 240 Together with setEnabled() it can be used to implement 241 selections with more than one picker. 242 243 \param on True, when the picker has been activated 244 */ 243 Q_SIGNALS: 244 /*! 245 A signal indicating, when the picker has been activated. 246 Together with setEnabled() it can be used to implement 247 selections with more than one picker. 248 249 \param on True, when the picker has been activated 250 */ 245 251 void activated( bool on ); 246 252 247 253 /*! 248 A signal emitting the selected points, 249 at the end of a selection. 250 251 \param polygon Selected points 252 */ 253 void selected( const QPolygon &polygon );254 255 /*! 256 A signal emitted when a point has been appended to the selection 257 258 \param pos Position of the appended point. 259 \sa append(). moved() 260 */ 261 void appended( const QPoint &pos );262 263 /*! 264 A signal emitted whenever the last appended point of the 265 selection has been moved. 266 267 \param pos Position of the moved last point of the selection. 268 \sa move(), appended() 269 */ 270 void moved( const QPoint &pos );271 272 /*! 273 A signal emitted whenever the last appended point of the 274 selection has been removed. 275 276 \param pos Position of the point, that has been removed 277 \sa remove(), appended() 278 */ 279 void removed( const QPoint &pos );280 /*! 281 A signal emitted when the active selection has been changed. 282 This might happen when the observed widget is resized. 283 284 \param selection Changed selection 285 \sa stretchSelection() 286 */ 287 void changed( const QPolygon &selection );288 289 protected: 290 virtual QPolygon adjustedPoints( const QPolygon & ) const;291 292 virtual void transition( const QEvent * );254 A signal emitting the selected points, 255 at the end of a selection. 256 257 \param polygon Selected points 258 */ 259 void selected( const QPolygon& polygon ); 260 261 /*! 262 A signal emitted when a point has been appended to the selection 263 264 \param pos Position of the appended point. 265 \sa append(). moved() 266 */ 267 void appended( const QPoint& pos ); 268 269 /*! 270 A signal emitted whenever the last appended point of the 271 selection has been moved. 272 273 \param pos Position of the moved last point of the selection. 274 \sa move(), appended() 275 */ 276 void moved( const QPoint& pos ); 277 278 /*! 279 A signal emitted whenever the last appended point of the 280 selection has been removed. 281 282 \param pos Position of the point, that has been removed 283 \sa remove(), appended() 284 */ 285 void removed( const QPoint& pos ); 286 /*! 287 A signal emitted when the active selection has been changed. 288 This might happen when the observed widget is resized. 289 290 \param selection Changed selection 291 \sa stretchSelection() 292 */ 293 void changed( const QPolygon& selection ); 294 295 protected: 296 virtual QPolygon adjustedPoints( const QPolygon& ) const; 297 298 virtual void transition( const QEvent* ); 293 299 294 300 virtual void begin(); 295 virtual void append( const QPoint & );296 virtual void move( const QPoint & );301 virtual void append( const QPoint& ); 302 virtual void move( const QPoint& ); 297 303 virtual void remove(); 298 304 virtual bool end( bool ok = true ); 299 305 300 virtual bool accept( QPolygon & ) const;306 virtual bool accept( QPolygon& ) const; 301 307 virtual void reset(); 302 308 303 virtual void widgetMousePressEvent( QMouseEvent * );304 virtual void widgetMouseReleaseEvent( QMouseEvent * );305 virtual void widgetMouseDoubleClickEvent( QMouseEvent * );306 virtual void widgetMouseMoveEvent( QMouseEvent * );307 virtual void widgetWheelEvent( QWheelEvent * );308 virtual void widgetKeyPressEvent( QKeyEvent * );309 virtual void widgetKeyReleaseEvent( QKeyEvent * );310 virtual void widgetEnterEvent( QEvent * );311 virtual void widgetLeaveEvent( QEvent * );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* ); 312 318 313 319 virtual void stretchSelection( 314 const QSize &oldSize, const QSize&newSize );320 const QSize& oldSize, const QSize& newSize ); 315 321 316 322 virtual void updateDisplay(); 317 323 318 const QwtWidgetOverlay *rubberBandOverlay() const; 319 const QwtWidgetOverlay *trackerOverlay() const; 320 321 const QPolygon &pickedPoints() const; 322 323 private: 324 void init( QWidget *, RubberBand rubberBand, DisplayMode trackerMode ); 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 ); 325 332 326 333 void setMouseTracking( bool ); 327 334 328 335 class PrivateData; 329 PrivateData *d_data;336 PrivateData* m_data; 330 337 }; 331 338
Note:
See TracChangeset
for help on using the changeset viewer.
