QGIS API Documentation 3.99.0-Master (d270888f95f)
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#define SIP_NO_FILE
21
22#include "qgis_gui.h"
23#include "qgsabstractgeometry.h"
24#include "qgsmaptoolcapture.h"
26
27#include <QIcon>
28#include <QString>
29
31class QgsVectorLayer;
33class QKeyEvent;
34
35
42 : public QObject
43{
44 Q_OBJECT
45 public:
47 enum class ShapeCategory
48 {
49 Curve,
50 Circle,
51 Ellipse,
52 Rectangle,
53 RegularPolygon,
54 };
55 Q_ENUM( ShapeCategory )
56
57
58 QgsMapToolShapeAbstract( const QString &id, QgsMapToolCapture *parentTool )
59 : mId( id ), mParentTool( parentTool )
60 {
61 Q_ASSERT( !mId.isEmpty() );
62 Q_ASSERT( parentTool );
63 }
64
65 ~QgsMapToolShapeAbstract() override;
66
68 QString id() const { return mId; }
69
75
78
83 virtual void keyPressEvent( QKeyEvent *e );
84
89 virtual void keyReleaseEvent( QKeyEvent *e );
90
92 virtual void activate( QgsMapToolCapture::CaptureMode mode, const QgsPoint &lastCapturedMapPoint )
93 {
94 Q_UNUSED( mode );
95 Q_UNUSED( lastCapturedMapPoint )
96 }
97
99 virtual void deactivate() { clean(); }
100
102 virtual void clean();
103
105 virtual void undo();
106
107 signals:
108
115
116 private:
117 QString mId;
118
119 protected:
130 void setTransientGeometry( const QgsGeometry &geometry );
131
133
136
138};
139
140
141#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