QGIS API Documentation 3.99.0-Master (a8882ad4560)
Loading...
Searching...
No Matches
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 <memory>
21
22#include "qgis_gui.h"
23#include "qgsmapmouseevent.h"
24#include "qgsmaptooledit.h"
26
30
42{
43 Q_OBJECT
44 public:
52
54 void canvasPressEvent( QgsMapMouseEvent *e ) override;
56 void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
58 void canvasMoveEvent( QgsMapMouseEvent *e ) override;
59
63 void activate() override;
64
68 void deactivate() override;
69
71
79 virtual QgsMapLayer *layer() const;
80
96 bool isAdvancedDigitizingAllowed() const { return mAdvancedDigitizingAllowed; }
97
108 bool isAutoSnapEnabled() const { return mAutoSnapEnabled; }
109
118 bool useSnappingIndicator() const;
119
120 protected:
129 void setAdvancedDigitizingAllowed( bool allowed ) { mAdvancedDigitizingAllowed = allowed; }
130
139 void setAutoSnapEnabled( bool enabled ) { mAutoSnapEnabled = enabled; }
140
149 void setUseSnappingIndicator( bool enabled );
150
151
153
154 public:
163 virtual void cadCanvasPressEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
164
165
174 virtual void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
175
176
185 virtual void cadCanvasMoveEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
186
193 bool snapToLayerGridEnabled() const;
194
201 void setSnapToLayerGridEnabled( bool snapToLayerGridEnabled );
202
203 signals:
204
205 //NOTE -- we use QgsReferencedGeometry here, as we'd like to defer the transformation of geometry to a particular
206 //desired destination CRS (eg layer CRS or map canvas CRS) as the caller's responsibility. That's because we don't want
207 //to waste cycles doing that transformation with every mouse move, when potentially NOTHING is even connected to this signal!
208 //By using QgsReferencedGeometry we allows the emitters to just use the geometries they've already calculated for the rubber
209 //bands, regardless of what CRS they are in
219
220 private slots:
221
230 void cadPointChanged( const QgsPointXY &point );
231
232 void onCurrentLayerChanged();
233
234 private:
236 bool mAdvancedDigitizingAllowed = true;
238 bool mAutoSnapEnabled = true;
240 bool mSnapToLayerGridEnabled = true;
241 QgsSnapToGridCanvasItem *mSnapToGridCanvasItem = nullptr;
242
243 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
244};
245
246#endif // QGSMAPTOOLADVANCEDDIGITIZE_H
A dockable widget used to handle the CAD tools on top of a selection of map tools.
Base class for all map layer types.
Definition qgsmaplayer.h:80
A mouse event which is the result of a user interaction with a QgsMapCanvas.
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...
QgsAdvancedDigitizingDockWidget * mCadDockWidget
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...
QgsMapToolAdvancedDigitizing(QgsMapCanvas *canvas, QgsAdvancedDigitizingDockWidget *cadDockWidget)
Creates an advanced digitizing maptool.
void transientGeometryChanged(const QgsReferencedGeometry &geometry)
Emitted whenever the geometry associated with the tool is changed, including transient (i....
bool isAdvancedDigitizingAllowed() const
Returns whether functionality of advanced digitizing dock widget is currently allowed.
QgsMapToolEdit(QgsMapCanvas *canvas)
QgsMapLayer * layer(const QString &id)
Returns the map layer with the matching ID, or nullptr if no layers could be found.
QgsMapCanvas * canvas() const
returns pointer to the tool's map canvas
friend class QgsMapCanvas
Definition qgsmaptool.h:380
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
A QgsGeometry with associated coordinate reference system.
Shows a snapping marker on map canvas for the current snapping match.
Shows a grid on the map canvas given a spatial resolution.