QGIS API Documentation 4.1.0-Master (60fea48833c)
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
126 SIP_SKIP static void calculateGeometryMeasures(
127 const QgsReferencedGeometry &geometry,
128 const QgsCoordinateReferenceSystem &destinationCrs,
130 Qgis::CadMeasurementDisplayType totalLengthType,
131 QString &areaString,
132 QString &totalLengthString
133 );
134
135 protected:
144 void setAdvancedDigitizingAllowed( bool allowed ) { mAdvancedDigitizingAllowed = allowed; }
145
154 void setAutoSnapEnabled( bool enabled ) { mAutoSnapEnabled = enabled; }
155
164 void setUseSnappingIndicator( bool enabled );
165
166
168
169 public:
178 virtual void cadCanvasPressEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
179
180
189 virtual void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
190
191
200 virtual void cadCanvasMoveEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
201
208 bool snapToLayerGridEnabled() const;
209
216 void setSnapToLayerGridEnabled( bool snapToLayerGridEnabled );
217
218 signals:
219
220 //NOTE -- we use QgsReferencedGeometry here, as we'd like to defer the transformation of geometry to a particular
221 //desired destination CRS (eg layer CRS or map canvas CRS) as the caller's responsibility. That's because we don't want
222 //to waste cycles doing that transformation with every mouse move, when potentially NOTHING is even connected to this signal!
223 //By using QgsReferencedGeometry we allows the emitters to just use the geometries they've already calculated for the rubber
224 //bands, regardless of what CRS they are in
234
235 private slots:
236
245 void cadPointChanged( const QgsPointXY &point );
246
247 void onCurrentLayerChanged();
248
249 void onTransientGeometryChanged( const QgsReferencedGeometry &geometry );
250
251 private:
253 bool mAdvancedDigitizingAllowed = true;
255 bool mAutoSnapEnabled = true;
257 bool mSnapToLayerGridEnabled = true;
258 QgsSnapToGridCanvasItem *mSnapToGridCanvasItem = nullptr;
259
260 std::unique_ptr<QgsSnapIndicator> mSnapIndicator;
261};
262
263#endif // QGSMAPTOOLADVANCEDDIGITIZE_H
CadMeasurementDisplayType
Advanced digitizing measurement display types.
Definition qgis.h:4207
A dockable widget used to handle the CAD tools on top of a selection of map tools.
Represents a coordinate reference system (CRS).
Base class for all map layer types.
Definition qgsmaplayer.h:83
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:389
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:62
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.
#define SIP_SKIP
Definition qgis_sip.h:133