QGIS API Documentation 3.43.0-Master (b60ef06885e)
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
6 email : denis.rouzaud@gmail.com
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#include <memory>
23
28
40{
41 Q_OBJECT
42 public:
50
52 void canvasPressEvent( QgsMapMouseEvent *e ) override;
54 void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
56 void canvasMoveEvent( QgsMapMouseEvent *e ) override;
57
61 void activate() override;
62
66 void deactivate() override;
67
68 QgsAdvancedDigitizingDockWidget *cadDockWidget() const { return mCadDockWidget; }
69
77 virtual QgsMapLayer *layer() const;
78
94 bool isAdvancedDigitizingAllowed() const { return mAdvancedDigitizingAllowed; }
95
106 bool isAutoSnapEnabled() const { return mAutoSnapEnabled; }
107
116 bool useSnappingIndicator() const;
117
118 protected:
127 void setAdvancedDigitizingAllowed( bool allowed ) { mAdvancedDigitizingAllowed = allowed; }
128
137 void setAutoSnapEnabled( bool enabled ) { mAutoSnapEnabled = enabled; }
138
147 void setUseSnappingIndicator( bool enabled );
148
149
150 QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr;
151
152 public:
161 virtual void cadCanvasPressEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
162
163
172 virtual void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
173
174
183 virtual void cadCanvasMoveEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
184
191 bool snapToLayerGridEnabled() const;
192
199 void setSnapToLayerGridEnabled( bool snapToLayerGridEnabled );
200
201 private slots:
202
211 void cadPointChanged( const QgsPointXY &point );
212
213 void onCurrentLayerChanged();
214
215 private:
217 bool mAdvancedDigitizingAllowed = true;
219 bool mAutoSnapEnabled = true;
221 bool mSnapToLayerGridEnabled = true;
222 QgsSnapToGridCanvasItem *mSnapToGridCanvasItem = nullptr;
223
224 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
225};
226
227#endif // QGSMAPTOOLADVANCEDDIGITIZE_H
A dockable widget used to handle the CAD tools on top of a selection of map tools.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:77
A mouse event which is the result of a user interaction with a QgsMapCanvas.
A QgsMapTool which gives events directly in map coordinates and allows filtering of events.
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
~QgsMapToolAdvancedDigitizing() override
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.
virtual void canvasPressEvent(QgsMapMouseEvent *e)
Mouse press event for overriding. Default implementation does nothing.
virtual void canvasMoveEvent(QgsMapMouseEvent *e)
Mouse move event for overriding. Default implementation does nothing.
virtual void canvasReleaseEvent(QgsMapMouseEvent *e)
Mouse release event for overriding. Default implementation does nothing.
virtual void activate()
called when set as currently active map tool
virtual void deactivate()
called when map tool is being deactivated
Represents a 2D point.
Definition qgspointxy.h:60
Shows a snapping marker on map canvas for the current snapping match.
Shows a grid on the map canvas given a spatial resolution.