QGIS API Documentation
4.3.0-Master (52aa6503bed)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
plot
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
23
#include "
qgis.h
"
24
#include "qgis_gui.h"
25
#include "
qgis_sip.h
"
26
27
#include <QCursor>
28
#include <QPointer>
29
30
class
QgsPlotCanvas
;
31
class
QgsPlotMouseEvent
;
32
class
QgsPoint
;
33
class
QgsPointXY
;
34
35
class
QWheelEvent;
36
class
QKeyEvent;
37
class
QGestureEvent;
38
class
QHelpEvent;
39
class
QMenu;
40
class
QAction;
41
42
#ifdef SIP_RUN
43
//%ModuleHeaderCode
44
#include "
qgsplottool.h
"
45
#include "
qgsplottoolpan.h
"
46
#include "
qgsplottoolzoom.h
"
47
//%End
48
#endif
49
50
58
class
GUI_EXPORT
QgsPlotTool
:
public
QObject
59
{
60
#ifdef SIP_RUN
61
SIP_CONVERT_TO_SUBCLASS_CODE
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
;
70
SIP_END
71
#endif
72
73
Q_OBJECT
74
75
public
:
76
~QgsPlotTool
()
override
;
77
81
virtual
Qgis::PlotToolFlags
flags
()
const
;
82
86
QString
toolName
()
const
{
return
mToolName
; }
87
95
virtual
void
plotMoveEvent(
QgsPlotMouseEvent
*event );
96
104
virtual
void
plotDoubleClickEvent(
QgsPlotMouseEvent
*event );
105
113
virtual
void
plotPressEvent(
QgsPlotMouseEvent
*event );
114
122
virtual
void
plotReleaseEvent(
QgsPlotMouseEvent
*event );
123
131
virtual
void
wheelEvent( QWheelEvent *event );
132
140
virtual
void
keyPressEvent( QKeyEvent *event );
141
149
virtual
void
keyReleaseEvent( QKeyEvent *event );
150
156
virtual
bool
gestureEvent( QGestureEvent *event );
157
163
virtual
bool
canvasToolTipEvent( QHelpEvent *event );
164
168
bool
isActive()
const
;
169
173
virtual
void
activate();
174
178
virtual
void
deactivate();
179
183
QgsPlotCanvas
*canvas()
const
;
184
193
void
setAction( QAction *action );
194
200
QAction *action();
201
205
void
setCursor(
const
QCursor &cursor );
206
223
virtual
bool
populateContextMenuWithEvent( QMenu *menu,
QgsPlotMouseEvent
*event );
224
225
signals:
226
228
void
activated
();
229
231
void
deactivated
();
232
233
protected
:
235
QgsPlotTool
(
QgsPlotCanvas
*
canvas
SIP_TRANSFERTHIS
,
const
QString &name );
236
242
QgsPoint
toMapCoordinates
(
const
QgsPointXY
&point )
const
;
243
249
QgsPointXY
toCanvasCoordinates
(
const
QgsPoint
&point )
const
;
250
257
bool
isClickAndDrag
( QPoint startViewPoint, QPoint endViewPoint )
const
;
258
262
static
QPointF
constrainPointToRect
( QPointF point,
const
QRectF &rect );
263
265
QgsPlotCanvas
*
mCanvas
=
nullptr
;
266
268
QString
mToolName
;
269
271
QPointer<QAction>
mAction
;
272
274
QCursor
mCursor
= Qt::ArrowCursor;
275
};
276
277
#endif
// QGSPLOTTOOL_H
Qgis::PlotToolFlags
QFlags< PlotToolFlag > PlotToolFlags
Definition
qgis.h:4387
QgsPlotCanvas
Plot canvas is a class for displaying interactive 2d charts and plots.
Definition
qgsplotcanvas.h:55
QgsPlotMouseEvent
A mouse event which is the result of a user interaction with a QgsPlotCanvas.
Definition
qgsplotmouseevent.h:40
QgsPlotTool::toCanvasCoordinates
QgsPointXY toCanvasCoordinates(const QgsPoint &point) const
Converts a point in map coordinates to the associated canvas point.
Definition
qgsplottool.cpp:41
QgsPlotTool::mCursor
QCursor mCursor
Cursor used by tool.
Definition
qgsplottool.h:274
QgsPlotTool::canvas
QgsPlotCanvas * canvas() const
Returns the tool's plot canvas.
Definition
qgsplottool.cpp:147
QgsPlotTool::mCanvas
QgsPlotCanvas * mCanvas
The pointer to the canvas.
Definition
qgsplottool.h:265
QgsPlotTool::QgsPlotTool
QgsPlotTool(QgsPlotCanvas *canvas, const QString &name)
Constructor takes a plot canvas as a parameter.
Definition
qgsplottool.cpp:28
QgsPlotTool::activated
void activated()
Emitted when the tool is activated.
QgsPlotTool::isClickAndDrag
bool isClickAndDrag(QPoint startViewPoint, QPoint endViewPoint) const
Returns true if a mouse press/release operation which started at startViewPoint and ended at endViewP...
Definition
qgsplottool.cpp:46
QgsPlotTool::toMapCoordinates
QgsPoint toMapCoordinates(const QgsPointXY &point) const
Converts a point on the canvas to the associated map coordinate.
Definition
qgsplottool.cpp:36
QgsPlotTool::deactivated
void deactivated()
Emitted when the tool is deactivated.
QgsPlotTool::mAction
QPointer< QAction > mAction
Optional action associated with tool.
Definition
qgsplottool.h:271
QgsPlotTool::mToolName
QString mToolName
Translated name of the map tool.
Definition
qgsplottool.h:268
QgsPlotTool::constrainPointToRect
static QPointF constrainPointToRect(QPointF point, const QRectF &rect)
Constrains a point to force it to fall within the specified rectangle.
Definition
qgsplottool.cpp:53
QgsPlotTool::flags
virtual Qgis::PlotToolFlags flags() const
Returns the flags for the plot tool.
Definition
qgsplottool.cpp:74
QgsPlotTool::toolName
QString toolName() const
Returns a user-visible, translated name for the tool.
Definition
qgsplottool.h:86
QgsPointXY
Represents a 2D point.
Definition
qgspointxy.h:62
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition
qgspoint.h:53
qgis.h
qgis_sip.h
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition
qgis_sip.h:203
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
SIP_END
#define SIP_END
Definition
qgis_sip.h:220
qgsplottool.h
qgsplottoolpan.h
qgsplottoolzoom.h
Generated on
for QGIS API Documentation by
1.17.0