QGIS API Documentation 4.3.0-Master (45633be667c)
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
32 % End
33// clang-format on
34#endif
35
44 class CORE_EXPORT QgsProcessingProvider : public QObject
45{
46#ifdef SIP_RUN
48 if ( qobject_cast<QgsProcessingProjectModelProvider *>( sipCpp ) )
49 sipType = sipType_QgsProcessingProjectModelProvider;
50 else if ( qobject_cast<QgsProcessingModelProvider *>( sipCpp ) )
51 sipType = sipType_QgsProcessingModelProvider;
52 else
53 sipType = nullptr;
55#endif
56
57 Q_OBJECT
58
59 public:
63 QgsProcessingProvider( QObject *parent SIP_TRANSFERTHIS = nullptr );
64
65 ~QgsProcessingProvider() override;
66
69
70 // clang-format off
75 virtual QIcon icon() const SIP_HOLDGIL;
76 // clang-format on
77
82 virtual QString svgIconPath() const SIP_HOLDGIL;
83
89 virtual Qgis::ProcessingProviderFlags flags() const SIP_HOLDGIL;
90
98 virtual QString id() const = 0 SIP_HOLDGIL;
99
106 virtual QString helpId() const SIP_HOLDGIL;
107
114 virtual QString name() const = 0 SIP_HOLDGIL;
115
126 virtual QString longName() const SIP_HOLDGIL;
127
136 virtual QString versionInfo() const SIP_HOLDGIL;
137
143 virtual bool canBeActivated() const { return true; }
144
155 virtual QString warningMessage() const { return QString(); }
156
160 virtual bool isActive() const { return true; }
161
171 QStringList supportedOutputRasterLayerExtensions() const;
172
178 virtual QList<QPair<QString, QString>> supportedOutputRasterLayerFormatAndExtensions() const;
179
185 static QList<QPair<QString, QString>> supportedOutputRasterLayerFormatAndExtensionsDefault() SIP_SKIP;
186
196 virtual QStringList supportedOutputVectorLayerExtensions() const;
197
209 virtual QStringList supportedOutputPointCloudLayerExtensions() const;
210
224 virtual QStringList supportedOutputVectorTileLayerExtensions() const;
225
240 virtual QStringList supportedOutputTableExtensions() const;
241
249 virtual bool isSupportedOutputValue( const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error SIP_OUT ) const;
250
267 virtual QString defaultVectorFileExtension( bool hasGeometry = true ) const;
268
282 virtual QString defaultRasterFileFormat() const;
283
296 QString defaultRasterFileExtension() const;
297
313 virtual QString defaultPointCloudFileExtension() const;
314
329 virtual QString defaultVectorTileFileExtension() const;
330
344 virtual bool supportsNonFileBasedOutput() const;
345
355 virtual bool load() { refreshAlgorithms(); return true; }
356
361 virtual void unload() {}
362
366 void refreshAlgorithms();
367
372 QList< const QgsProcessingAlgorithm * > algorithms() const;
373
379 const QgsProcessingAlgorithm *algorithm( const QString &name ) const;
380
381 signals:
382
389
390 protected:
391
396 virtual void loadAlgorithms() = 0;
397
402
403 private:
404
405 QMap< QString, const QgsProcessingAlgorithm * > mAlgorithms;
406
407#ifdef SIP_RUN
409#endif
410};
411
412#endif // QGSPROCESSINGPROVIDER_H
413
414
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