Skip to content
Permalink
Browse files

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 26a8a54c00ff747793fc825f0c6e81638b92dd12
Showing with 936 additions and 363 deletions.
  1. +1 −0 doc/CMakeLists.txt
  2. +4 −0 doc/api_break.dox
  3. +8 −0 images/images.qrc
  4. 0 python/plugins/processing/images/alg.svg → images/themes/default/processingAlgorithm.svg
  5. 0 python/plugins/processing/images/model.svg → images/themes/default/processingModel.svg
  6. 0 python/plugins/processing/images/script.svg → images/themes/default/processingScript.svg
  7. 0 python/plugins/processing/images/gdal.svg → images/themes/default/providerGdal.svg
  8. 0 python/plugins/processing/images/grass.svg → images/themes/default/providerGrass.svg
  9. 0 python/plugins/processing/images/qgis.svg → images/themes/default/providerQgis.svg
  10. 0 python/plugins/processing/images/r.svg → images/themes/default/providerR.svg
  11. +9 −76 python/plugins/processing/images/taudem.svg → images/themes/default/providerTaudem.svg
  12. +1 −0 python/CMakeLists.txt
  13. +3 −0 python/core/core.sip
  14. +56 −0 python/core/processing/qgsprocessingprovider.sip
  15. +72 −0 python/core/processing/qgsprocessingregistry.sip
  16. +7 −0 python/core/qgsapplication.sip
  17. +2 −2 python/plugins/processing/ProcessingPlugin.py
  18. +5 −5 python/plugins/processing/algs/exampleprovider/ExampleAlgorithmProvider.py
  19. +3 −1 python/plugins/processing/algs/gdal/GdalAlgorithm.py
  20. +10 −6 python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py
  21. +3 −2 python/plugins/processing/algs/grass7/Grass7Algorithm.py
  22. +13 −9 python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py
  23. +7 −7 python/plugins/processing/algs/lidar/LidarToolsAlgorithmProvider.py
  24. +8 −8 python/plugins/processing/algs/otb/OTBAlgorithmProvider.py
  25. +12 −7 python/plugins/processing/algs/qgis/QGISAlgorithmProvider.py
  26. +3 −1 python/plugins/processing/algs/r/RAlgorithm.py
  27. +13 −10 python/plugins/processing/algs/r/RAlgorithmProvider.py
  28. +5 −5 python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
  29. +2 −2 python/plugins/processing/algs/taudem/TauDEMAlgorithm.py
  30. +13 −8 python/plugins/processing/algs/taudem/TauDEMAlgorithmProvider.py
  31. +3 −1 python/plugins/processing/algs/taudem/dinfdistdown.py
  32. +3 −1 python/plugins/processing/algs/taudem/dinfdistup.py
  33. +3 −1 python/plugins/processing/algs/taudem/dinftranslimaccum.py
  34. +3 −1 python/plugins/processing/algs/taudem/dinftranslimaccum2.py
  35. +3 −1 python/plugins/processing/algs/taudem/dropanalysis.py
  36. +3 −1 python/plugins/processing/algs/taudem/gridnet.py
  37. +3 −1 python/plugins/processing/algs/taudem/lengtharea.py
  38. +4 −2 python/plugins/processing/algs/taudem/peukerdouglas.py
  39. +2 −2 python/plugins/processing/algs/taudem/slopearea.py
  40. +7 −23 python/plugins/processing/core/AlgorithmProvider.py
  41. +3 −4 python/plugins/processing/core/GeoAlgorithm.py
  42. +17 −21 python/plugins/processing/core/Processing.py
  43. +5 −4 python/plugins/processing/core/ProcessingConfig.py
  44. +13 −22 python/plugins/processing/core/alglist.py
  45. +1 −1 python/plugins/processing/gui/BatchPanel.py
  46. +5 −4 python/plugins/processing/gui/ConfigDialog.py
  47. +4 −2 python/plugins/processing/gui/CreateNewScriptAction.py
  48. +9 −7 python/plugins/processing/gui/GetScriptsAndModels.py
  49. +40 −38 python/plugins/processing/gui/ProcessingToolbox.py
  50. +2 −3 python/plugins/processing/gui/ScriptEditorDialog.py
  51. +4 −2 python/plugins/processing/gui/ToolboxAction.py
  52. +2 −1 python/plugins/processing/gui/menus.py
  53. +4 −1 python/plugins/processing/modeler/AddModelFromFileAction.py
  54. +4 −1 python/plugins/processing/modeler/CreateNewModelAction.py
  55. +2 −2 python/plugins/processing/modeler/ModelerAlgorithm.py
  56. +11 −6 python/plugins/processing/modeler/ModelerAlgorithmProvider.py
  57. +9 −9 python/plugins/processing/modeler/ModelerDialog.py
  58. +3 −6 python/plugins/processing/preconfigured/PreconfiguredAlgorithmProvider.py
  59. +3 −2 python/plugins/processing/script/AddScriptFromFileAction.py
  60. +3 −2 python/plugins/processing/script/CreateScriptCollectionPluginAction.py
  61. +7 −4 python/plugins/processing/script/ScriptAlgorithm.py
  62. +11 −6 python/plugins/processing/script/ScriptAlgorithmProvider.py
  63. +2 −2 python/plugins/processing/script/ScriptSelector.py
  64. +2 −2 python/plugins/processing/tools/help.py
  65. +8 −0 src/core/CMakeLists.txt
  66. +29 −0 src/core/processing/qgsprocessingprovider.cpp
  67. +86 −0 src/core/processing/qgsprocessingprovider.h
  68. +71 −0 src/core/processing/qgsprocessingregistry.cpp
  69. +101 −0 src/core/processing/qgsprocessingregistry.h
  70. +8 −14 src/core/qgsapplication.cpp
  71. +23 −14 src/core/qgsapplication.h
  72. +2 −0 tests/src/core/CMakeLists.txt
  73. +148 −0 tests/src/core/testqgsprocessing.cpp
@@ -58,6 +58,7 @@ IF(WITH_APIDOC)
${CMAKE_SOURCE_DIR}/src/core/gps
${CMAKE_SOURCE_DIR}/src/core/layertree
${CMAKE_SOURCE_DIR}/src/core/pal
${CMAKE_SOURCE_DIR}/src/core/processing
${CMAKE_SOURCE_DIR}/src/core/raster
${CMAKE_SOURCE_DIR}/src/core/symbology-ng
${CMAKE_SOURCE_DIR}/src/gui
@@ -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}
@@ -550,6 +550,14 @@
<file>themes/default/mTaskRunning.svg</file>
<file>themes/default/mTaskTerminated.svg</file>
<file>themes/default/mTaskCancel.svg</file>
<file>themes/default/providerGdal.svg</file>
<file>themes/default/providerGrass.svg</file>
<file>themes/default/providerQgis.svg</file>
<file>themes/default/providerR.svg</file>
<file>themes/default/providerTaudem.svg</file>
<file>themes/default/processingModel.svg</file>
<file>themes/default/processingScript.svg</file>
<file>themes/default/processingAlgorithm.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
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.
@@ -13,11 +13,11 @@
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg3399"
version="1.1"
inkscape:version="0.91 r13725"
inkscape:version="0.92pre3 r"
width="25.4mm"
height="25.4mm"
viewBox="0 0 89.999998 89.999999"
sodipodi:docname="taudem.svg">
sodipodi:docname="providerTaudem.svg">
<metadata
id="metadata3405">
<rdf:RDF>
@@ -32,30 +32,6 @@
</metadata>
<defs
id="defs3403">
<linearGradient
inkscape:collect="always"
id="linearGradient5605">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop5607" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop5610" />
</linearGradient>
<linearGradient
inkscape:collect="always"
id="linearGradient5613">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop5615" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop5617" />
</linearGradient>
<linearGradient
id="linearGradient5607"
osb:paint="solid">
@@ -94,35 +70,6 @@
y2="699.9278"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(0,-654.09448)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5589"
id="linearGradient5593"
x1="54.945377"
y1="51.502598"
x2="85.780338"
y2="51.502598"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5613"
id="linearGradient5619"
x1="54.445377"
y1="51.502598"
x2="86.280338"
y2="51.502598"
gradientUnits="userSpaceOnUse" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient5605"
id="radialGradient5612"
cx="71.826358"
cy="50.677773"
fx="71.826358"
fy="50.677773"
r="15.378681"
gradientTransform="matrix(1,0,0,0.317652,0,34.579877)"
gradientUnits="userSpaceOnUse" />
</defs>
<sodipodi:namedview
pagecolor="#ffffff"
@@ -133,8 +80,8 @@
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="714"
inkscape:window-width="1920"
inkscape:window-height="1016"
id="namedview3401"
showgrid="false"
fit-margin-top="0"
@@ -143,12 +90,12 @@
fit-margin-bottom="0"
units="mm"
inkscape:zoom="2.1213203"
inkscape:cx="-78.093983"
inkscape:cy="46.505347"
inkscape:cx="37.400126"
inkscape:cy="64.418719"
inkscape:window-x="0"
inkscape:window-y="25"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="layer1" />
inkscape:current-layer="layer3" />
<g
inkscape:groupmode="layer"
id="layer1"
@@ -178,19 +125,5 @@
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="dem">
<text
xml:space="preserve"
style="font-style:italic;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.07694149px;line-height:125%;font-family:Sans;-inkscape-font-specification:'Sans Bold Italic';letter-spacing:0px;word-spacing:0px;opacity:0.766;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.966;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;"
x="56.677109"
y="55.079842"
id="text4139"
sodipodi:linespacing="125%"
transform="scale(0.97457262,1.0260908)"><tspan
sodipodi:role="line"
id="tspan4141"
x="56.677109"
y="55.079842"
style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:0.966;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-linejoin:round;stroke-linecap:round;">DEM</tspan></text>
</g>
inkscape:label="dem" />
</svg>
@@ -106,6 +106,7 @@ INCLUDE_DIRECTORIES(
../src/core/geometry
../src/core/gps
../src/core/layertree
../src/core/processing
../src/core/raster
../src/core/symbology-ng

@@ -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
@@ -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
{
%TypeHeaderCode
#include <qgsprocessingprovider.h>
%End

public:

QgsProcessingProvider();

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;

private:

//! Providers cannot be copied
QgsProcessingProvider( const QgsProcessingProvider& other );
//! Providers cannot be copied
//QgsProcessingProvider& operator=( const QgsProcessingProvider& other );
};
@@ -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
{
%TypeHeaderCode
#include <qgsprocessingregistry.h>
%End

public:

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

~QgsProcessingRegistry();

/**
* 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 );

signals:

//! 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 );

private:

//! Registry cannot be copied
QgsProcessingRegistry( const QgsProcessingRegistry& other );
//! Registry cannot be copied
//QgsProcessingRegistry& operator=( const QgsProcessingRegistry& other );
};
@@ -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();

%If(ANDROID)
//dummy method to workaround sip generation issue issue
bool x11EventFilter ( XEvent * event );
@@ -72,13 +72,13 @@ def initGui(self):
self.toolboxAction = self.toolbox.toggleViewAction()
self.toolboxAction.setObjectName('toolboxAction')
self.toolboxAction.setIcon(
QIcon(os.path.join(cmd_folder, 'images', 'alg.svg')))
QgsApplication.getThemeIcon("/processingAlgorithm.svg"))
self.toolboxAction.setText(self.tr('&Toolbox'))
self.iface.registerMainWindowAction(self.toolboxAction, 'Ctrl+Alt+T')
self.menu.addAction(self.toolboxAction)

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

def __init__(self):
AlgorithmProvider.__init__(self)
super().__init__()

# Deactivate provider by default
self.activate = False
@@ -66,23 +66,23 @@ def unload(self):
ProcessingConfig.removeSetting(
ExampleAlgorithmProvider.MY_DUMMY_SETTING)

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.
@@ -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
@@ -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):

0 comments on commit 26a8a54

Please sign in to comment.
You can’t perform that action at this time.