diff --git a/python/plugins/processing/modeler/ModelerParametersDialog.py b/python/plugins/processing/modeler/ModelerParametersDialog.py index 76135852bac2..e31926046523 100644 --- a/python/plugins/processing/modeler/ModelerParametersDialog.py +++ b/python/plugins/processing/modeler/ModelerParametersDialog.py @@ -291,7 +291,10 @@ def getAvailableValuesOfType(self, paramType, outType=None, dataType=None): if alg.name not in dependent: for out in alg.algorithm.outputs: if isinstance(out, outType): - values.append(ValueFromOutput(alg.name, out.name)) + if subType is not None and out.datatype in dataType: + values.append(ValueFromOutput(alg.name, out.name)) + else: + values.append(ValueFromOutput(alg.name, out.name)) return values @@ -350,11 +353,11 @@ def getWidgetFromParameter(self, param): if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY: options = self.getAvailableValuesOfType(ParameterVector, OutputVector) elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POINT: - options = self.getAvailableValuesOfType(ParameterVector, None, [ParameterVector.TYPE_VECTOR_POINT]) + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POINT, OutputVector.VECTOR_TYPE_ANY]) elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_LINE: - options = self.getAvailableValuesOfType(ParameterVector, None, [ParameterVector.TYPE_VECTOR_LINE]) + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_LINE, OutputVector.VECTOR_TYPE_ANY]) elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POLYGON: - options = self.getAvailableValuesOfType(ParameterVector, None, [ParameterVector.TYPE_VECTOR_POLYGON]) + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POLYGON, OutputVector.VECTOR_TYPE_ANY]) elif param.datatype == ParameterMultipleInput.TYPE_RASTER: options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster) else: @@ -524,8 +527,16 @@ def setPreviousValues(self): elif isinstance(param, ParameterMultipleInput): if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY: options = self.getAvailableValuesOfType(ParameterVector, OutputVector) - else: + elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POINT: + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POINT, OutputVector.VECTOR_TYPE_ANY]) + elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_LINE: + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_LINE, OutputVector.VECTOR_TYPE_ANY]) + elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POLYGON: + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POLYGON, OutputVector.VECTOR_TYPE_ANY]) + elif param.datatype == ParameterMultipleInput.TYPE_RASTER: options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster) + else: + options = self.getAvailableValuesOfType(ParameterFile, OutputFile) selected = [] for i, opt in enumerate(options): if opt in value: @@ -751,8 +762,16 @@ def setParamValue(self, alg, param, widget): elif isinstance(param, ParameterMultipleInput): if param.datatype == ParameterMultipleInput.TYPE_VECTOR_ANY: options = self.getAvailableValuesOfType(ParameterVector, OutputVector) - else: + elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POINT: + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POINT, OutputVector.VECTOR_TYPE_ANY]) + elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_LINE: + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_LINE, OutputVector.VECTOR_TYPE_ANY]) + elif param.datatype == ParameterMultipleInput.TYPE_VECTOR_POLYGON: + options = self.getAvailableValuesOfType(ParameterVector, OutputVector, [OutputVector.TYPE_VECTOR_POLYGON, OutputVector.VECTOR_TYPE_ANY]) + elif param.datatype == ParameterMultipleInput.TYPE_RASTER: options = self.getAvailableValuesOfType(ParameterRaster, OutputRaster) + else: + options = self.getAvailableValuesOfType(ParameterFile, OutputFile) values = [options[i] for i in widget.selectedoptions] if len(values) == 0 and not param.optional: return False diff --git a/python/plugins/processing/script/ScriptAlgorithm.py b/python/plugins/processing/script/ScriptAlgorithm.py index 9b9c1712cfe0..dc042d2d0857 100644 --- a/python/plugins/processing/script/ScriptAlgorithm.py +++ b/python/plugins/processing/script/ScriptAlgorithm.py @@ -313,8 +313,14 @@ def processOutputParameterToken(self, token): if token.lower().strip().startswith('raster'): out = OutputRaster() - elif token.lower().strip().startswith('vector'): + elif token.lower().strip() == 'vector': out = OutputVector() + elif token.lower().strip() == 'vector point': + out = OutputVector(datatype=[OutputVector.VECTOR_TYPE_POINT]) + elif token.lower().strip() == 'vector line': + out = OutputVector(datatype=[OutputVector.VECTOR_TYPE_LINE]) + elif token.lower().strip() == 'vector polygon': + out = OutputVector(datatype=[OutputVector.VECTOR_TYPE_POLYGON]) elif token.lower().strip().startswith('table'): out = OutputTable() elif token.lower().strip().startswith('html'):