QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsmaptooladvanceddigitizing.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaptooladvanceddigitizing.h - map tool with event in map coordinates
3 ----------------------
4 begin : October 2014
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
17#ifndef QGSMAPTOOLADVANCEDDIGITIZE_H
18#define QGSMAPTOOLADVANCEDDIGITIZE_H
19
20#include "qgsmaptooledit.h"
21#include "qgis_gui.h"
22
26
37{
38 Q_OBJECT
39 public:
40
47
49 void canvasPressEvent( QgsMapMouseEvent *e ) override;
51 void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
53 void canvasMoveEvent( QgsMapMouseEvent *e ) override;
54
58 void activate() override;
59
63 void deactivate() override;
64
65 QgsAdvancedDigitizingDockWidget *cadDockWidget() const { return mCadDockWidget; }
66
74 virtual QgsMapLayer *layer() const;
75
88 bool isAdvancedDigitizingAllowed() const { return mAdvancedDigitizingAllowed; }
89
97 bool isAutoSnapEnabled() const { return mAutoSnapEnabled; }
98
99 protected:
100
106 void setAdvancedDigitizingAllowed( bool allowed ) { mAdvancedDigitizingAllowed = allowed; }
107
113 void setAutoSnapEnabled( bool enabled ) { mAutoSnapEnabled = enabled; }
114
115
116 QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr;
117
118 public:
119
128 virtual void cadCanvasPressEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
129
130
139 virtual void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
140
141
150 virtual void cadCanvasMoveEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
151
158 bool snapToLayerGridEnabled() const;
159
166 void setSnapToLayerGridEnabled( bool snapToLayerGridEnabled );
167
168 private slots:
169
178 void cadPointChanged( const QgsPointXY &point );
179
180 void onCurrentLayerChanged();
181
182 private:
183
185 bool mAdvancedDigitizingAllowed = true;
187 bool mAutoSnapEnabled = true;
189 bool mSnapToLayerGridEnabled = true;
190 QgsSnapToGridCanvasItem *mSnapToGridCanvasItem = nullptr;
191};
192
193#endif // QGSMAPTOOLADVANCEDDIGITIZE_H
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:93
Base class for all map layer types.
Definition: qgsmaplayer.h:75
A QgsMapMouseEvent is the result of a user interaction with the mouse on a QgsMapCanvas.
The QgsMapToolAdvancedDigitizing class is a QgsMapTool which gives event directly in map coordinates ...
virtual void cadCanvasMoveEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
bool isAutoSnapEnabled() const
Returns whether mouse events (press/move/release) should automatically try to snap mouse position (ac...
virtual void cadCanvasPressEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
QgsAdvancedDigitizingDockWidget * cadDockWidget() const
void setAdvancedDigitizingAllowed(bool allowed)
Sets whether functionality of advanced digitizing dock widget is currently allowed.
virtual void cadCanvasReleaseEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
void setAutoSnapEnabled(bool enabled)
Sets whether mouse events (press/move/release) should automatically try to snap mouse position This m...
bool isAdvancedDigitizingAllowed() const
Returns whether functionality of advanced digitizing dock widget is currently allowed.
Base class for map tools that edit vector geometry.
QgsMapLayer * layer(const QString &id)
Returns the map layer with the matching ID, or nullptr if no layers could be found.
Definition: qgsmaptool.cpp:84
virtual void canvasPressEvent(QgsMapMouseEvent *e)
Mouse press event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:184
virtual void canvasMoveEvent(QgsMapMouseEvent *e)
Mouse move event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:174
virtual void canvasReleaseEvent(QgsMapMouseEvent *e)
Mouse release event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:189
virtual void activate()
called when set as currently active map tool
Definition: qgsmaptool.cpp:94
virtual void deactivate()
called when map tool is being deactivated
Definition: qgsmaptool.cpp:110
A class to represent a 2D point.
Definition: qgspointxy.h:60
Shows a grid on the map canvas given a spatial resolution.