Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_picker.h


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (4 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_picker.h

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#ifndef QWT_PICKER
    11 #define QWT_PICKER 1
     11#define QWT_PICKER
    1212
    1313#include "qwt_global.h"
    14 #include "qwt_text.h"
    1514#include "qwt_event_pattern.h"
     15
    1616#include <qobject.h>
    17 #include <qpen.h>
    18 #include <qfont.h>
    19 #include <qrect.h>
    20 #include <qpainterpath.h>
    21 
     17
     18class QwtPickerMachine;
     19class QwtWidgetOverlay;
     20class QwtText;
    2221class QWidget;
    2322class QMouseEvent;
    2423class QWheelEvent;
    2524class QKeyEvent;
    26 class QwtPickerMachine;
    27 class QwtWidgetOverlay;
     25class QPainter;
     26class QPen;
     27class QFont;
     28class QRegion;
     29class QPainterPath;
     30class QPoint;
     31class QRect;
     32class QSize;
     33class QPolygon;
    2834
    2935/*!
    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
    4046    QwtPickerTrackerMachine
    41   - Single points\n
     47   - Single points\n
    4248    QwtPickerClickPointMachine, QwtPickerDragPointMachine
    43   - Rectangles\n
     49   - Rectangles\n
    4450    QwtPickerClickRectMachine, QwtPickerDragRectMachine
    45   - Polygons\n
     51   - Polygons\n
    4652    QwtPickerPolygonMachine
    4753
    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>
    6470
    6571    QwtPicker *picker = new QwtPicker(widget);
    … …  
    6773    picker->setTrackerMode(QwtPicker::ActiveOnly);
    6874    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
    7580    Activate/Initialize the selection.
    76   - append()\n
     81   - append()\n
    7782    Add a new point
    78   - move() \n
     83   - move() \n
    7984    Change the position of the last point.
    80   - remove()\n
     85   - remove()\n
    8186    Remove the last point.
    82   - end()\n
     87   - end()\n
    8388    Terminate the selection and call accept to validate the picked points.
    8489
    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
    9398           widget is set to QWidget::WheelFocus and mouse tracking
    9499           will be manipulated while the picker is active,
    95100           or if trackerMode() is AlwayOn.
    96 */
    97 
    98 class QWT_EXPORT QwtPicker: public QObject, public QwtEventPattern
     101 */
     102
     103class QWT_EXPORT QwtPicker : public QObject, public QwtEventPattern
    99104{
    100105    Q_OBJECT
    … …  
    112117    Q_PROPERTY( QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen )
    113118
    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     */
    121126
    122127    enum RubberBand
    … …  
    144149
    145150        /*!
    146           Values >= UserRubberBand can be used to define additional
    147           rubber bands.
     151           Values >= UserRubberBand can be used to define additional
     152           rubber bands.
    148153         */
    149154        UserRubberBand = 100
    … …  
    151156
    152157    /*!
    153       \brief Display mode
    154       \sa setTrackerMode(), trackerMode(), isActive()
    155     */
     158       \brief Display mode
     159       \sa setTrackerMode(), trackerMode(), isActive()
     160     */
    156161    enum DisplayMode
    157162    {
    … …  
    167172
    168173    /*!
    169       Controls what to do with the selected points of an active
     174       Controls what to do with the selected points of an active
    170175         selection when the observed widget is resized.
    171176
    172       The default value is QwtPicker::Stretch.
    173       \sa setResizeMode()
    174     */
     177       The default value is QwtPicker::Stretch.
     178       \sa setResizeMode()
     179     */
    175180
    176181    enum ResizeMode
    … …  
    183188    };
    184189
    185     explicit QwtPicker( QWidget *parent );
     190    explicit QwtPicker( QWidget* parent );
    186191    explicit QwtPicker( RubberBand rubberBand,
    187                         DisplayMode trackerMode, QWidget * );
     192        DisplayMode trackerMode, QWidget* );
    188193
    189194    virtual ~QwtPicker();
    190195
    191     void setStateMachine( QwtPickerMachine * );
    192     const QwtPickerMachine *stateMachine() const;
    193     QwtPickerMachine *stateMachine();
     196    void setStateMachine( QwtPickerMachine* );
     197    const QwtPickerMachine* stateMachine() const;
     198    QwtPickerMachine* stateMachine();
    194199
    195200    void setRubberBand( RubberBand );
    … …  
    202207    ResizeMode resizeMode() const;
    203208
    204     void setRubberBandPen( const QPen & );
     209    void setRubberBandPen( const QPen& );
    205210    QPen rubberBandPen() const;
    206211
    207     void setTrackerPen( const QPen & );
     212    void setTrackerPen( const QPen& );
    208213    QPen trackerPen() const;
    209214
    210     void setTrackerFont( const QFont & );
     215    void setTrackerFont( const QFont& );
    211216    QFont trackerFont() const;
    212217
    … …  
    214219    bool isActive() const;
    215220
    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;
    220225
    221226    virtual QPainterPath pickArea() const;
    222227
    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;
    226232    virtual QRegion rubberBandMask() const;
    227233
    228     virtual QwtText trackerText( const QPoint &pos ) const;
     234    virtual QwtText trackerText( const QPoint& pos ) const;
    229235    QPoint trackerPosition() const;
    230     virtual QRect trackerRect( const QFont & ) const;
     236    virtual QRect trackerRect( const QFont& ) const;
    231237
    232238    QPolygon selection() const;
    233239
    234 public Q_SLOTS:
     240  public Q_SLOTS:
    235241    void setEnabled( bool );
    236242
    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     */
    245251    void activated( bool on );
    246252
    247253    /*!
    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* );
    293299
    294300    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& );
    297303    virtual void remove();
    298304    virtual bool end( bool ok = true );
    299305
    300     virtual bool accept( QPolygon & ) const;
     306    virtual bool accept( QPolygon& ) const;
    301307    virtual void reset();
    302308
    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* );
    312318
    313319    virtual void stretchSelection(
    314         const QSize &oldSize, const QSize &newSize );
     320        const QSize& oldSize, const QSize& newSize );
    315321
    316322    virtual void updateDisplay();
    317323
    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 );
    325332
    326333    void setMouseTracking( bool );
    327334
    328335    class PrivateData;
    329     PrivateData *d_data;
     336    PrivateData* m_data;
    330337};
    331338
Note: See TracChangeset for help on using the changeset viewer.