mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-22 00:14:55 -05:00
Adds an API which an algorithm can implement to support auto-setting
parameter values. This is designed to handle the case
of eg an algorithm which does a file format translation, where
it's desirable to default the output parameter value to an input
parameter value with a different extension.
This can now be done by implementing autogenerateParameterValues
in the algorithm, eg:
def autogenerateParameterValues(self, existingParameters, changedParameter, mode):
if changedParameter == self.INPUT:
input_file = existingParameters.get(self.INPUT)
if input_file:
input_path = Path(input_file)
if input_path.exists():
# auto set output parameter to same as input but with 'qgs' extension
return {self.OUTPUT: input_path.with_suffix('.qgs').as_posix()}
return {}
Works for both toolbox and batch modes for algorithms
29 lines
2.6 KiB
Python
29 lines
2.6 KiB
Python
# The following has been generated automatically from src/core/processing/qgsprocessingalgorithm.h
|
|
try:
|
|
QgsProcessingAlgorithm.VectorProperties.__attribute_docs__ = {'fields': 'Fields', 'wkbType': 'Geometry (WKB) type', 'crs': 'Coordinate Reference System', 'availability': 'Availability of the properties. By default properties are not available.'}
|
|
QgsProcessingAlgorithm.VectorProperties.__annotations__ = {'fields': 'QgsFields', 'wkbType': 'Qgis.WkbType', 'crs': 'QgsCoordinateReferenceSystem', 'availability': 'Qgis.ProcessingPropertyAvailability'}
|
|
QgsProcessingAlgorithm.VectorProperties.__doc__ = """Properties of a vector source or sink used in an algorithm.
|
|
|
|
.. versionadded:: 3.14"""
|
|
QgsProcessingAlgorithm.VectorProperties.__group__ = ['processing']
|
|
except (NameError, AttributeError):
|
|
pass
|
|
try:
|
|
QgsProcessingAlgorithm.invalidSourceError = staticmethod(QgsProcessingAlgorithm.invalidSourceError)
|
|
QgsProcessingAlgorithm.invalidRasterError = staticmethod(QgsProcessingAlgorithm.invalidRasterError)
|
|
QgsProcessingAlgorithm.invalidSinkError = staticmethod(QgsProcessingAlgorithm.invalidSinkError)
|
|
QgsProcessingAlgorithm.invalidPointCloudError = staticmethod(QgsProcessingAlgorithm.invalidPointCloudError)
|
|
QgsProcessingAlgorithm.writeFeatureError = staticmethod(QgsProcessingAlgorithm.writeFeatureError)
|
|
QgsProcessingAlgorithm.__virtual_methods__ = ['shortDescription', 'tags', 'shortHelpString', 'helpString', 'helpUrl', 'documentationFlags', 'icon', 'svgIconPath', 'group', 'groupId', 'flags', 'canExecute', 'checkParameterValues', 'preprocessParameters', 'autogenerateParameterValues', 'sinkProperties', 'createCustomParametersWidget', 'createExpressionContext', 'validateInputCrs', 'asPythonCommand', 'asQgisProcessCommand', 'asMap', 'supportInPlaceEdit', 'prepareAlgorithm', 'postProcessAlgorithm']
|
|
QgsProcessingAlgorithm.__abstract_methods__ = ['name', 'displayName', 'createInstance', 'initAlgorithm', 'processAlgorithm']
|
|
QgsProcessingAlgorithm.__group__ = ['processing']
|
|
except (NameError, AttributeError):
|
|
pass
|
|
try:
|
|
QgsProcessingFeatureBasedAlgorithm.__virtual_methods__ = ['inputParameterName', 'inputParameterDescription', 'inputLayerTypes', 'outputLayerType', 'sourceFlags', 'sinkFlags', 'outputWkbType', 'outputFields', 'outputCrs', 'initParameters', 'request']
|
|
QgsProcessingFeatureBasedAlgorithm.__abstract_methods__ = ['processFeature', 'outputName']
|
|
QgsProcessingFeatureBasedAlgorithm.__overridden_methods__ = ['flags', 'supportInPlaceEdit', 'initAlgorithm', 'processAlgorithm', 'sinkProperties']
|
|
QgsProcessingFeatureBasedAlgorithm.__group__ = ['processing']
|
|
except (NameError, AttributeError):
|
|
pass
|