QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 : [email protected]
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 
29 class QgsMapMouseEvent;
30 class QgsVectorLayer;
32 class QKeyEvent;
33 
34 
40 class GUI_EXPORT QgsMapToolShapeAbstract
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 
64  virtual ~QgsMapToolShapeAbstract();
65 
67  QString id() const {return mId;}
68 
73  virtual bool cadCanvasReleaseEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) = 0;
74 
76  virtual void cadCanvasMoveEvent( QgsMapMouseEvent *e, QgsMapToolCapture::CaptureMode mode ) = 0;
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
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
QgsMapToolCapture::CaptureMode
CaptureMode
Different capture modes.
Definition: qgsmaptoolcapture.h:56
QgsMapToolShapeAbstract::deactivate
virtual void deactivate()
Deactivates the map tool.
Definition: qgsmaptoolshapeabstract.h:94
QgsMapToolShapeAbstract::mPoints
QgsPointSequence mPoints
points (in map coordinates)
Definition: qgsmaptoolshapeabstract.h:109
QgsMapToolShapeAbstract::activate
virtual void activate(QgsMapToolCapture::CaptureMode mode, const QgsPoint &lastCapturedMapPoint)
Activates the map tool with the last captured map point.
Definition: qgsmaptoolshapeabstract.h:91
QgsGeometryRubberBand
A rubberband class for QgsAbstractGeometry (considering curved geometries).
Definition: qgsgeometryrubberband.h:48
QgsMapMouseEvent
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas....
Definition: qgsmapmouseevent.h:35
QgsPointSequence
QVector< QgsPoint > QgsPointSequence
Definition: qgsabstractgeometry.h:52
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsMapToolShapeAbstract::id
QString id() const
Returns the id of the shape tool (equivalent to the one from the metadata)
Definition: qgsmaptoolshapeabstract.h:67
qgsmaptoolcapture.h
QgsMapToolShapeAbstract
QgsMapToolShapeAbstract is a base class for shape map tools to be used by QgsMapToolCapture.
Definition: qgsmaptoolshapeabstract.h:40
QgsMapToolShapeAbstract::ShapeCategory
ShapeCategory
List of different shapes.
Definition: qgsmaptoolshapeabstract.h:46
QgsMapToolCapture
Definition: qgsmaptoolcapture.h:49
qgsabstractgeometry.h