QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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"
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 ) {Q_UNUSED( mode ); Q_UNUSED( lastCapturedMapPoint )}
92
94 virtual void deactivate() {clean();}
95
97 virtual void clean();
98
100 virtual void undo();
101
102 private:
103 QString mId;
104
105 protected:
106 QgsMapToolCapture *mParentTool = nullptr;
107
110
111 QgsGeometryRubberBand *mTempRubberBand = nullptr;
112
113};
114
115
116
117#endif // QGSMAPTOOLSHAPEABSTRACT_H
A rubberband class for QgsAbstractGeometry (considering curved geometries).
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
QgsMapToolCapture is a base class capable of capturing point, lines and polygons.
CaptureMode
Different capture modes.
QgsMapToolShapeAbstract is a 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 data sets.
QVector< QgsPoint > QgsPointSequence