QGIS API Documentation 3.43.0-Master (b60ef06885e)
qgsmaptoolshapeabstract.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaptoolshapeabstract.h - base class for map tools digitizing shapes
3 ---------------------
4 begin : January 2022
5 copyright : (C) Denis Rouzaud
6 email : denis@opengis.ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSMAPTOOLSHAPEABSTRACT_H
17#define QGSMAPTOOLSHAPEABSTRACT_H
18
19// no bindings for now, not stable yet
20#define SIP_NO_FILE
21
22#include "qgis_gui.h"
23#include "qgsabstractgeometry.h"
24#include "qgsmaptoolcapture.h"
25
26#include <QString>
27#include <QIcon>
28
30class QgsVectorLayer;
32class QKeyEvent;
33
34
41 : public QObject
42{
43 Q_OBJECT
44 public:
46 enum class ShapeCategory
47 {
48 Curve,
49 Circle,
50 Ellipse,
51 Rectangle,
52 RegularPolygon,
53 };
54 Q_ENUM( ShapeCategory )
55
56
57 QgsMapToolShapeAbstract( const QString &id, QgsMapToolCapture *parentTool )
58 : mId( id ), mParentTool( parentTool )
59 {
60 Q_ASSERT( !mId.isEmpty() );
61 Q_ASSERT( parentTool );
62 }
63
65
67 QString id() const { return mId; }
68
74
77
82 virtual void keyPressEvent( QKeyEvent *e );
83
88 virtual void keyReleaseEvent( QKeyEvent *e );
89
91 virtual void activate( QgsMapToolCapture::CaptureMode mode, const QgsPoint &lastCapturedMapPoint )
92 {
93 Q_UNUSED( mode );
94 Q_UNUSED( lastCapturedMapPoint )
95 }
96
98 virtual void deactivate() { clean(); }
99
101 virtual void clean();
102
104 virtual void undo();
105
106 private:
107 QString mId;
108
109 protected:
110 QgsMapToolCapture *mParentTool = nullptr;
111
114
115 QgsGeometryRubberBand *mTempRubberBand = nullptr;
116};
117
118
119#endif // QGSMAPTOOLSHAPEABSTRACT_H
A rubberband class for QgsAbstractGeometry (considering curved geometries).
A mouse event which is the result of a user interaction with a QgsMapCanvas.
Base class for map tools capable of capturing point, lines and polygons.
CaptureMode
Different capture modes.
Base class for shape map tools to be used by QgsMapToolCapture.
virtual void deactivate()
Deactivates the map tool.
virtual void cadCanvasMoveEvent(QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode)=0
Called for a mouse move event.
QgsPointSequence mPoints
points (in map coordinates)
QString id() const
Returns the id of the shape tool (equivalent to the one from the metadata)
virtual void activate(QgsMapToolCapture::CaptureMode mode, const QgsPoint &lastCapturedMapPoint)
Activates the map tool with the last captured map point.
virtual bool cadCanvasReleaseEvent(QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode)=0
Called for a mouse release event Must return true if the digitization has ended and the geometry is c...
ShapeCategory
List of different shapes.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
Represents a vector layer which manages a vector based dataset.
QVector< QgsPoint > QgsPointSequence