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.
- Parameters
project –
-
ActiveLayer
= 1¶
-
AdvancedConfiguration
= 3¶
-
AllLayers
= 2¶
-
class
IndividualLayerSettings
(enabled: bool, type: QgsSnappingConfig.SnappingType, tolerance: float, units: QgsTolerance.UnitType)¶ Bases:
sip.wrapper
IndividualLayerSettings
- Parameters
enabled (bool) –
type (QgsSnappingConfig.SnappingType) –
tolerance (float) –
units (QgsTolerance.UnitType) –
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
- Return type
bool
-
setEnabled
(self, enabled: bool)¶ enables the snapping
- Parameters
enabled (bool) –
-
setTolerance
(self, tolerance: float)¶ Sets the tolerance
- Parameters
tolerance (float) –
-
setType
(self, type: QgsSnappingConfig.SnappingType)¶ define the type of snapping
- Parameters
type (QgsSnappingConfig.SnappingType) –
-
setUnits
(self, units: QgsTolerance.UnitType)¶ Sets the type of units
- Parameters
units (QgsTolerance.UnitType) –
-
tolerance
(self) → float¶ Returns the tolerance
- Return type
float
-
type
(self) → QgsSnappingConfig.SnappingType¶ Returns the type (vertices and/or segments)
- Return type
-
units
(self) → QgsTolerance.UnitType¶ Returns the type of units
- Return type
-
valid
(self) → bool¶ Returns if settings are valid
- Return type
bool
-
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 inQgsProject
) it is best to directly feed this with information from the layer registry.- Return type
bool
- Returns
True
if changes have been done.
New in version 3.0.
- Parameters
layers (Iterable[QgsMapLayer]) –
-
enabled
(self) → bool¶ Returns if snapping is enabled
- Return type
bool
-
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)- Return type
Dict
-
intersectionSnapping
(self) → bool¶ Returns if the snapping on intersection is enabled
- Return type
bool
-
mode
(self) → QgsSnappingConfig.SnappingMode¶ Returns the mode (all layers, active layer, per layer settings)
- Return type
-
project
(self) → QgsProject¶ The project from which the snapped layers should be retrieved
New in version 3.0.
- Return type
-
readProject
(self, doc: QDomDocument)¶ Reads the configuration from the specified QGIS project document.
New in version 3.0.
- Parameters
doc (QDomDocument) –
-
removeLayers
(self, layers: Iterable[QgsMapLayer]) → bool¶ Removes the specified layers from the individual layer configuration. When implementing a long-living
QgsSnappingConfig
(like the one inQgsProject
) it is best to directly feed this with information from the layer registry.- Return type
bool
- Returns
True
if changes have been done.
New in version 3.0.
- Parameters
layers (Iterable[QgsMapLayer]) –
-
reset
(self)¶ reset to default values
-
setEnabled
(self, enabled: bool)¶ enables the snapping
- Parameters
enabled (bool) –
-
setIndividualLayerSettings
(self, vl: QgsVectorLayer, individualLayerSettings: QgsSnappingConfig.IndividualLayerSettings)¶ Sets individual layer snappings settings (applied if mode is AdvancedConfiguration)
- Parameters
vl (QgsVectorLayer) –
individualLayerSettings (QgsSnappingConfig.IndividualLayerSettings) –
-
setIntersectionSnapping
(self, enabled: bool)¶ Sets if the snapping on intersection is enabled
- Parameters
enabled (bool) –
-
setMode
(self, mode: QgsSnappingConfig.SnappingMode)¶ define the mode of snapping
- Parameters
mode (QgsSnappingConfig.SnappingMode) –
-
setProject
(self, project: QgsProject)¶ The project from which the snapped layers should be retrieved
New in version 3.0.
- Parameters
project (QgsProject) –
-
setTolerance
(self, tolerance: float)¶ Sets the tolerance
- Parameters
tolerance (float) –
-
setType
(self, type: QgsSnappingConfig.SnappingType)¶ define the type of snapping
- Parameters
type (QgsSnappingConfig.SnappingType) –
-
setUnits
(self, units: QgsTolerance.UnitType)¶ Sets the type of units
- Parameters
units (QgsTolerance.UnitType) –
-
staticMetaObject
= <PyQt5.QtCore.QMetaObject object>¶
-
tolerance
(self) → float¶ Returns the tolerance
- Return type
float
-
type
(self) → QgsSnappingConfig.SnappingType¶ Returns the type (vertices and/or segments)
- Return type
-
units
(self) → QgsTolerance.UnitType¶ Returns the type of units
- Return type
-
writeProject
(self, doc: QDomDocument)¶ Writes the configuration to the specified QGIS project document.
New in version 3.0.
- Parameters
doc (QDomDocument) –