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. Map tools are user interactive tools for manipulating the map canvas. For example map pan and zoom features are implemented as map tools.

QObject

Subclasses

QgsMapToolAdvancedDigitizing

The QgsMapToolAdvancedDigitizing class is a QgsMapTool which gives event directly in map coordinates and allows filtering its events. Events from QgsMapTool are caught and their QMouseEvent are transformed into QgsMapMouseEvent (with map coordinates). Events are then forwarded to corresponding virtual methods which can be reimplemented in subclasses. An event filter can be set on the map tool to filter and modify the events in map coordinates (:py:

Methods

addTopologicalPoints

Adds a list of vertices to other features to keep topology up to date, e.g. to neighbouring polygons.

createGeometryRubberBand

Creates a geometry rubber band with the color/line width from the QGIS settings.

createRubberBand

Creates a rubber band with the color/line width from the QGIS settings.

currentVectorLayer

Returns the current vector layer of the map canvas or 0

notifyNotEditableLayer

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

notifyNotVectorLayer

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

Static Methods

defaultMValue

Returns default M value.

defaultZValue

Returns default Z value.

digitizingFillColor

Returns fill color for rubber bands (from global settings)

digitizingStrokeColor

Returns stroke color for rubber bands (from global settings)

digitizingStrokeWidth

Returns stroke width for rubber bands (from global settings)

Attributes

InvalidCanvas

InvalidLayer

Success

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.

Parameters:

vertices (Iterable[QgsPointXY])

Return type:

QgsMapToolEdit.TopologicalResult

addTopologicalPoints(self, vertices: Iterable[QgsPoint]) 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.

Added in version 3.10.

Parameters:

vertices (Iterable[QgsPoint])

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.