QGIS API Documentation 4.3.0-Master (01f22706ec5)
Loading...
Searching...
No Matches
qgsprocessingprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingprovider.h
3 ------------------------
4 begin : December 2016
5 copyright : (C) 2016 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPROCESSINGPROVIDER_H
19#define QGSPROCESSINGPROVIDER_H
20
21#include "qgis.h"
22#include "qgis_core.h"
24
25#include <QIcon>
26
27#ifdef SIP_RUN
28// clang-format off
29% ModuleHeaderCode
31 % End
32// clang-format on
33#endif
34
43 class CORE_EXPORT QgsProcessingProvider : public QObject
44{
45#ifdef SIP_RUN
47 if ( qobject_cast<QgsProcessingProjectModelProvider *>( sipCpp ) )
48 sipType = sipType_QgsProcessingProjectModelProvider;
49 else
50 sipType = nullptr;
52#endif
53
54 Q_OBJECT
55
56 public:
60 QgsProcessingProvider( QObject *parent SIP_TRANSFERTHIS = nullptr );
61
62 ~QgsProcessingProvider() override;
63
66
67 // clang-format off
72 virtual QIcon icon() const SIP_HOLDGIL;
73 // clang-format on
74
79 virtual QString svgIconPath() const SIP_HOLDGIL;
80
86 virtual Qgis::ProcessingProviderFlags flags() const SIP_HOLDGIL;
87
95 virtual QString id() const = 0 SIP_HOLDGIL;
96
103 virtual QString helpId() const SIP_HOLDGIL;
104
111 virtual QString name() const = 0 SIP_HOLDGIL;
112
123 virtual QString longName() const SIP_HOLDGIL;
124
133 virtual QString versionInfo() const SIP_HOLDGIL;
134
140 virtual bool canBeActivated() const { return true; }
141
152 virtual QString warningMessage() const { return QString(); }
153
157 virtual bool isActive() const { return true; }
158
168 QStringList supportedOutputRasterLayerExtensions() const;
169
175 virtual QList<QPair<QString, QString>> supportedOutputRasterLayerFormatAndExtensions() const;
176
182 static QList<QPair<QString, QString>> supportedOutputRasterLayerFormatAndExtensionsDefault() SIP_SKIP;
183
193 virtual QStringList supportedOutputVectorLayerExtensions() const;
194
206 virtual QStringList supportedOutputPointCloudLayerExtensions() const;
207
221 virtual QStringList supportedOutputVectorTileLayerExtensions() const;
222
237 virtual QStringList supportedOutputTableExtensions() const;
238
246 virtual bool isSupportedOutputValue( const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error SIP_OUT ) const;
247
264 virtual QString defaultVectorFileExtension( bool hasGeometry = true ) const;
265
279 virtual QString defaultRasterFileFormat() const;
280
293 QString defaultRasterFileExtension() const;
294
310 virtual QString defaultPointCloudFileExtension() const;
311
326 virtual QString defaultVectorTileFileExtension() const;
327
341 virtual bool supportsNonFileBasedOutput() const;
342
352 virtual bool load() { refreshAlgorithms(); return true; }
353
358 virtual void unload() {}
359
363 void refreshAlgorithms();
364
369 QList< const QgsProcessingAlgorithm * > algorithms() const;
370
376 const QgsProcessingAlgorithm *algorithm( const QString &name ) const;
377
378 signals:
379
386
387 protected:
388
393 virtual void loadAlgorithms() = 0;
394
399
400 private:
401
402 QMap< QString, const QgsProcessingAlgorithm * > mAlgorithms;
403
404#ifdef SIP_RUN
406#endif
407};
408
409#endif // QGSPROCESSINGPROVIDER_H
410
411
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
Base class for all parameter definitions which represent file or layer destinations,...
virtual QIcon icon() const
Returns an icon for the provider.
QgsProcessingProvider(const QgsProcessingProvider &other)=delete
virtual QString helpId() const
Returns the provider help id string, used for creating QgsHelp urls for algorithms belong to this pro...
const QgsProcessingAlgorithm * algorithm(const QString &name) const
Returns the matching algorithm by name, or nullptr if no matching algorithm is contained by this prov...
virtual Qgis::ProcessingProviderFlags flags() const
Returns the flags indicating how and when the provider operates and should be exposed to users.
virtual QString versionInfo() const
Returns a version information string for the provider, or an empty string if this is not applicable (...
virtual QString name() const =0
Returns the provider name, which is used to describe the provider within the GUI.
QgsProcessingProvider(QObject *parent=nullptr)
Constructor for QgsProcessingProvider.
virtual bool isActive() const
Returns true if the provider is active and able to run algorithms.
void algorithmsLoaded()
Emitted when the provider has loaded (or refreshed) its list of available algorithms.
virtual QString svgIconPath() const
Returns a path to an SVG version of the provider's icon.
virtual void unload()
Unloads the provider.
virtual bool load()
Loads the provider.
virtual void loadAlgorithms()=0
Loads all algorithms belonging to this provider.
virtual bool canBeActivated() const
Returns true if the provider can be activated, or false if it cannot be activated (e....
void refreshAlgorithms()
Refreshes the algorithms available from the provider, causing it to re-populate with all associated a...
virtual QString longName() const
Returns the longer version of the provider name, which can include extra details such as version numb...
virtual QString warningMessage() const
Returns an optional warning message to show users when running algorithms from this provider.
QgsProcessingProvider & operator=(const QgsProcessingProvider &other)=delete
bool addAlgorithm(QgsProcessingAlgorithm *algorithm)
Adds an algorithm to the provider.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:203
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_HOLDGIL
Definition qgis_sip.h:183
#define SIP_END
Definition qgis_sip.h:220