Logo Search packages:      
Sourcecode: pcp-gui version File versions

QwtPicker Class Reference

#include <qwt_picker.h>

Inheritance diagram for QwtPicker:

QwtEventPattern QwtPlotPicker QwtPlotZoomer

List of all members.

Detailed Description

QwtPicker provides selections on a widget.

QwtPicker filters all mouse and keyboard events of a widget and translates them into an array of selected points. Depending on the QwtPicker::SelectionType the selection might be a single point, a rectangle or a polygon. The selection process is supported by optional rubberbands (rubberband selection) and position trackers.

QwtPicker is useful for widgets where the event handlers canīt be overloaded, like for components of composite widgets. It offers alternative handlers for mouse and key events.

#include <qwt_picker.h>

QwtPicker *picker = new QwtPicker(widget);
connect(picker, SIGNAL(selected(const QwtPolygon &)), ...);

// emit the position of clicks on widget
picker->setSelectionFlags(QwtPicker::PointSelection | QwtPicker::ClickSelection);

// now select rectangles
picker->setSelectionFlags(QwtPicker::RectSelection | QwtPicker::DragSelection);

The selection process uses the commands begin(), append(), move() and end(). append() adds a new point to the selection, move() changes the position of the latest point.

The commands are initiated from a small state machine (QwtPickerMachine) that translates mouse and key events. There are a couple of predefined state machines for point, rect and polygon selections. The selectionFlags() control which one should be used. It is possible to use other machines by overloading stateMachine().

The picker is active (isActive()), between begin() and end(). In active state the rubberband is displayed, and the tracker is visible in case of trackerMode is ActiveOnly or AlwaysOn.

The cursor can be moved using the arrow keys. All selections can be aborted using the abort key. (QwtEventPattern::KeyPatternCode)

In case of QWidget::NoFocus the focus policy of the observed widget is set to QWidget::WheelFocus and mouse tracking will be manipulated for ClickSelection while the picker is active, or if trackerMode() is AlwayOn.

Definition at line 80 of file qwt_picker.h.

Public Types

enum  DisplayMode { AlwaysOff, AlwaysOn, ActiveOnly }
enum  KeyPatternCode {
  KeySelect1, KeySelect2, KeyAbort, KeyLeft,
  KeyRight, KeyUp, KeyDown, KeyRedo,
  KeyUndo, KeyHome, KeyPatternCount
 Symbolic keyboard input codes. More...
enum  MousePatternCode {
  MouseSelect1, MouseSelect2, MouseSelect3, MouseSelect4,
  MouseSelect5, MouseSelect6, MousePatternCount
 Symbolic mouse input codes. More...
enum  RectSelectionType { CornerToCorner = 64, CenterToCorner = 128, CenterToRadius = 256 }
 Selection subtype for RectSelection This enum type describes the type of rectangle selections. It can be orīd with QwtPicker::RectSelectionType and QwtPicker::SelectionMode and passed to QwtPicker::setSelectionFlags().
  • CornerToCorner
    The first and the second selected point are the corners of the rectangle.
  • CenterToCorner
    The first point is the center, the second a corner of the rectangle.
  • CenterToRadius
    The first point is the center of a quadrat, calculated by the maximum of the x- and y-distance.
enum  ResizeMode { Stretch, KeepSize }
enum  RubberBand {
  NoRubberBand = 0, HLineRubberBand, VLineRubberBand, CrossRubberBand,
  RectRubberBand, EllipseRubberBand, PolygonRubberBand, UserRubberBand = 100
enum  SelectionMode { ClickSelection = 1024, DragSelection = 2048 }
enum  SelectionType { NoSelection = 0, PointSelection = 1, RectSelection = 2, PolygonSelection = 4 }


void appended (const QPoint &pos)
void changed (const QwtPolygon &pa)
void moved (const QPoint &pos)
void selected (const QwtPolygon &pa)

Public Member Functions

virtual void drawRubberBand (QPainter *) const
virtual void drawTracker (QPainter *) const
virtual bool eventFilter (QObject *, QEvent *)
 Event filter.
void initKeyPattern ()
void initMousePattern (int numButtons)
bool isActive () const
bool isEnabled () const
bool keyMatch (uint pattern, const QKeyEvent *) const
 Compare a key event with an event pattern.
QwtArray< KeyPattern > & keyPattern ()
 Return Key patterns.
const QwtArray< KeyPattern > & keyPattern () const
 Return key patterns.
bool mouseMatch (uint pattern, const QMouseEvent *) const
 Compare a mouse event with an event pattern.
QwtArray< MousePattern > & mousePattern ()
 Return ,ouse patterns.
const QwtArray< MousePattern > & mousePattern () const
 Return mouse patterns.
const QWidget * parentWidget () const
 Return the parent widget, where the selection happens.
QWidget * parentWidget ()
 Return the parent widget, where the selection happens.
virtual QRect pickRect () const
 QwtPicker (int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode, QWidget *)
 QwtPicker (QWidget *parent)
ResizeMode resizeMode () const
RubberBand rubberBand () const
QPen rubberBandPen () const
const QwtPolygon & selection () const
 Return Selected points.
int selectionFlags () const
virtual void setEnabled (bool)
 En/disable the picker.
void setKeyPattern (const QwtArray< KeyPattern > &)
 Change the key event patterns.
void setKeyPattern (uint pattern, int key, int state=Qt::NoButton)
void setMousePattern (const QwtArray< MousePattern > &)
 Change the mouse event patterns.
void setMousePattern (uint pattern, int button, int state=Qt::NoButton)
virtual void setResizeMode (ResizeMode)
 Set the resize mode.
virtual void setRubberBand (RubberBand)
virtual void setRubberBandPen (const QPen &)
virtual void setSelectionFlags (int)
virtual void setTrackerFont (const QFont &)
virtual void setTrackerMode (DisplayMode)
 Set the display mode of the tracker.
virtual void setTrackerPen (const QPen &)
QFont trackerFont () const
DisplayMode trackerMode () const
QPen trackerPen () const
virtual ~QwtPicker ()

Protected Member Functions

virtual bool accept (QwtPolygon &selection) const
 Validate and fixup the selection.
virtual void append (const QPoint &)
virtual void begin ()
virtual bool end (bool ok=true)
 Close a selection setting the state to inactive.
virtual bool keyMatch (const KeyPattern &, const QKeyEvent *) const
 Compare a key event with an event pattern.
virtual bool mouseMatch (const MousePattern &, const QMouseEvent *) const
 Compare a mouse event with an event pattern.
virtual void move (const QPoint &)
const QWidget * rubberBandWidget () const
virtual QwtPickerMachinestateMachine (int) const
virtual void stretchSelection (const QSize &oldSize, const QSize &newSize)
QRect trackerRect (QPainter *painter) const
virtual QwtText trackerText (const QPoint &pos) const
 Return the label for a position.
const QWidget * trackerWidget () const
virtual void transition (const QEvent *)
virtual void updateDisplay ()
virtual void widgetKeyPressEvent (QKeyEvent *)
virtual void widgetKeyReleaseEvent (QKeyEvent *)
virtual void widgetLeaveEvent (QEvent *)
virtual void widgetMouseDoubleClickEvent (QMouseEvent *)
virtual void widgetMouseMoveEvent (QMouseEvent *)
virtual void widgetMousePressEvent (QMouseEvent *)
virtual void widgetMouseReleaseEvent (QMouseEvent *)
virtual void widgetWheelEvent (QWheelEvent *)


bool isEnabled
ResizeMode resizeMode
RubberBand rubberBand
QPen rubberBandPen
int selectionFlags
QFont trackerFont
DisplayMode trackerMode
QPen trackerPen

Private Member Functions

void init (QWidget *, int selectionFlags, RubberBand rubberBand, DisplayMode trackerMode)
 Init the picker, used by the constructors.
void setMouseTracking (bool)
void setStateMachine (QwtPickerMachine *)

Private Attributes

PrivateData * d_data


class  PrivateData

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index