Class: QgsSnappingConfig¶
- class qgis.core.QgsSnappingConfig¶
Bases:
sip.wrapper
This is a container for configuration of the snapping of the project
New in version 3.0.
QgsSnappingConfig(project:
QgsProject
= None) Constructor with default parameters defined in global settingsQgsSnappingConfig(
QgsSnappingConfig
)Enums
Bases:
enum.IntEnum
alias of
SnappingType
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.
Returns the min scale (i.e.
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
Convenient method to return an icon corresponding to the enum type Qgis.SnappingTypes.
Convenient method to return the translated name of the enum type Qgis.SnappingTypes.
Convenient method to return an icon corresponding to the enum type Qgis.SnappingTypes.
Convenient method to returns the translated name of the enum type Qgis.SnappingTypes.
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.
Attributes
- Disabled = 0¶
- Global = 1¶
- class IndividualLayerSettings¶
Bases:
sip.wrapper
This is a container of advanced configuration (per layer) of the snapping of the project
New in version 3.0.
QgsSnappingConfig.IndividualLayerSettings(enabled: bool, type: QgsSnappingConfig.SnappingType, tolerance: float, units: QgsTolerance.UnitType) IndividualLayerSettings
- Parameters:
enabled –
type –
tolerance –
units –
Deprecated since version QGIS: 3.12 use the method with Qgis.SnappingTypes instead.
QgsSnappingConfig.IndividualLayerSettings(enabled: bool, type: Union[Qgis.SnappingTypes, Qgis.SnappingType], tolerance: float, units: QgsTolerance.UnitType, minScale: float = 0, maxScale: float = 0) IndividualLayerSettings
- Parameters:
enabled –
type –
tolerance –
units –
minScale – 0.0 disable scale limit
maxScale – 0.0 disable scale limit
New in version 3.12.
QgsSnappingConfig.IndividualLayerSettings() Constructs an invalid setting
QgsSnappingConfig.IndividualLayerSettings(QgsSnappingConfig.IndividualLayerSettings)
- enabled(self) bool ¶
Returns if snapping is enabled
- Return type:
bool
- maximumScale(self) float ¶
Returns max scale on which snapping is limited
New in version 3.14.
- Return type:
float
- minimumScale(self) float ¶
Returns minimum scale on which snapping is limited
New in version 3.14.
- Return type:
float
- setEnabled(self, enabled: bool)¶
enables the snapping
- Parameters:
enabled (bool) –
- setMaximumScale(self, maxScale: float)¶
Sets the max scale value on which snapping is used, 0.0 disable scale limit
New in version 3.14.
- Parameters:
maxScale (float) –
- setMinimumScale(self, minScale: float)¶
Sets the min scale value on which snapping is used, 0.0 disable scale limit
New in version 3.14.
- Parameters:
minScale (float) –
- setTolerance(self, tolerance: float)¶
Sets the tolerance
- Parameters:
tolerance (float) –
- setType(self, type: QgsSnappingConfig.SnappingType)¶
define the type of snapping
Deprecated since version QGIS: 3.12 use setTypeFlag instead.
- Parameters:
type (QgsSnappingConfig.SnappingType) –
- setTypeFlag(self, type: Qgis.SnappingTypes | Qgis.SnappingType)¶
define the type of snapping
New in version 3.12.
- Parameters:
type (Union[Qgis.SnappingTypes) –
- 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 flags type (vertices | segments | area | centroid | middle)
Deprecated since version QGIS: 3.12 use typeFlag instead.
- Return type:
- typeFlag(self) Qgis.SnappingTypes ¶
Returns the flags type (vertices | segments | area | centroid | middle)
New in version 3.12.
- Return type:
- units(self) QgsTolerance.UnitType ¶
Returns the type of units
- Return type:
- valid(self) bool ¶
Returns if settings are valid
- Return type:
bool
- PerLayer = 2¶
- class ScaleDependencyMode¶
Bases:
int
- baseClass¶
alias of
QgsSnappingConfig
- Segment = 3¶
- class SnappingMode(value)¶
Bases:
enum.IntEnum
SnappingMode defines on which layer the snapping is performed
New 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 ¶
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]) –
- clearIndividualLayerSettings(self)¶
Removes all individual layer snapping settings
New in version 3.16.
- 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
- maximumScale(self) float ¶
Returns the max scale (i.e. most "zoomed in" scale)
New in version 3.14.
- Return type:
float
- minimumScale(self) float ¶
Returns the min scale (i.e. most "zoomed out" scale)
New in version 3.14.
- Return type:
float
- mode(self) Qgis.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
- scaleDependencyMode(self) QgsSnappingConfig.ScaleDependencyMode ¶
Returns the scale dependency mode
New in version 3.14.
- Return type:
- selfSnapping(self) bool ¶
Returns if self snapping (snapping to the currently digitized feature) is enabled
New in version 3.14.
- Return type:
bool
- 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) –
- setMaximumScale(self, maxScale: float)¶
Set the max scale on which snapping is enabled, 0.0 disable scale limit
New in version 3.14.
- Parameters:
maxScale (float) –
- setMinimumScale(self, minScale: float)¶
Sets the min scale on which snapping is enabled, 0.0 disable scale limit
New in version 3.14.
- Parameters:
minScale (float) –
- setMode(self, mode: Qgis.SnappingMode)¶
define the mode of snapping
- Parameters:
mode (Qgis.SnappingMode) –
- setProject(self, project: QgsProject)¶
The project from which the snapped layers should be retrieved
New in version 3.0.
- Parameters:
project (QgsProject) –
- setScaleDependencyMode(self, mode: QgsSnappingConfig.ScaleDependencyMode)¶
Set the scale dependency mode
New in version 3.14.
- Parameters:
- setSelfSnapping(self, enabled: bool)¶
Sets if self snapping (snapping to the currently digitized feature) is enabled
New in version 3.14.
- Parameters:
enabled (bool) –
- setTolerance(self, tolerance: float)¶
Sets the tolerance
- Parameters:
tolerance (float) –
- setType(self, type: QgsSnappingConfig.SnappingType)¶
define the type of snapping
Deprecated since version QGIS: 3.12 use setTypeFlag instead.
- Parameters:
type (QgsSnappingConfig.SnappingType) –
- setTypeFlag(self, type: Qgis.SnappingTypes | Qgis.SnappingType)¶
define the type of snapping
New in version 3.12.
- Parameters:
type (Union[Qgis.SnappingTypes) –
- setUnits(self, units: QgsTolerance.UnitType)¶
Sets the type of units
- Parameters:
units (QgsTolerance.UnitType) –
- snappingTypeFlagToIcon(type: Qgis.SnappingType) QIcon ¶
Convenient method to return an icon corresponding to the enum type Qgis.SnappingTypes.
Deprecated since version QGIS: 3.26 use Qgis.snappingTypeToString instead
New in version 3.20.
- Parameters:
type (Qgis.SnappingType) –
- Return type:
QIcon
- snappingTypeFlagToString(type: Qgis.SnappingType) str ¶
Convenient method to return the translated name of the enum type Qgis.SnappingTypes.
New in version 3.12.
Deprecated since version QGIS: 3.26 use Qgis.snappingTypeToString instead
- Parameters:
type (Qgis.SnappingType) –
- Return type:
str
- snappingTypeToIcon(type: Qgis.SnappingType) QIcon ¶
Convenient method to return an icon corresponding to the enum type Qgis.SnappingTypes.
New in version 3.20.
- Parameters:
type (Qgis.SnappingType) –
- Return type:
QIcon
- snappingTypeToString(type: Qgis.SnappingType) str ¶
Convenient method to returns the translated name of the enum type Qgis.SnappingTypes.
New in version 3.26.
- Parameters:
type (Qgis.SnappingType) –
- Return type:
str
- staticMetaObject = <PyQt5.QtCore.QMetaObject object>¶
- tolerance(self) float ¶
Returns the tolerance
- Return type:
float
- type(self) QgsSnappingConfig.SnappingType ¶
Returns the flags type (vertices | segments | area | centroid | middle)
Deprecated since version QGIS: 3.12 use typeFlag instead.
- Return type:
- typeFlag(self) Qgis.SnappingTypes ¶
Returns the flags type (vertices | segments | area | centroid | middle)
New in version 3.12.
- 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) –