Class: QgsVectorLayerTools¶
-
class
qgis.core.
QgsVectorLayerTools
¶ Bases:
PyQt5.QtCore.QObject
Methods in this class are used to handle basic operations on vector layers. With an implementation of this class, parts of the application can ask for an operation to be done and the implementation will then take care of it.
Reimplement this class, if you need to have custom checks or GUI elements in your application.
Methods
This method should/will be called, whenever a new feature will be added to the layer
Copy and move features with defined translation.
Should be called, when the features should be committed but the editing session is not ended.
This will be called, whenever a vector layer should be switched to edit mode.
Will be called, when an editing session is ended and the features should be committed.
-
addFeature
(self, layer: QgsVectorLayer, defaultValues: Dict[int, Any] = {}, defaultGeometry: QgsGeometry = QgsGeometry()) → Tuple[bool, QgsFeature]¶ This method should/will be called, whenever a new feature will be added to the layer
- Parameters
layer (QgsVectorLayer) – The layer to which the feature should be added
defaultValues (Dict[int) – Default values for the feature to add
defaultGeometry (
QgsGeometry
= QgsGeometry()) – A default geometry to add to the feature
- Return type
Tuple[bool, QgsFeature]
- Returns
True
in case of success,False
if the operation failed/was abortedfeature: Updated feature after adding will be written back to this
-
childEvent
(self, QChildEvent)¶
-
connectNotify
(self, QMetaMethod)¶
-
copyMoveFeatures
(self, layer: QgsVectorLayer, request: QgsFeatureRequest, dx: float = 0, dy: float = 0, topologicalEditing: bool = False, topologicalLayer: QgsVectorLayer = None) → Tuple[bool, QgsFeatureRequest, str]¶ Copy and move features with defined translation.
- Parameters
layer (QgsVectorLayer) – The layer
request (QgsFeatureRequest) – The request for the features to be moved. It will be assigned to a new feature request with the newly copied features.
dx (float = 0) – The translation on x
dy (float = 0) – The translation on y
topologicalEditing (bool = False) – If true, the function will perform topological editing of the vertices of
layer
onlayer
andtopologicalLayer
topologicalLayer (
QgsVectorLayer
= None) – The layer where vertices from the moved features oflayer
will be added
- Return type
Tuple[bool,
QgsFeatureRequest
, str]- Returns
True
if all features could be copied.errorMsg: If given, it will contain the error message
-
customEvent
(self, QEvent)¶
-
disconnectNotify
(self, QMetaMethod)¶
-
isSignalConnected
(self, QMetaMethod) → bool¶
-
receivers
(self, PYQT_SIGNAL) → int¶
-
saveEdits
(self, layer: QgsVectorLayer) → bool¶ Should be called, when the features should be committed but the editing session is not ended.
- Parameters
layer (QgsVectorLayer) – The layer to commit
- Return type
bool
- Returns
True
if successful
-
sender
(self) → QObject¶
-
senderSignalIndex
(self) → int¶
-
startEditing
(self, layer: QgsVectorLayer) → bool¶ This will be called, whenever a vector layer should be switched to edit mode. Check the providers capability to edit in here. If successful layer->startEditing() will be called and
True
returned.- Parameters
layer (QgsVectorLayer) – The layer on which to start an edit session
- Return type
bool
- Returns
True
, if the editing session was started
-
stopEditing
(self, layer: QgsVectorLayer, allowCancel: bool = True) → bool¶ Will be called, when an editing session is ended and the features should be committed. Appropriate dialogs should be shown like
- Parameters
layer (QgsVectorLayer) – The layer to commit
allowCancel (bool = True) –
True
if a cancel button should be offered
- Return type
bool
- Returns
True
if successful
-
timerEvent
(self, QTimerEvent)¶
-