Class: QgsMapToolEdit

Base class for map tools that edit vector geometry.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsMapToolEdit

Base classes

QgsMapTool

Abstract base class for all map tools.

QObject

Subclasses

QgsMapToolAdvancedDigitizing

A QgsMapTool which gives events directly in map coordinates and allows filtering of events.

class qgis.gui.QgsMapToolEdit[source]

Bases: QgsMapTool

InvalidCanvas = 1
InvalidLayer = 2
Success = 0
class TopologicalResult

Bases: int

addTopologicalPoints(self, vertices: Iterable[QgsPointXY]) QgsMapToolEdit.TopologicalResult[source]

Adds a list of vertices to other features to keep topology up to date, e.g. to neighbouring polygons. The vertices list specifies a set of topological points to add, in the layer’s coordinate reference system.

Deprecated since version 3.12: Will be removed in QGIS 4.0. Use the variant which accepts QgsPoint objects instead of QgsPointXY.

addTopologicalPoints(self, vertices: Iterable[QgsPoint]) -> QgsMapToolEdit.TopologicalResult Adds a list of vertices to other features to keep topology up to date, e.g. to neighbouring polygons. The vertices list specifies a set of topological points to add, in the layer’s coordinate reference system.

Added in version 3.10.

Parameters:

vertices (Iterable[QgsPointXY])

Return type:

QgsMapToolEdit.TopologicalResult

createGeometryRubberBand(self, geometryType: Qgis.GeometryType = Qgis.GeometryType.Line, alternativeBand: bool = False) QgsGeometryRubberBand | None[source]

Creates a geometry rubber band with the color/line width from the QGIS settings. The caller takes ownership of the returned object

Parameters:
  • geometryType (Qgis.GeometryType = Qgis.GeometryType.Line)

  • alternativeBand (bool = False) – if True, rubber band will be set with more transparency and a dash pattern. default is False.

Return type:

Optional[QgsGeometryRubberBand]

createRubberBand(self, geometryType: Qgis.GeometryType = Qgis.GeometryType.Line, alternativeBand: bool = False) QgsRubberBand | None[source]

Creates a rubber band with the color/line width from the QGIS settings. The caller takes ownership of the returned object

Parameters:
  • geometryType (Qgis.GeometryType = Qgis.GeometryType.Line)

  • alternativeBand (bool = False) – if True, rubber band will be set with more transparency and a dash pattern. default is False.

Return type:

Optional[QgsRubberBand]

currentVectorLayer(self) QgsVectorLayer | None[source]

Returns the current vector layer of the map canvas or 0

Return type:

Optional[QgsVectorLayer]

static defaultMValue() float[source]

Returns default M value. Used for setting M coordinate to new vertex.

Added in version 3.20.

Return type:

float

static defaultZValue() float[source]

Returns default Z value. Used for setting Z coordinate to new vertex.

Return type:

float

static digitizingFillColor() QColor[source]

Returns fill color for rubber bands (from global settings)

Return type:

QColor

static digitizingStrokeColor() QColor[source]

Returns stroke color for rubber bands (from global settings)

Return type:

QColor

static digitizingStrokeWidth() int[source]

Returns stroke width for rubber bands (from global settings)

Return type:

int

notifyNotEditableLayer(self)[source]

Display a timed message bar noting the active vector layer is not editable.

notifyNotVectorLayer(self)[source]

Display a timed message bar noting the active layer is not vector.