QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_PICKER
28#define QWT_PICKER
29
30#include "qwt_global.h"
31#include "qwt_event_pattern.h"
32
33#include <qobject.h>
34#include <QPen>
35#include <QFont>
36#include <QPainterPath>
37#include <QPoint>
38#include <QPolygon>
39#include <QSize>
40#include <QRect>
41#include <QRegion>
44class QwtText;
45class QWidget;
46class QMouseEvent;
47class QWheelEvent;
48class QKeyEvent;
49class QPainter;
50
156class QWT_EXPORT QwtPicker : public QObject, public QwtEventPattern
157{
158 Q_OBJECT
159
161
162 Q_PROPERTY(bool isEnabled READ isEnabled WRITE setEnabled)
163 Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
164
165 Q_PROPERTY(DisplayMode trackerMode READ trackerMode WRITE setTrackerMode)
166 Q_PROPERTY(QPen trackerPen READ trackerPen WRITE setTrackerPen)
167 Q_PROPERTY(QFont trackerFont READ trackerFont WRITE setTrackerFont)
168
169 Q_PROPERTY(RubberBand rubberBand READ rubberBand WRITE setRubberBand)
170 Q_PROPERTY(QPen rubberBandPen READ rubberBandPen WRITE setRubberBandPen)
171 QWT_DECLARE_PRIVATE(QwtPicker)
172public:
186 {
188 NoRubberBand = 0,
189
192
195
198
201
204
207
216 UserRubberBand = 100
217 };
218
230 {
233
236
238 ActiveOnly
239 };
240
254 {
257
259 KeepSize
260 };
261
262 // Constructor
263 explicit QwtPicker(QWidget* parent);
264 // Constructor with rubber band and tracker mode
265 explicit QwtPicker(RubberBand rubberBand, DisplayMode trackerMode, QWidget*);
266
267 // Destructor
268 virtual ~QwtPicker();
269
270 // Set the state machine
271 void setStateMachine(QwtPickerMachine*);
272 // Return the state machine (const)
273 const QwtPickerMachine* stateMachine() const;
274 // Return the state machine
275 QwtPickerMachine* stateMachine();
276
277 // Set the rubber band style
278 void setRubberBand(RubberBand);
279 // Return the rubber band style
280 RubberBand rubberBand() const;
281
282 // Set the tracker display mode
283 void setTrackerMode(DisplayMode);
284 // Return the tracker display mode
285 DisplayMode trackerMode() const;
286
287 // Set the resize mode
288 void setResizeMode(ResizeMode);
289 // Return the resize mode
290 ResizeMode resizeMode() const;
291
292 // Set the rubber band pen
293 void setRubberBandPen(const QPen&);
294 // Return the rubber band pen
295 QPen rubberBandPen() const;
296
297 // Set the tracker pen
298 void setTrackerPen(const QPen&);
299 // Return the tracker pen
300 QPen trackerPen() const;
301
302 // Set the tracker font
303 void setTrackerFont(const QFont&);
304 // Return the tracker font
305 QFont trackerFont() const;
306
307 // Return true when enabled
308 bool isEnabled() const;
309 // Return true if the selection is active
310 bool isActive() const;
311
312 // Event filter for handling events
313 virtual bool eventFilter(QObject*, QEvent*) override;
314
315 // Return the parent widget
316 QWidget* parentWidget();
317 // Return the parent widget (const)
318 const QWidget* parentWidget() const;
319
320 // Return the pick area
321 virtual QPainterPath pickArea() const;
322
323 // Draw the rubber band
324 virtual void drawRubberBand(QPainter*) const;
325 // Draw the tracker
326 virtual void drawTracker(QPainter*) const;
327
328 // Return the tracker mask
329 virtual QRegion trackerMask() const;
330 // Return the rubber band mask
331 virtual QRegion rubberBandMask() const;
332
333 // Return the tracker text for a position
334 virtual QwtText trackerText(const QPoint& pos) const;
335 // Return the tracker rectangle
336 virtual QRect trackerRect(const QFont&) const;
337 // Set the tracker position manually (for displaying picker without mouse)
338 virtual void setTrackerPosition(const QPoint& pos);
339 // Return the tracker position
340 QPoint trackerPosition() const;
341 // Return the selected points
342 QPolygon selection() const;
343 // Update the display
344 void update();
345 // Set the picker active manually
346 void setActive(bool on);
347public Q_SLOTS:
348 // Enable or disable the picker
349 void setEnabled(bool);
350
351Q_SIGNALS:
365 void activated(bool on);
366
377 void selected(const QPolygon& polygon);
378
391 void appended(const QPoint& pos);
392
405 void moved(const QPoint& pos);
406
419 void removed(const QPoint& pos);
420
435 void changed(const QPolygon& selection);
436
437protected:
438 virtual QPolygon adjustedPoints(const QPolygon&) const;
439
440 virtual void transition(const QEvent*);
441
442 virtual void begin();
443 virtual void append(const QPoint&);
444 virtual void move(const QPoint&);
445 virtual void remove();
446 virtual bool end(bool ok = true);
447
448 virtual bool accept(QPolygon&) const;
449 virtual void reset();
450
451 virtual void widgetMousePressEvent(QMouseEvent*);
452 virtual void widgetMouseReleaseEvent(QMouseEvent*);
453 virtual void widgetMouseDoubleClickEvent(QMouseEvent*);
454 virtual void widgetMouseMoveEvent(QMouseEvent*);
455 virtual void widgetWheelEvent(QWheelEvent*);
456 virtual void widgetKeyPressEvent(QKeyEvent*);
457 virtual void widgetKeyReleaseEvent(QKeyEvent*);
458 virtual void widgetEnterEvent(QEvent*);
459 virtual void widgetLeaveEvent(QEvent*);
460
461 virtual void stretchSelection(const QSize& oldSize, const QSize& newSize);
462
463 virtual void updateDisplay();
464
465 const QwtWidgetOverlay* rubberBandOverlay() const;
466 const QwtWidgetOverlay* trackerOverlay() const;
467
468 const QPolygon& pickedPoints() const;
469
470private:
471 void init(QWidget*, RubberBand rubberBand, DisplayMode trackerMode);
472
473 void setMouseTracking(bool);
474};
475
476#endif
事件模式的集合
Definition qwt_event_pattern.h:54
QwtPicker 选择的状态机
Definition qwt_picker_machine.h:51
QwtPicker 在一个部件上提供选择功能
Definition qwt_picker.h:157
DisplayMode
显示模式
Definition qwt_picker.h:230
@ AlwaysOn
Display always
Definition qwt_picker.h:235
@ AlwaysOff
Display never
Definition qwt_picker.h:232
void selected(const QPolygon &polygon)
在选择结束时发出选定点的信号
void activated(bool on)
当选择器被激活时发出的信号
RubberBand
橡皮筋样式
Definition qwt_picker.h:186
@ VLineRubberBand
A vertical line ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:194
@ CrossRubberBand
A crosshair ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:197
@ EllipseRubberBand
An ellipse ( only for QwtPickerMachine::RectSelection )
Definition qwt_picker.h:203
@ PolygonRubberBand
A polygon ( only for QwtPickerMachine::PolygonSelection )
Definition qwt_picker.h:206
@ HLineRubberBand
A horizontal line ( only for QwtPickerMachine::PointSelection )
Definition qwt_picker.h:191
@ RectRubberBand
A rectangle ( only for QwtPickerMachine::RectSelection )
Definition qwt_picker.h:200
ResizeMode
控制当观察部件调整大小时对选定点的处理方式
Definition qwt_picker.h:254
@ Stretch
All points are scaled according to the new size,
Definition qwt_picker.h:256
void appended(const QPoint &pos)
当一个点被添加到选择时发出的信号
void moved(const QPoint &pos)
当选择的最后一个添加点被移动时发出的信号
void removed(const QPoint &pos)
当选择的最后一个添加点被移除时发出的信号
void changed(const QPolygon &selection)
当活动选择被更改时发出的信号
表示文本的类
Definition qwt_text.h:93
控件的覆盖层
Definition qwt_widget_overlay.h:80