|
41 | 41 | QgsProcessingParameterDefinition,
|
42 | 42 | QgsProcessingParameterRasterLayer,
|
43 | 43 | QgsProcessingParameterVectorLayer,
|
| 44 | + QgsProcessingParameterBand, |
44 | 45 | QgsProcessingParameterBoolean,
|
45 | 46 | QgsProcessingParameterCrs,
|
46 | 47 | QgsProcessingParameterRange,
|
47 | 48 | QgsProcessingParameterPoint,
|
48 | 49 | QgsProcessingParameterEnum,
|
49 | 50 | QgsProcessingParameterExtent,
|
| 51 | + QgsProcessingParameterExpression, |
50 | 52 | QgsProcessingParameterMatrix,
|
51 | 53 | QgsProcessingParameterFile,
|
52 | 54 | QgsProcessingParameterField,
|
|
55 | 57 | QgsProcessingParameterFolderDestination,
|
56 | 58 | QgsProcessingParameterRasterDestination,
|
57 | 59 | QgsProcessingParameterString,
|
| 60 | + QgsProcessingParameterMapLayer, |
58 | 61 | QgsProcessingParameterMultipleLayers,
|
59 | 62 | QgsProcessingParameterFeatureSource,
|
60 | 63 | QgsProcessingParameterNumber)
|
61 | 64 |
|
| 65 | +from PyQt5.QtCore import QCoreApplication |
| 66 | + |
| 67 | +PARAMETER_NUMBER = 'Number' |
| 68 | +PARAMETER_RASTER = 'Raster Layer' |
| 69 | +PARAMETER_TABLE = 'Vector Layer' |
| 70 | +PARAMETER_VECTOR = 'Vector Features' |
| 71 | +PARAMETER_STRING = 'String' |
| 72 | +PARAMETER_EXPRESSION = 'Expression' |
| 73 | +PARAMETER_BOOLEAN = 'Boolean' |
| 74 | +PARAMETER_TABLE_FIELD = 'Vector Field' |
| 75 | +PARAMETER_EXTENT = 'Extent' |
| 76 | +PARAMETER_FILE = 'File' |
| 77 | +PARAMETER_POINT = 'Point' |
| 78 | +PARAMETER_CRS = 'CRS' |
| 79 | +PARAMETER_MULTIPLE = 'Multiple Input' |
| 80 | +PARAMETER_BAND = 'Raster Band' |
| 81 | +PARAMETER_MAP_LAYER = 'Map Layer' |
| 82 | +PARAMETER_RANGE = 'Range' |
| 83 | +PARAMETER_ENUM = 'Enum' |
| 84 | +PARAMETER_MATRIX = 'Matrix' |
| 85 | +PARAMETER_VECTOR_DESTINATION = 'Vector Destination' |
| 86 | +PARAMETER_FILE_DESTINATION = 'File Destination' |
| 87 | +PARAMETER_FOLDER_DESTINATION = 'Folder Destination' |
| 88 | +PARAMETER_RASTER_DESTINATION = 'Raster Destination' |
| 89 | + |
62 | 90 |
|
63 | 91 | def getParameterFromString(s):
|
64 | 92 | # Try the parameter definitions used in description files
|
@@ -209,3 +237,53 @@ def getParameterFromString(s):
|
209 | 237 | param = QgsProcessingParameters.parameterFromScriptCode(s)
|
210 | 238 | if param:
|
211 | 239 | return param
|
| 240 | + |
| 241 | + |
| 242 | +def initializeParameters(): |
| 243 | + from processing.core.Processing import Processing |
| 244 | + |
| 245 | + """ |
| 246 | + ModelerParameterDefinitionDialog.PARAMETER_TABLE: QCoreApplication.translate('Processing', |
| 247 | + 'A vector layer parameter, e.g. for algorithms which change layer styles, edit layers in place, or other operations which affect an entire layer.'), |
| 248 | + """ |
| 249 | + |
| 250 | + Processing.registerParameter(PARAMETER_MAP_LAYER, QCoreApplication.translate('Processing', 'Map Layer'), |
| 251 | + QgsProcessingParameterMapLayer, |
| 252 | + description=QCoreApplication.translate('Processing', 'A generic map layer parameter, which accepts either vector or raster layers.')) |
| 253 | + Processing.registerParameter(PARAMETER_BAND, QCoreApplication.translate('Processing', 'Raster Band'), |
| 254 | + QgsProcessingParameterBand, |
| 255 | + description=QCoreApplication.translate('Processing', 'A raster band parameter, for selecting an existing band from a raster source.')) |
| 256 | + Processing.registerParameter(PARAMETER_EXPRESSION, QCoreApplication.translate('Processing', 'Expression'), |
| 257 | + QgsProcessingParameterExpression, |
| 258 | + description=QCoreApplication.translate('Processing', 'A QGIS expression parameter, which presents an expression builder widget to users.')) |
| 259 | + Processing.registerParameter(PARAMETER_RASTER, QCoreApplication.translate('Processing', 'Raster Layer'), QgsProcessingParameterRasterLayer, |
| 260 | + description=QCoreApplication.translate('Processing', 'A raster layer parameter.')) |
| 261 | + Processing.registerParameter(PARAMETER_TABLE, QCoreApplication.translate('Processing', 'Vector Layer'), QgsProcessingParameterVectorLayer, |
| 262 | + description=QCoreApplication.translate('Processing', 'A vector feature parameter, e.g. for algorithms which operate on the features within a layer.')) |
| 263 | + Processing.registerParameter(PARAMETER_BOOLEAN, QCoreApplication.translate('Processing', 'Boolean'), QgsProcessingParameterBoolean, |
| 264 | + description=QCoreApplication.translate('Processing', 'A boolean parameter, for true/false values.')) |
| 265 | + Processing.registerParameter(PARAMETER_CRS, QCoreApplication.translate('Processing', 'CRS'), QgsProcessingParameterCrs, |
| 266 | + description=QCoreApplication.translate('Processing', 'A coordinate reference system (CRS) input parameter.')) |
| 267 | + Processing.registerParameter(PARAMETER_RANGE, QCoreApplication.translate('Processing', 'Range'), QgsProcessingParameterRange) |
| 268 | + Processing.registerParameter(PARAMETER_POINT, QCoreApplication.translate('Processing', 'Point'), QgsProcessingParameterPoint, |
| 269 | + description=QCoreApplication.translate('Processing', 'A geographic point parameter.')) |
| 270 | + Processing.registerParameter(PARAMETER_ENUM, QCoreApplication.translate('Processing', 'Enum'), QgsProcessingParameterEnum) |
| 271 | + Processing.registerParameter(PARAMETER_EXTENT, QCoreApplication.translate('Processing', 'Extent'), QgsProcessingParameterExtent, |
| 272 | + description=QCoreApplication.translate('Processing', 'A map extent parameter.')) |
| 273 | + Processing.registerParameter(PARAMETER_MATRIX, QCoreApplication.translate('Processing', 'Matrix'), QgsProcessingParameterMatrix) |
| 274 | + Processing.registerParameter(PARAMETER_FILE, QCoreApplication.translate('Processing', 'File'), QgsProcessingParameterFile, |
| 275 | + description=QCoreApplication.translate('Processing', 'A file parameter, for use with non-map layer file sources.')) |
| 276 | + Processing.registerParameter(PARAMETER_TABLE_FIELD, QCoreApplication.translate('Processing', 'Field'), QgsProcessingParameterField, |
| 277 | + description=QCoreApplication.translate('Processing', 'A vector field parameter, for selecting an existing field from a vector source.')) |
| 278 | + Processing.registerParameter(PARAMETER_VECTOR_DESTINATION, QCoreApplication.translate('Processing', 'Vector Destination'), QgsProcessingParameterVectorDestination) |
| 279 | + Processing.registerParameter(PARAMETER_FILE_DESTINATION, QCoreApplication.translate('Processing', 'File Destination'), QgsProcessingParameterFileDestination) |
| 280 | + Processing.registerParameter(PARAMETER_FOLDER_DESTINATION, QCoreApplication.translate('Processing', 'Folder Destination'), QgsProcessingParameterFolderDestination) |
| 281 | + Processing.registerParameter(PARAMETER_RASTER_DESTINATION, QCoreApplication.translate('Processing', 'Raster Destination'), QgsProcessingParameterRasterDestination) |
| 282 | + Processing.registerParameter(PARAMETER_STRING, QCoreApplication.translate('Processing', 'String'), QgsProcessingParameterString, |
| 283 | + description=QCoreApplication.translate('Processing', 'A freeform string parameter.')) |
| 284 | + Processing.registerParameter(PARAMETER_MULTIPLE, QCoreApplication.translate('Processing', 'Multiple Layers'), QgsProcessingParameterMultipleLayers, |
| 285 | + description=QCoreApplication.translate('Processing', 'An input allowing selection of multiple sources, including multiple map layers or file sources.')) |
| 286 | + Processing.registerParameter(PARAMETER_VECTOR, QCoreApplication.translate('Processing', 'Feature Source'), QgsProcessingParameterFeatureSource) |
| 287 | + Processing.registerParameter(PARAMETER_NUMBER, QCoreApplication.translate('Processing', 'Number'), QgsProcessingParameterNumber, |
| 288 | + description=QCoreApplication.translate('Processing', 'A numeric parameter, including float or integer values.')) |
| 289 | + Processing.registeredParameters() |
0 commit comments