Class: QgsSnappingConfig

class qgis.core.QgsSnappingConfig(project: QgsProject = None)

Bases: sip.wrapper

Constructor with default parameters defined in global settings

QgsSnappingConfig(QgsSnappingConfig)

This is a container for configuration of the snapping of the project

New in version 3.0: Enums

Methods

addLayers

Adds the specified layers as individual layers to the configuration with standard configuration.

enabled

Returns if snapping is enabled

individualLayerSettings

Returns individual snapping settings for all layers

intersectionSnapping

Returns if the snapping on intersection is enabled

mode

Returns the mode (all layers, active layer, per layer settings)

project

The project from which the snapped layers should be retrieved

readProject

Reads the configuration from the specified QGIS project document.

removeLayers

Removes the specified layers from the individual layer configuration.

reset

reset to default values

setEnabled

enables the snapping

setIndividualLayerSettings

Sets individual layer snappings settings (applied if mode is AdvancedConfiguration)

setIntersectionSnapping

Sets if the snapping on intersection is enabled

setMode

define the mode of snapping

setProject

The project from which the snapped layers should be retrieved

setTolerance

Sets the tolerance

setType

define the type of snapping

setUnits

Sets the type of units

tolerance

Returns the tolerance

type

Returns the type (vertices and/or segments)

units

Returns the type of units

writeProject

Writes the configuration to the specified QGIS project document.

Signals

Attributes

ActiveLayer

AdvancedConfiguration

AllLayers

Segment

Vertex

VertexAndSegment

staticMetaObject

ActiveLayer = 1
AdvancedConfiguration = 3
AllLayers = 2
class IndividualLayerSettings(enabled: bool, type: QgsSnappingConfig.SnappingType, tolerance: float, units: QgsTolerance.UnitType)

Bases: sip.wrapper

IndividualLayerSettings

Parameters
  • enabled

  • type

  • tolerance

  • units

QgsSnappingConfig.IndividualLayerSettings() Constructs an invalid setting

QgsSnappingConfig.IndividualLayerSettings(QgsSnappingConfig.IndividualLayerSettings)

This is a container of advanced configuration (per layer) of the snapping of the project

New in version 3.0.

enabled(self) → bool

Returns if snapping is enabled

setEnabled(self, enabled: bool)

enables the snapping

setTolerance(self, tolerance: float)

Sets the tolerance

setType(self, type: QgsSnappingConfig.SnappingType)

define the type of snapping

setUnits(self, units: QgsTolerance.UnitType)

Sets the type of units

tolerance(self) → float

Returns the tolerance

type(self) → QgsSnappingConfig.SnappingType

Returns the type (vertices and/or segments)

units(self) → QgsTolerance.UnitType

Returns the type of units

valid(self) → bool

Returns if settings are valid

Segment = 3
class SnappingMode

Bases: int

baseClass

alias of QgsSnappingConfig

class SnappingType

Bases: int

baseClass

alias of QgsSnappingConfig

Vertex = 1
VertexAndSegment = 2
addLayers(self, layers: Iterable[QgsMapLayer]) → bool

Adds the specified layers as individual layers to the configuration with standard configuration. When implementing a long-living QgsSnappingConfig (like the one in QgsProject) it is best to directly feed this with information from the layer registry.

Returns

True if changes have been done.

New in version 3.0.

enabled(self) → bool

Returns if snapping is enabled

individualLayerSettings(self) → Dict

Returns individual snapping settings for all layers

individualLayerSettings(self, vl: QgsVectorLayer) -> QgsSnappingConfig.IndividualLayerSettings Returns individual layer snappings settings (applied if mode is AdvancedConfiguration)

intersectionSnapping(self) → bool

Returns if the snapping on intersection is enabled

mode(self) → QgsSnappingConfig.SnappingMode

Returns the mode (all layers, active layer, per layer settings)

project(self) → QgsProject

The project from which the snapped layers should be retrieved

New in version 3.0.

readProject(self, doc: QDomDocument)

Reads the configuration from the specified QGIS project document.

New in version 3.0.

removeLayers(self, layers: Iterable[QgsMapLayer]) → bool

Removes the specified layers from the individual layer configuration. When implementing a long-living QgsSnappingConfig (like the one in QgsProject) it is best to directly feed this with information from the layer registry.

Returns

True if changes have been done.

New in version 3.0.

reset(self)

reset to default values

setEnabled(self, enabled: bool)

enables the snapping

setIndividualLayerSettings(self, vl: QgsVectorLayer, individualLayerSettings: QgsSnappingConfig.IndividualLayerSettings)

Sets individual layer snappings settings (applied if mode is AdvancedConfiguration)

setIntersectionSnapping(self, enabled: bool)

Sets if the snapping on intersection is enabled

setMode(self, mode: QgsSnappingConfig.SnappingMode)

define the mode of snapping

setProject(self, project: QgsProject)

The project from which the snapped layers should be retrieved

New in version 3.0.

setTolerance(self, tolerance: float)

Sets the tolerance

setType(self, type: QgsSnappingConfig.SnappingType)

define the type of snapping

setUnits(self, units: QgsTolerance.UnitType)

Sets the type of units

staticMetaObject = <PyQt5.QtCore.QMetaObject object>
tolerance(self) → float

Returns the tolerance

type(self) → QgsSnappingConfig.SnappingType

Returns the type (vertices and/or segments)

units(self) → QgsTolerance.UnitType

Returns the type of units

writeProject(self, doc: QDomDocument)

Writes the configuration to the specified QGIS project document.

New in version 3.0.