Open arnaud-morvan opened 7 years ago
@volaya @alexbruy @nyalldawson @rldhont : How do you fell this ?
The idea looks good to me. We will have to see how that integrates with algorithms that have specific parameters and behaviour in the modeler, like the raster calculator.
I guess there will be no issues, so this sounds like a nice enhancement
@nirvn : Any opinion on this ?
@arnaud-morvan
https://github.com/qgis/QGIS/pull/4729 relates to this. In that PR the way model child algorithm parameter values are handled in the base model algorithm classes are changed. Instead of separate classes used to handle ValueFromInput/ValueFromOutput/etc, there's a single class QgsProcessingModelAlgorithm::ChildParameterSource which handles all possible source types for input parameters to child algorithms. The actual behaviour is specified via an enum (StaticValue /ModelParameter /ChildOutput ).
This would tie in very well with the proposal outlined here. We'd just make sure the the model widget wrapper checks the ChildParameterSource source type and shows the appropriate configuration widget, and when it returns the value it returns a properly created ChildParameterSource object.
The changes in that PR + the changes outlined here will make it easy to extend in future with other possible child algorithm parameter input types, such as a "calculate expression result before running child alg" type.
My 2c is that I'm very much in favour of this proposal, and think that separating model inputs from the static value choices from other child algorithm outputs will make processing's UI easier to understand. My only concern is the reuse of the data defined icon in a different context - that should be avoided and either a combobox used OR a new icon for this designed. It'll get very confusing when I add the data defined button to dynamic parameter widgets (it's now supported in the code, just not exposed in the UI yet!).
The changes in that PR + the changes outlined here will make it easy to extend in future with other possible child algorithm parameter input types, such as a "calculate expression result before running child alg" type.
This is implemented in https://github.com/qgis/QGIS/pull/4812
QGIS Enhancement 84: Processing ModelerParametersDialog widget wrapper
Date 2016/12/13
Author Arnaud Morvan (@arnaud-morvan)
Contact arnaud dot morvan at camptocamp dot com
maintainer @arnaud-morvan
Version QGIS 3.0
Summary
For now, we have created widget wrappers to extract parameter type specific code from ParametersPanel, BatchDialog and ModelerParameterDialog. But it remains a lot of specific code for modeler in these widget wrappers.
The idea here is to factorize the part specific to modeler (model inputs selection in modeler algorithm parameter dialog).
Proposed Solution
My proposition is to create a modeler specific widget wrapper for modeler algorithm parameters dialog (the dialog that show up when you want to configure an algorithm inside a model). This new wrapper will be responsible to wrap the standard parameter widget with a model input selector.
Note that this ModelerWidgetWrapper class will have globally the same interface as standard widgets (createWidget, setValue and value methods), plus an option, in createWidget method, to give the compatible model inputs we want to propose to the user.
This will allow us to remove near to all the modeler specific part of code from standard widget wrappers, and will allow the user to use all the power of standard widgets from the algorithm dialog in the modeler algorithm dialog.
Example(s)
Here is an example code for the modeler widget wrapper that will be used by the ModelerParameterDialog exactly same way as standard wrapper by the ParametersPanel.
Here is the result on screen, with a drop down menu to select compatible model inputs:
Note that the UI appearance can be changed, for example we could use radio buttons (fixed values / model inputs) with a combo box for inputs, and this could be done easily transversally for all the parameter types.
IMHO it would be clearer for the user if the model values (model inputs and other algorithm outputs) are listed away from other values.
Affected Files
processing.gui.wrappers.py processing.modeler.ModelerParametersDialog.py
Performance Implications
Should have no effect on performance.
Further Considerations/Improvements
Backwards Compatibility
Full compatible with existing models, just an UI change.
Issue Tracking ID(s)
(optional)
Votes
(required)