Skip to content


Browse files Browse the repository at this point in the history
Merge pull request #3966 from nyalldawson/proc_prov_c
[processing] Port some stuff to c++
  • Loading branch information
nyalldawson committed Jan 11, 2017
2 parents 243f01c + 04eb293 commit 26a8a54
Show file tree
Hide file tree
Showing 73 changed files with 936 additions and 363 deletions.
1 change: 1 addition & 0 deletions doc/CMakeLists.txt
Expand Up @@ -58,6 +58,7 @@ IF(WITH_APIDOC)
Expand Down
4 changes: 4 additions & 0 deletions doc/api_break.dox
Expand Up @@ -1826,7 +1826,11 @@ optional property map passing down layer level properties to the SLD encoders. I
- setScaleMethodToSymbol was removed. This is now handled using data defined scaling at a symbol layer level
- usedAttributes is now a const method and returns QSet<QString> instead of QStringList

Processing {#qgis_api_break_3_0_Processing}

- Algorithm providers now subclass the c++ QgsProcessingProvider class, and must be adapted to the API for QgsProcessingProvider. Specifically,
getName() should be replaced with id(), getDescription() with name(), and getIcon with icon().

QGIS 2.4 {#qgis_api_break_2_4}
Expand Down
8 changes: 8 additions & 0 deletions images/images.qrc
Expand Up @@ -550,6 +550,14 @@
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions python/CMakeLists.txt
Expand Up @@ -106,6 +106,7 @@ INCLUDE_DIRECTORIES(

Expand Down
3 changes: 3 additions & 0 deletions python/core/core.sip
Expand Up @@ -259,6 +259,9 @@
%Include layertree/qgslayertreeregistrybridge.sip
%Include layertree/qgslayertreeutils.sip

%Include processing/qgsprocessingprovider.sip
%Include processing/qgsprocessingregistry.sip

%Include raster/qgsbilinearrasterresampler.sip
%Include raster/qgsbrightnesscontrastfilter.sip
%Include raster/qgscliptominmaxenhancement.sip
Expand Down
56 changes: 56 additions & 0 deletions python/core/processing/qgsprocessingprovider.sip
@@ -0,0 +1,56 @@
* \class QgsProcessingProvider
* \ingroup core
* Abstract base class for processing providers. An algorithm provider is a set of
* related algorithms, typically from the same external application or related
* to a common area of analysis.
* \note added in QGIS 3.0
class QgsProcessingProvider
#include <qgsprocessingprovider.h>



virtual ~QgsProcessingProvider();

* Returns an icon for the provider.
* @see svgIcon()
virtual QIcon icon() const;

* Returns a path to an SVG version of the provider's icon.
* @see icon()
virtual QString svgIconPath() const;

* Returns the unique provider id, used for identifying the provider. This string
* should be a unique, short, character only string, eg "qgis" or "gdal". This
* string should not be localised.
* @see name()
virtual QString id() const = 0;

* Returns the full provider name, which is used to describe the provider within the GUI.
* This string should be localised.
* @see id()
virtual QString name() const = 0;

virtual bool canBeActivated() const;


//! Providers cannot be copied
QgsProcessingProvider( const QgsProcessingProvider& other );
//! Providers cannot be copied
//QgsProcessingProvider& operator=( const QgsProcessingProvider& other );
72 changes: 72 additions & 0 deletions python/core/processing/qgsprocessingregistry.sip
@@ -0,0 +1,72 @@
* \class QgsProcessingRegistry
* \ingroup core
* Registry for various processing components, including providers, algorithms
* and various parameters and outputs.
* QgsProcessingRegistry is not usually directly created, but rather accessed through
* QgsApplication::processingRegistry().
* \note added in QGIS 3.0
class QgsProcessingRegistry : QObject
#include <qgsprocessingregistry.h>


* Constructor for QgsProcessingRegistry.
QgsProcessingRegistry( QObject* parent /TransferThis/ = nullptr );


* Get list of available providers.
QList<QgsProcessingProvider*> providers() const;

* Add a processing provider to the registry. Ownership of the provider is transferred to the registry.
* Returns false if the provider could not be added (eg if a provider with a duplicate ID already exists
* in the registry).
* @see removeProvider()
bool addProvider( QgsProcessingProvider* provider /Transfer/ );

* Removes a provider implementation from the registry (the provider object is deleted).
* Returns false if the provider could not be removed (eg provider does not exist in the registry).
* @see addProvider()
bool removeProvider( QgsProcessingProvider* provider );

* Removes a provider implementation from the registry (the provider object is deleted).
* Returns false if the provider could not be removed (eg provider does not exist in the registry).
* @see addProvider()
bool removeProvider( const QString& providerId );

* Returns a matching provider by provider ID.
QgsProcessingProvider* providerById( const QString& id );


//! Emitted when a provider has been added to the registry.
void providerAdded( const QString& id );

//! Emitted when a provider is removed from the registry
void providerRemoved( const QString& id );


//! Registry cannot be copied
QgsProcessingRegistry( const QgsProcessingRegistry& other );
//! Registry cannot be copied
//QgsProcessingRegistry& operator=( const QgsProcessingRegistry& other );
7 changes: 7 additions & 0 deletions python/core/qgsapplication.sip
Expand Up @@ -442,6 +442,13 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
static QgsMessageLog* messageLog();

* Returns the application's processing registry, used for managing processing providers,
* algorithms, and various parameters and outputs.
* @note added in QGIS 3.0
static QgsProcessingRegistry* processingRegistry();

//dummy method to workaround sip generation issue issue
bool x11EventFilter ( XEvent * event );
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/
Expand Up @@ -72,13 +72,13 @@ def initGui(self):
self.toolboxAction = self.toolbox.toggleViewAction()
QIcon(os.path.join(cmd_folder, 'images', 'alg.svg')))
self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T')

self.modelerAction = QAction(
QIcon(os.path.join(cmd_folder, 'images', 'model.svg')),
QgsApplication.getThemeIcon("/processingModel.svg"),'Graphical &Modeler...'), self.iface.mainWindow())
Expand Down
Expand Up @@ -35,7 +35,7 @@ class ExampleAlgorithmProvider(AlgorithmProvider):

def __init__(self):

# Deactivate provider by default
self.activate = False
Expand Down Expand Up @@ -66,23 +66,23 @@ def unload(self):

def getName(self):
def id(self):
"""This is the name that will appear on the toolbox group.
It is also used to create the command line name of all the
algorithms from this provider.
return 'Example provider'

def getDescription(self):
def name(self):
"""This is the provired full name.
return 'Example algorithms'

def getIcon(self):
def icon(self):
"""We return the default icon.
return AlgorithmProvider.getIcon(self)
return AlgorithmProvider.icon(self)

def _loadAlgorithms(self):
"""Here we fill the list of algorithms in self.algs.
Expand Down
4 changes: 3 additions & 1 deletion python/plugins/processing/algs/gdal/
Expand Up @@ -31,6 +31,8 @@
from qgis.PyQt.QtGui import QIcon
from qgis.PyQt.QtCore import QUrl

from qgis.core import QgsApplication

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.algs.gdal.GdalAlgorithmDialog import GdalAlgorithmDialog
from processing.algs.gdal.GdalUtils import GdalUtils
Expand All @@ -48,7 +50,7 @@ def __init__(self):

def getIcon(self):
if self._icon is None:
self._icon = QIcon(os.path.join(pluginPath, 'images', 'gdal.svg'))
self._icon = QgsApplication.getThemeIcon("/providerGdal.svg")
return self._icon

def getCustomParametersDialog(self):
Expand Down

0 comments on commit 26a8a54

Please sign in to comment.