mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
[processing] Add method for algorithms to preprocess parameter values
Allows algorithms to pre-processes a set of parameters, allowing the algorithm to clean their values. This method is automatically called after users enter parameters, e.g. via the algorithm dialog. This method should NOT be called manually by algorithms.
This commit is contained in:
parent
a93daf1437
commit
08d30c3b9f
@ -203,6 +203,15 @@ filled with explanatory text if validation fails.
|
||||
Overridden implementations should also check this base class implementation.
|
||||
|
||||
:return: true if parameters are acceptable for the algorithm.
|
||||
%End
|
||||
|
||||
virtual QVariantMap preprocessParameters( const QVariantMap ¶meters );
|
||||
%Docstring
|
||||
Pre-processes a set of ``parameters``, allowing the algorithm to clean their
|
||||
values.
|
||||
|
||||
This method is automatically called after users enter parameters, e.g. via the algorithm
|
||||
dialog. This method should NOT be called manually by algorithms.
|
||||
%End
|
||||
|
||||
QgsProcessingProvider *provider() const;
|
||||
|
@ -116,7 +116,7 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
if value:
|
||||
parameters[param.name()] = value
|
||||
|
||||
return parameters
|
||||
return self.algorithm().preprocessParameters(parameters)
|
||||
|
||||
def checkExtentCRS(self):
|
||||
unmatchingCRS = False
|
||||
|
@ -134,6 +134,8 @@ class BatchAlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
self.setProgressText(QCoreApplication.translate('BatchAlgorithmDialog', '\nProcessing algorithm {0}/{1}…').format(count + 1, len(alg_parameters)))
|
||||
self.setInfo(self.tr('<b>Algorithm {0} starting…</b>').format(self.algorithm().displayName()), escapeHtml=False)
|
||||
|
||||
parameters = self.algorithm().preprocessParameters(parameters)
|
||||
|
||||
feedback.pushInfo(self.tr('Input parameters:'))
|
||||
feedback.pushCommandInfo(pformat(parameters))
|
||||
feedback.pushInfo('')
|
||||
|
@ -98,6 +98,11 @@ bool QgsProcessingAlgorithm::checkParameterValues( const QVariantMap ¶meters
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariantMap QgsProcessingAlgorithm::preprocessParameters( const QVariantMap ¶meters )
|
||||
{
|
||||
return parameters;
|
||||
}
|
||||
|
||||
QgsProcessingProvider *QgsProcessingAlgorithm::provider() const
|
||||
{
|
||||
return mProvider;
|
||||
|
@ -232,6 +232,15 @@ class CORE_EXPORT QgsProcessingAlgorithm
|
||||
virtual bool checkParameterValues( const QVariantMap ¶meters,
|
||||
QgsProcessingContext &context, QString *message SIP_OUT = nullptr ) const;
|
||||
|
||||
/**
|
||||
* Pre-processes a set of \a parameters, allowing the algorithm to clean their
|
||||
* values.
|
||||
*
|
||||
* This method is automatically called after users enter parameters, e.g. via the algorithm
|
||||
* dialog. This method should NOT be called manually by algorithms.
|
||||
*/
|
||||
virtual QVariantMap preprocessParameters( const QVariantMap ¶meters );
|
||||
|
||||
/**
|
||||
* Returns the provider to which this algorithm belongs.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user