QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsplottool.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsplottool.h
3 ---------------
4 begin : March 2022
5 copyright : (C) 2022 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPLOTTOOL_H
19#define QGSPLOTTOOL_H
20
21#include "qgsconfig.h"
22#include "qgis.h"
23#include "qgis_gui.h"
24#include "qgis_sip.h"
25
26#include <QPointer>
27#include <QCursor>
28
29class QgsPlotCanvas;
31class QgsPoint;
32class QgsPointXY;
33
34class QWheelEvent;
35class QKeyEvent;
36class QGestureEvent;
37class QHelpEvent;
38class QMenu;
39class QAction;
40
41#ifdef SIP_RUN
42% ModuleHeaderCode
43#include "qgsplottool.h"
44#include "qgsplottoolpan.h"
45#include "qgsplottoolzoom.h"
46% End
47#endif
48
49
57class GUI_EXPORT QgsPlotTool : public QObject
58{
59
60#ifdef SIP_RUN
62 if ( qobject_cast<QgsPlotToolPan *>( sipCpp ) != nullptr )
63 sipType = sipType_QgsPlotToolPan;
64 else if ( qobject_cast<QgsPlotToolZoom *>( sipCpp ) != nullptr )
65 sipType = sipType_QgsPlotToolZoom;
66 else if ( qobject_cast<QgsPlotTool *>( sipCpp ) != nullptr )
67 sipType = sipType_QgsPlotTool;
68 else
69 sipType = nullptr;
71#endif
72
73 Q_OBJECT
74
75 public:
76
77 ~QgsPlotTool() override;
78
82 virtual Qgis::PlotToolFlags flags() const;
83
87 QString toolName() const { return mToolName; }
88
96 virtual void plotMoveEvent( QgsPlotMouseEvent *event );
97
105 virtual void plotDoubleClickEvent( QgsPlotMouseEvent *event );
106
114 virtual void plotPressEvent( QgsPlotMouseEvent *event );
115
123 virtual void plotReleaseEvent( QgsPlotMouseEvent *event );
124
132 virtual void wheelEvent( QWheelEvent *event );
133
141 virtual void keyPressEvent( QKeyEvent *event );
142
150 virtual void keyReleaseEvent( QKeyEvent *event );
151
157 virtual bool gestureEvent( QGestureEvent *event );
158
164 virtual bool canvasToolTipEvent( QHelpEvent *event );
165
169 bool isActive() const;
170
174 virtual void activate();
175
179 virtual void deactivate();
180
184 QgsPlotCanvas *canvas() const;
185
194 void setAction( QAction *action );
195
201 QAction *action();
202
206 void setCursor( const QCursor &cursor );
207
224 virtual bool populateContextMenuWithEvent( QMenu *menu, QgsPlotMouseEvent *event );
225
226 signals:
227
229 void activated();
230
233
234 protected:
235
237 QgsPlotTool( QgsPlotCanvas *canvas SIP_TRANSFERTHIS, const QString &name );
238
244 QgsPoint toMapCoordinates( const QgsPointXY &point ) const;
245
251 QgsPointXY toCanvasCoordinates( const QgsPoint &point ) const;
252
259 bool isClickAndDrag( QPoint startViewPoint, QPoint endViewPoint ) const;
260
264 static QPointF constrainPointToRect( QPointF point, const QRectF &rect );
265
267 QgsPlotCanvas *mCanvas = nullptr;
268
270 QString mToolName;
271
273 QPointer< QAction > mAction;
274
276 QCursor mCursor = Qt::ArrowCursor;
277};
278
279#endif // QGSPLOTTOOL_H
Plot canvas is a class for displaying interactive 2d charts and plots.
A QgsPlotMouseEvent is the result of a user interaction with the mouse on a QgsPlotCanvas.
Abstract base class for all interactive plot tools.
Definition qgsplottool.h:58
void activated()
Emitted when the tool is activated.
void deactivated()
Emitted when the tool is deactivated.
QPointer< QAction > mAction
Optional action associated with tool.
QString mToolName
Translated name of the map tool.
QString toolName() const
Returns a user-visible, translated name for the tool.
Definition qgsplottool.h:87
A class to represent a 2D point.
Definition qgspointxy.h:59
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:186
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_END
Definition qgis_sip.h:203