Class: QgsSnappingConfig¶
Stores configuration of snapping settings for the project.
Enums
SnappingMode defines on which layer the snapping is performed |
|
alias of |
Methods
Adds the specified layers as individual layers to the configuration with standard configuration. |
|
Removes all individual layer snapping settings |
|
Returns if snapping is enabled |
|
Returns individual snapping settings for all layers |
|
Returns if the snapping on intersection is enabled |
|
Returns the max scale (i.e. most "zoomed in" scale). |
|
Returns the min scale (i.e. most "zoomed out" scale). |
|
Returns the mode (all layers, active layer, per layer settings) |
|
The project from which the snapped layers should be retrieved |
|
Reads the configuration from the specified QGIS project document. |
|
Removes the specified layers from the individual layer configuration. |
|
reset to default values |
|
Returns the scale dependency mode |
|
Returns if self snapping (snapping to the currently digitized feature) is enabled |
|
enables the snapping |
|
Sets individual layer snappings settings (applied if mode is AdvancedConfiguration) |
|
Sets if the snapping on intersection is enabled |
|
Set the max scale on which snapping is enabled, 0.0 disable scale limit |
|
Sets the min scale on which snapping is enabled, 0.0 disable scale limit |
|
define the mode of snapping |
|
The project from which the snapped layers should be retrieved |
|
Set the scale dependency mode |
|
Sets if self snapping (snapping to the currently digitized feature) is enabled |
|
Sets the tolerance |
|
define the type of snapping |
|
define the type of snapping |
|
Sets the type of units |
|
Returns the tolerance |
|
Returns the flags type (vertices | segments | area | centroid | middle) |
|
Returns the flags type (vertices | segments | area | centroid | middle) |
|
Returns the type of units |
|
Writes the configuration to the specified QGIS project document. |
Static Methods
Convenient method to return an icon corresponding to the enum type |
|
Convenient method to return the translated name of the enum type |
|
Convenient method to return an icon corresponding to the enum type |
|
Convenient method to returns the translated name of the enum type |
Attributes
- class qgis.core.QgsSnappingConfig[source]¶
Bases:
object
- __init__(project: QgsProject | None = None)
Constructor with default parameters defined in global settings
- Parameters:
project (Optional[QgsProject] = None)
- __init__(a0: QgsSnappingConfig)
- Parameters:
a0 (QgsSnappingConfig)
- Disabled = 0¶
- Global = 1¶
- class IndividualLayerSettings[source]¶
Bases:
object
A container of advanced configuration (per layer) of the snapping of the project.
QgsSnappingConfig.IndividualLayerSettings(enabled: bool, type: QgsSnappingConfig.SnappingType, tolerance: float, units: Qgis.MapToolUnit) IndividualLayerSettings
- Parameters:
enabled
type
tolerance
units
Deprecated since version 3.12: Use the method with
Qgis
.SnappingTypes instead.QgsSnappingConfig.IndividualLayerSettings(enabled: bool, type: Union[Qgis.SnappingTypes, Qgis.SnappingType], tolerance: float, units: Qgis.MapToolUnit, minScale: float = 0, maxScale: float = 0) IndividualLayerSettings
- Parameters:
enabled
type
tolerance
units
minScale – 0.0 disable scale limit
maxScale – 0.0 disable scale limit
Added in version 3.12.
QgsSnappingConfig.IndividualLayerSettings() Constructs an invalid setting
QgsSnappingConfig.IndividualLayerSettings(a0: QgsSnappingConfig.IndividualLayerSettings)
- maximumScale(self) float [source]¶
Returns max scale on which snapping is limited
Added in version 3.14.
- Return type:
float
- minimumScale(self) float [source]¶
Returns minimum scale on which snapping is limited
Added in version 3.14.
- Return type:
float
- setMaximumScale(self, maxScale: float)[source]¶
Sets the max scale value on which snapping is used, 0.0 disable scale limit
Added in version 3.14.
- Parameters:
maxScale (float)
- setMinimumScale(self, minScale: float)[source]¶
Sets the min scale value on which snapping is used, 0.0 disable scale limit
Added in version 3.14.
- Parameters:
minScale (float)
- setType(self, type: QgsSnappingConfig.SnappingType)[source]¶
define the type of snapping
Deprecated since version 3.12: Use
setTypeFlag()
instead.- Parameters:
- setTypeFlag(self, type: Qgis.SnappingTypes | Qgis.SnappingType)[source]¶
define the type of snapping
Added in version 3.12.
- Parameters:
type (Union[Qgis.SnappingTypes, Qgis.SnappingType])
- setUnits(self, units: Qgis.MapToolUnit)[source]¶
Sets the type of units
- Parameters:
units (Qgis.MapToolUnit)
- type(self) QgsSnappingConfig.SnappingType [source]¶
Returns the flags type (vertices | segments | area | centroid | middle)
Deprecated since version 3.12: Use
typeFlag()
instead.- Return type:
- typeFlag(self) Qgis.SnappingTypes [source]¶
Returns the flags type (vertices | segments | area | centroid | middle)
Added in version 3.12.
- Return type:
- units(self) Qgis.MapToolUnit [source]¶
Returns the type of units
- Return type:
- PerLayer = 2¶
- class ScaleDependencyMode¶
Bases:
int
- Segment = 3¶
- class SnappingMode(*values)¶
Bases:
IntEnum
SnappingMode defines on which layer the snapping is performed
Added in version 3.26.
ActiveLayer
: On the active layerAllLayers
: On all vector layersAdvancedConfiguration
: On a per layer configuration basis
- class SnappingType¶
Bases:
int
- SnappingTypeFlag¶
alias of
SnappingTypes
- SnappingTypes¶
alias of
SnappingType
- Vertex = 1¶
- VertexAndSegment = 2¶
- addLayers(self, layers: Iterable[QgsMapLayer]) bool [source]¶
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.- Parameters:
layers (Iterable[QgsMapLayer])
- clearIndividualLayerSettings(self)[source]¶
Removes all individual layer snapping settings
Added in version 3.16.
- individualLayerSettings(self) Dict [source]¶
Returns individual snapping settings for all layers
- Return type:
Dict
- individualLayerSettings(self, vl: QgsVectorLayer | None) QgsSnappingConfig.IndividualLayerSettings [source]
Returns individual layer snappings settings (applied if mode is AdvancedConfiguration)
- Parameters:
vl (Optional[QgsVectorLayer])
- Return type:
- intersectionSnapping(self) bool [source]¶
Returns if the snapping on intersection is enabled
- Return type:
bool
- maximumScale(self) float [source]¶
Returns the max scale (i.e. most "zoomed in" scale)
Added in version 3.14.
- Return type:
float
- minimumScale(self) float [source]¶
Returns the min scale (i.e. most "zoomed out" scale)
Added in version 3.14.
- Return type:
float
- mode(self) Qgis.SnappingMode [source]¶
Returns the mode (all layers, active layer, per layer settings)
- Return type:
- project(self) QgsProject | None [source]¶
The project from which the snapped layers should be retrieved
- Return type:
Optional[QgsProject]
- readProject(self, doc: QDomDocument)[source]¶
Reads the configuration from the specified QGIS project document.
- Parameters:
doc (QDomDocument)
- removeLayers(self, layers: Iterable[QgsMapLayer]) bool [source]¶
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.- Parameters:
layers (Iterable[QgsMapLayer])
- scaleDependencyMode(self) QgsSnappingConfig.ScaleDependencyMode [source]¶
Returns the scale dependency mode
Added in version 3.14.
- Return type:
- selfSnapping(self) bool [source]¶
Returns if self snapping (snapping to the currently digitized feature) is enabled
Added in version 3.14.
- Return type:
bool
- setIndividualLayerSettings(self, vl: QgsVectorLayer | None, individualLayerSettings: QgsSnappingConfig.IndividualLayerSettings)[source]¶
Sets individual layer snappings settings (applied if mode is AdvancedConfiguration)
- Parameters:
vl (Optional[QgsVectorLayer])
individualLayerSettings (QgsSnappingConfig.IndividualLayerSettings)
- setIntersectionSnapping(self, enabled: bool)[source]¶
Sets if the snapping on intersection is enabled
- Parameters:
enabled (bool)
- setMaximumScale(self, maxScale: float)[source]¶
Set the max scale on which snapping is enabled, 0.0 disable scale limit
Added in version 3.14.
- Parameters:
maxScale (float)
- setMinimumScale(self, minScale: float)[source]¶
Sets the min scale on which snapping is enabled, 0.0 disable scale limit
Added in version 3.14.
- Parameters:
minScale (float)
- setMode(self, mode: Qgis.SnappingMode)[source]¶
define the mode of snapping
- Parameters:
mode (Qgis.SnappingMode)
- setProject(self, project: QgsProject | None)[source]¶
The project from which the snapped layers should be retrieved
- Parameters:
project (Optional[QgsProject])
- setScaleDependencyMode(self, mode: QgsSnappingConfig.ScaleDependencyMode)[source]¶
Set the scale dependency mode
Added in version 3.14.
- Parameters:
- setSelfSnapping(self, enabled: bool)[source]¶
Sets if self snapping (snapping to the currently digitized feature) is enabled
Added in version 3.14.
- Parameters:
enabled (bool)
- setType(self, type: QgsSnappingConfig.SnappingType)[source]¶
define the type of snapping
Deprecated since version 3.12: Use
setTypeFlag()
instead.- Parameters:
- setTypeFlag(self, type: Qgis.SnappingTypes | Qgis.SnappingType)[source]¶
define the type of snapping
Added in version 3.12.
- Parameters:
type (Union[Qgis.SnappingTypes, Qgis.SnappingType])
- setUnits(self, units: Qgis.MapToolUnit)[source]¶
Sets the type of units
- Parameters:
units (Qgis.MapToolUnit)
- static snappingTypeFlagToIcon(type: Qgis.SnappingType) QIcon [source]¶
Convenient method to return an icon corresponding to the enum type
Qgis
.SnappingTypes.Deprecated since version 3.26: Use
snappingTypeToIcon()
instead.Added in version 3.20.
- Parameters:
type (Qgis.SnappingType)
- Return type:
QIcon
- static snappingTypeFlagToString(type: Qgis.SnappingType) str [source]¶
Convenient method to return the translated name of the enum type
Qgis
.SnappingTypes.Added in version 3.12.
Deprecated since version 3.26: Use
snappingTypeToString()
instead.- Parameters:
type (Qgis.SnappingType)
- Return type:
str
- static snappingTypeToIcon(type: Qgis.SnappingType) QIcon [source]¶
Convenient method to return an icon corresponding to the enum type
Qgis
.SnappingTypes.Added in version 3.20.
- Parameters:
type (Qgis.SnappingType)
- Return type:
QIcon
- static snappingTypeToString(type: Qgis.SnappingType) str [source]¶
Convenient method to returns the translated name of the enum type
Qgis
.SnappingTypes.Added in version 3.26.
- Parameters:
type (Qgis.SnappingType)
- Return type:
str
- type(self) QgsSnappingConfig.SnappingType [source]¶
Returns the flags type (vertices | segments | area | centroid | middle)
Deprecated since version 3.12: Use
typeFlag()
instead.- Return type:
- typeFlag(self) Qgis.SnappingTypes [source]¶
Returns the flags type (vertices | segments | area | centroid | middle)
Added in version 3.12.
- Return type:
- units(self) Qgis.MapToolUnit [source]¶
Returns the type of units
- Return type: