1010
1111
1212
13+
1314class QgsProcessingAlgorithm
1415{
1516%Docstring
@@ -76,6 +77,32 @@ class QgsProcessingAlgorithm
7677 :rtype: list of str
7778%End
7879
80+ virtual QString shortHelpString() const;
81+ %Docstring
82+ Returns a localised short helper string for the algorithm. This string should provide a basic description
83+ about what the algorithm does and the parameters and outputs associated with it.
84+ .. seealso:: helpString()
85+ .. seealso:: helpUrl()
86+ :rtype: str
87+ %End
88+
89+ virtual QString helpString() const;
90+ %Docstring
91+ Returns a localised help string for the algorithm. Algorithm subclasses should implement either
92+ helpString() or helpUrl().
93+ .. seealso:: helpUrl()
94+ .. seealso:: shortHelpString()
95+ :rtype: str
96+ %End
97+
98+ virtual QString helpUrl() const;
99+ %Docstring
100+ Returns a url pointing to the algorithm' s help page.
101+ .. seealso:: helpString()
102+ .. seealso:: shortHelpString()
103+ :rtype: str
104+ %End
105+
79106 virtual QIcon icon () const ;
80107%Docstring
81108 Returns an icon for the algorithm.
@@ -104,19 +131,38 @@ class QgsProcessingAlgorithm
104131 :rtype: Flags
105132%End
106133
134+ virtual bool canExecute( QString *errorMessage /Out/ = 0 ) const;
135+ %Docstring
136+ Returns true if the algorithm can execute. Algorithm subclasses can return false
137+ here to indicate that they are not able to execute, e.g. as a result of unmet
138+ external dependencies. If specified, the ``errorMessage`` argument will be filled
139+ with a localised error message describing why the algorithm cannot execute.
140+ :rtype: bool
141+ %End
142+
143+ virtual bool checkParameterValues( const QVariantMap ¶meters,
144+ QgsProcessingContext &context, QString *message /Out/ = 0 ) const;
145+ %Docstring
146+ Checks the supplied ``parameter`` values to verify that they satisfy the requirements
147+ of this algorithm in the supplied ``context``. The ``message`` parameter will be
148+ filled with explanatory text if validation fails.
149+ Overridden implementations should also check this base class implementation.
150+ :return: true if parameters are acceptable for the algorithm.
151+ :rtype: bool
152+ %End
153+
107154 QgsProcessingProvider *provider() const;
108155%Docstring
109156 Returns the provider to which this algorithm belongs.
110157 :rtype: QgsProcessingProvider
111158%End
112159
113- void setProvider ( QgsProcessingProvider *provider );
114-
115160 QgsProcessingParameterDefinitions parameterDefinitions() const;
116161%Docstring
117162 Returns an ordered list of parameter definitions utilized by the algorithm.
118163.. seealso:: addParameter()
119164.. seealso:: parameterDefinition()
165+ .. seealso:: destinationParameterDefinitions()
120166 :rtype: QgsProcessingParameterDefinitions
121167%End
122168
@@ -128,33 +174,97 @@ class QgsProcessingAlgorithm
128174 :rtype: QgsProcessingParameterDefinition
129175%End
130176
131- virtual QVariantMap run ( const QVariantMap ¶meters,
132- QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const ;
177+ int countVisibleParameters() const;
133178%Docstring
134- Runs the algorithm using the specified ``parameters``. Algorithms should implement
135- their custom processing logic here.
179+ Returns the number of visible (non-hidden) parameters defined by this
180+ algorithm.
181+ :rtype: int
182+ %End
183+
184+ QgsProcessingParameterDefinitions destinationParameterDefinitions() const;
185+ %Docstring
186+ Returns a list of destination parameters definitions utilized by the algorithm.
187+ .. seealso:: QgsProcessingParameterDefinition.isDestination()
188+ .. seealso:: parameterDefinitions()
189+ :rtype: QgsProcessingParameterDefinitions
190+ %End
191+
192+ QgsProcessingOutputDefinitions outputDefinitions() const;
193+ %Docstring
194+ Returns an ordered list of output definitions utilized by the algorithm.
195+ .. seealso:: addOutput()
196+ .. seealso:: outputDefinition()
197+ :rtype: QgsProcessingOutputDefinitions
198+ %End
199+
200+ const QgsProcessingOutputDefinition *outputDefinition( const QString &name ) const;
201+ %Docstring
202+ Returns a matching output by ``name``. Matching is done in a case-insensitive
203+ manner.
204+ .. seealso:: outputDefinitions()
205+ :rtype: QgsProcessingOutputDefinition
206+ %End
207+
208+ QVariantMap run( const QVariantMap ¶meters,
209+ QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const;
210+ %Docstring
211+ Executes the algorithm using the specified ``parameters``.
136212
137213 The ``context`` argument specifies the context in which the algorithm is being run.
138214
139- Algorithm progress should be reported using the supplied ``feedback`` object. Additionally,
140- well-behaved algorithms should periodically check ``feedback`` to determine whether the
141- algorithm should be canceled and exited early.
215+ Algorithm progress should be reported using the supplied ``feedback`` object.
142216
143217 :return: A map of algorithm outputs. These may be output layer references, or calculated
144218 values such as statistical calculations.
145219 :rtype: QVariantMap
146220%End
147221
222+ virtual QWidget *createCustomParametersWidget( QWidget *parent = 0 ) const /Factory/;
223+ %Docstring
224+ If an algorithm subclass implements a custom parameters widget, a copy of this widget
225+ should be constructed and returned by this method.
226+ The base class implementation returns None, which indicates that an autogenerated
227+ parameters widget should be used.
228+ :rtype: QWidget
229+ %End
230+
148231 protected:
149232
150233 bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/ );
151234%Docstring
152235 Adds a parameter ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
153236 Returns true if parameter could be successfully added, or false if the parameter could not be added (e.g.
154237 as a result of a duplicate name).
238+ .. seealso:: addOutput()
239+ :rtype: bool
240+ %End
241+
242+ bool addOutput( QgsProcessingOutputDefinition *outputDefinition /Transfer/ );
243+ %Docstring
244+ Adds an output ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
245+ Returns true if the output could be successfully added, or false if the output could not be added (e.g.
246+ as a result of a duplicate name).
247+ .. seealso:: addParameter()
155248 :rtype: bool
156249%End
157250
251+ virtual QVariantMap processAlgorithm( const QVariantMap ¶meters,
252+ QgsProcessingContext &context, QgsProcessingFeedback *feedback ) const = 0;
253+ %Docstring
254+ Runs the algorithm using the specified ``parameters``. Algorithms should implement
255+ their custom processing logic here.
256+
257+ The ``context`` argument specifies the context in which the algorithm is being run.
258+
259+ Algorithm progress should be reported using the supplied ``feedback`` object. Additionally,
260+ well-behaved algorithms should periodically check ``feedback`` to determine whether the
261+ algorithm should be canceled and exited early.
262+
263+ :return: A map of algorithm outputs. These may be output layer references, or calculated
264+ values such as statistical calculations.
265+ :rtype: QVariantMap
266+ %End
267+
158268 QString parameterAsString( const QVariantMap ¶meters, const QString &name, const QgsProcessingContext &context ) const;
159269%Docstring
160270 Evaluates the parameter with matching ``name`` to a static string value.
@@ -197,6 +307,36 @@ class QgsProcessingAlgorithm
197307 :rtype: bool
198308%End
199309
310+ QgsFeatureSink *parameterAsSink( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context,
311+ const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
312+ QString &destinationIdentifier /Out/ ) const /Factory/;
313+ %Docstring
314+ Evaluates the parameter with matching ``name`` to a feature sink.
315+
316+ Sinks will either be taken from ``context``' s active project, or created from external
317+ providers and stored temporarily in the ``context``.
318+
319+ The ``fields``, ``geometryType`` and ``crs`` parameters dictate the properties
320+ of the resulting feature sink.
321+
322+ The ``destinationIdentifier`` argument will be set to a string which can be used to retrieve the layer corresponding
323+ to the sink, e.g. via calling QgsProcessingUtils.mapLayerFromString().
324+
325+ This function creates a new object and the caller takes responsibility for deleting the returned object.
326+ :rtype: QgsFeatureSink
327+ %End
328+
329+ QgsFeatureSource *parameterAsSource ( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const /Factory/;
330+ %Docstring
331+ Evaluates the parameter with matching ``definition`` to a feature source.
332+
333+ Sources will either be taken from ``context``' s active project, or loaded from external
334+ sources and stored temporarily in the ``context``.
335+
336+ This function creates a new object and the caller takes responsibility for deleting the returned object.
337+ :rtype: QgsFeatureSource
338+ %End
339+
200340 QgsMapLayer *parameterAsLayer( const QVariantMap ¶meters, const QString &name, QgsProcessingContext &context ) const;
201341%Docstring
202342 Evaluates the parameter with matching ``name`` to a map layer.
@@ -285,6 +425,8 @@ QFlags<QgsProcessingAlgorithm::Flag> operator|(QgsProcessingAlgorithm::Flag f1,
285425
286426
287427
428+
429+
288430/* ***********************************************************************
289431 * This file has been generated automatically from *
290432 * *
0 commit comments