-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsmaptooledit.h
120 lines (99 loc) · 4.55 KB
/
qgsmaptooledit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/***************************************************************************
qgsmaptooledit.h - base class for editing map tools
---------------------
begin : Juli 2007
copyright : (C) 2007 by Marco Hugentobler
email : marco dot hugentobler at karto dot baug dot ethz dot ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMAPTOOLEDIT_H
#define QGSMAPTOOLEDIT_H
#include "qgswkbtypes.h"
#include "qgsmaptool.h"
#include "qgis_gui.h"
class QgsRubberBand;
class QgsGeometryRubberBand;
class QgsVectorLayer;
class QKeyEvent;
/**
* \ingroup gui
* \brief Base class for map tools that edit vector geometry
*/
class GUI_EXPORT QgsMapToolEdit: public QgsMapTool
{
Q_OBJECT
public:
QgsMapToolEdit( QgsMapCanvas *canvas );
Flags flags() const override { return QgsMapTool::EditTool; }
/**
* Returns default Z value
* Use for set Z coordinate to new vertex
*/
double defaultZValue() const;
/**
* Returns default M value
* Use for set M coordinate to new vertex
*
* \since QGIS 3.20
*/
double defaultMValue() const;
private slots:
//! Vector layers' editingStopped SIGNAL will eventually trigger a clean
void connectLayers( const QList<QgsMapLayer *> &layers );
/**
* Makes sure rubber bands are removed if there
* is no editable layer left in the project
*/
void cleanCanvas();
protected:
//! Returns stroke color for rubber bands (from global settings)
static QColor digitizingStrokeColor();
//! Returns stroke width for rubber bands (from global settings)
static int digitizingStrokeWidth();
//! Returns fill color for rubber bands (from global settings)
static QColor digitizingFillColor();
/**
* Creates a rubber band with the color/line width from
* the QGIS settings. The caller takes ownership of the
* returned object
* \param geometryType
* \param alternativeBand if TRUE, rubber band will be set with more transparency and a dash pattern. default is FALSE.
*/
QgsRubberBand *createRubberBand( QgsWkbTypes::GeometryType geometryType = QgsWkbTypes::LineGeometry, bool alternativeBand = false ) SIP_FACTORY;
QgsGeometryRubberBand *createGeometryRubberBand( QgsWkbTypes::GeometryType geometryType = QgsWkbTypes::LineGeometry, bool alternativeBand = false ) const SIP_FACTORY;
//! Returns the current vector layer of the map canvas or 0
QgsVectorLayer *currentVectorLayer();
//! Result of addTopologicalPoints
enum TopologicalResult
{
Success = 0, //!< AddTopologicalPoints was successful
InvalidCanvas = 1, //!< AddTopologicalPoints failed due to an invalid canvas
InvalidLayer = 2, //!< AddTopologicalPoints failed due to an invalid canvas
};
/**
* Adds a list of \a vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
* The \a vertices list specifies a set of topological points to add, in the layer's coordinate reference system.
* \deprecated since QGIS 3.12 - will be removed in QGIS 4.0. Use the variant which accepts QgsPoint objects instead of QgsPointXY.
*/
Q_DECL_DEPRECATED TopologicalResult addTopologicalPoints( const QVector<QgsPointXY> &vertices ) SIP_DEPRECATED;
/**
* Adds a list of \a vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
* The \a vertices list specifies a set of topological points to add, in the layer's coordinate reference system.
* \since QGIS 3.10
*/
TopologicalResult addTopologicalPoints( const QVector<QgsPoint> &vertices );
//! Display a timed message bar noting the active layer is not vector.
void notifyNotVectorLayer();
//! Display a timed message bar noting the active vector layer is not editable.
void notifyNotEditableLayer();
private:
//! Returns a list of layers filtered to just editable spatial vector layers
QList<QgsVectorLayer *> editableVectorLayers();
};
#endif