QGIS API Documentation 3.99.0-Master (a8f284845db)
Loading...
Searching...
No Matches
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
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
21#include "qgis_gui.h"
22#include "qgsabstractgeometry.h"
23#include "qgsmaptoolcapture.h"
25
26#include <QIcon>
27#include <QString>
28
29#define SIP_NO_FILE
30
32class QgsVectorLayer;
34class QKeyEvent;
35
36
43 : public QObject
44{
45 Q_OBJECT
46 public:
48 enum class ShapeCategory
49 {
50 Curve,
51 Circle,
52 Ellipse,
53 Rectangle,
54 RegularPolygon,
55 };
56 Q_ENUM( ShapeCategory )
57
58
59 QgsMapToolShapeAbstract( const QString &id, QgsMapToolCapture *parentTool )
60 : mId( id ), mParentTool( parentTool )
61 {
62 Q_ASSERT( !mId.isEmpty() );
63 Q_ASSERT( parentTool );
64 }
65
66 ~QgsMapToolShapeAbstract() override;
67
69 QString id() const { return mId; }
70
76
79
84 virtual void keyPressEvent( QKeyEvent *e );
85
90 virtual void keyReleaseEvent( QKeyEvent *e );
91
93 virtual void activate( QgsMapToolCapture::CaptureMode mode, const QgsPoint &lastCapturedMapPoint )
94 {
95 Q_UNUSED( mode );
96 Q_UNUSED( lastCapturedMapPoint )
97 }
98
100 virtual void deactivate() { clean(); }
101
103 virtual void clean();
104
106 virtual void undo();
107
108 signals:
109
116
117 private:
118 QString mId;
119
120 protected:
131 void setTransientGeometry( const QgsGeometry &geometry );
132
134
137
139};
140
141
142#endif // QGSMAPTOOLSHAPEABSTRACT_H
A rubberband class for QgsAbstractGeometry (considering curved geometries).
A geometry is the spatial representation of a feature.
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.
QgsMapToolShapeAbstract(const QString &id, QgsMapToolCapture *parentTool)
Constructor.
void transientGeometryChanged(const QgsReferencedGeometry &geometry)
Emitted whenever the geometry associated with the tool is changed, including transient (i....
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)
virtual void keyReleaseEvent(QKeyEvent *e)
Filters a key release event Ignores the event in default implementation.
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 void clean()
Called to clean the map tool (after canceling the operation or when the digitization has finished).
void setTransientGeometry(const QgsGeometry &geometry)
Sets the current geometry, including transient (i.e.
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.
virtual void keyPressEvent(QKeyEvent *e)
Filters a key press event Ignores the event in default implementation.
QgsGeometryRubberBand * mTempRubberBand
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
A QgsGeometry with associated coordinate reference system.
Represents a vector layer which manages a vector based dataset.
QVector< QgsPoint > QgsPointSequence