QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 : [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 
17 #ifndef QGSMAPTOOLADVANCEDDIGITIZE_H
18 #define QGSMAPTOOLADVANCEDDIGITIZE_H
19 
20 #include "qgsmaptooledit.h"
21 #include "qgis_gui.h"
22 
23 class QgsMapMouseEvent;
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 
80  bool isAdvancedDigitizingAllowed() const { return mAdvancedDigitizingAllowed; }
81 
90  bool isAutoSnapEnabled() const { return mAutoSnapEnabled; }
91 
92  protected:
93 
100  void setAdvancedDigitizingAllowed( bool allowed ) { mAdvancedDigitizingAllowed = allowed; }
101 
108  void setAutoSnapEnabled( bool enabled ) { mAutoSnapEnabled = enabled; }
109 
110 
111  QgsAdvancedDigitizingDockWidget *mCadDockWidget = nullptr;
112 
113  public:
114 
123  virtual void cadCanvasPressEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
124 
125 
134  virtual void cadCanvasReleaseEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
135 
136 
145  virtual void cadCanvasMoveEvent( QgsMapMouseEvent *e ) { Q_UNUSED( e ) }
146 
153  bool snapToLayerGridEnabled() const;
154 
161  void setSnapToLayerGridEnabled( bool snapToLayerGridEnabled );
162 
163  private slots:
164 
173  void cadPointChanged( const QgsPointXY &point );
174 
175  void onCurrentLayerChanged();
176 
177  private:
178 
180  bool mAdvancedDigitizingAllowed = true;
182  bool mAutoSnapEnabled = true;
184  bool mSnapToLayerGridEnabled = true;
185  QgsSnapToGridCanvasItem *mSnapToGridCanvasItem = nullptr;
186 };
187 
188 #endif // QGSMAPTOOLADVANCEDDIGITIZE_H
QgsMapToolAdvancedDigitizing::isAdvancedDigitizingAllowed
bool isAdvancedDigitizingAllowed() const
Returns whether functionality of advanced digitizing dock widget is currently allowed.
Definition: qgsmaptooladvanceddigitizing.h:80
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsMapTool::deactivate
virtual void deactivate()
called when map tool is being deactivated
Definition: qgsmaptool.cpp:99
QgsMapToolAdvancedDigitizing::setAdvancedDigitizingAllowed
void setAdvancedDigitizingAllowed(bool allowed)
Sets whether functionality of advanced digitizing dock widget is currently allowed.
Definition: qgsmaptooladvanceddigitizing.h:100
QgsMapToolAdvancedDigitizing::isAutoSnapEnabled
bool isAutoSnapEnabled() const
Returns whether mouse events (press/move/release) should automatically try to snap mouse position (ac...
Definition: qgsmaptooladvanceddigitizing.h:90
QgsAdvancedDigitizingDockWidget
The QgsAdvancedDigitizingDockWidget class is a dockable widget used to handle the CAD tools on top of...
Definition: qgsadvanceddigitizingdockwidget.h:48
QgsMapTool::activate
virtual void activate()
called when set as currently active map tool
Definition: qgsmaptool.cpp:83
QgsPointXY
Definition: qgspointxy.h:43
QgsMapTool::canvasPressEvent
virtual void canvasPressEvent(QgsMapMouseEvent *e)
Mouse press event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:167
QgsMapMouseEvent
Definition: qgsmapmouseevent.h:35
QgsMapTool::canvasMoveEvent
virtual void canvasMoveEvent(QgsMapMouseEvent *e)
Mouse move event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:157
QgsMapToolEdit
Definition: qgsmaptooledit.h:32
QgsMapTool::canvasReleaseEvent
virtual void canvasReleaseEvent(QgsMapMouseEvent *e)
Mouse release event for overriding. Default implementation does nothing.
Definition: qgsmaptool.cpp:172
qgsmaptooledit.h
QgsMapToolAdvancedDigitizing::cadCanvasMoveEvent
virtual void cadCanvasMoveEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
Definition: qgsmaptooladvanceddigitizing.h:145
QgsMapToolAdvancedDigitizing::cadDockWidget
QgsAdvancedDigitizingDockWidget * cadDockWidget() const
Definition: qgsmaptooladvanceddigitizing.h:65
QgsSnapToGridCanvasItem
Definition: qgssnaptogridcanvasitem.h:41
QgsMapToolAdvancedDigitizing
The QgsMapToolAdvancedDigitizing class is a QgsMapTool which gives event directly in map coordinates ...
Definition: qgsmaptooladvanceddigitizing.h:36
QgsMapToolAdvancedDigitizing::cadCanvasPressEvent
virtual void cadCanvasPressEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
Definition: qgsmaptooladvanceddigitizing.h:123
QgsMapToolAdvancedDigitizing::cadCanvasReleaseEvent
virtual void cadCanvasReleaseEvent(QgsMapMouseEvent *e)
Override this method when subclassing this class.
Definition: qgsmaptooladvanceddigitizing.h:134
QgsMapToolAdvancedDigitizing::setAutoSnapEnabled
void setAutoSnapEnabled(bool enabled)
Sets whether mouse events (press/move/release) should automatically try to snap mouse position This m...
Definition: qgsmaptooladvanceddigitizing.h:108