Skip to content
Permalink
Browse files

Add native c++ algorithm provider

  • Loading branch information
nyalldawson committed Jun 5, 2017
1 parent b64a71d commit 8b4bf88b35e789a9a9bf0f8aaeb5fd49801f301f
@@ -26,6 +26,43 @@

///@cond PRIVATE

QgsNativeAlgorithms::QgsNativeAlgorithms( QObject *parent )
: QgsProcessingProvider( parent )
{}

QIcon QgsNativeAlgorithms::icon() const
{
return QgsApplication::getThemeIcon( QStringLiteral( "/providerQgis.svg" ) );
}

QString QgsNativeAlgorithms::svgIconPath() const
{
return QgsApplication::iconPath( QStringLiteral( "providerQgis.svg" ) );
}

QString QgsNativeAlgorithms::id() const
{
return QStringLiteral( "native" );
}

QString QgsNativeAlgorithms::name() const
{
return tr( "QGIS" );
}

bool QgsNativeAlgorithms::supportsNonFileBasedOutput() const
{
return true;
}

void QgsNativeAlgorithms::loadAlgorithms()
{
addAlgorithm( new QgsCentroidAlgorithm() );
addAlgorithm( new QgsBufferAlgorithm() );
}



QgsCentroidAlgorithm::QgsCentroidAlgorithm()
{
addParameter( new QgsProcessingParameterVector( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
@@ -21,9 +21,28 @@
#include "qgis_core.h"
#include "qgis.h"
#include "qgsprocessingalgorithm.h"
#include "qgsprocessingprovider.h"

///@cond PRIVATE

class QgsNativeAlgorithms: public QgsProcessingProvider
{
public:

QgsNativeAlgorithms( QObject *parent = nullptr );

QIcon icon() const override;
QString svgIconPath() const override;
QString id() const override;
QString name() const override;
bool supportsNonFileBasedOutput() const override;

protected:

void loadAlgorithms() override;

};

/**
* Native centroid algorithm.
*/
@@ -54,7 +73,7 @@ class QgsBufferAlgorithm : public QgsProcessingAlgorithm

QgsBufferAlgorithm();

QString name() const override { return QStringLiteral( "fixeddistancebuffer" ); }
QString name() const override { return QStringLiteral( "buffer" ); }
QString displayName() const override { return QObject::tr( "Buffer" ); }
virtual QStringList tags() const override { return QObject::tr( "buffer,grow" ).split( ',' ); }
QString group() const override { return QObject::tr( "Vector geometry tools" ); }
@@ -40,6 +40,7 @@

#include "gps/qgsgpsconnectionregistry.h"
#include "processing/qgsprocessingregistry.h"
#include "processing/qgsnativealgorithms.h"

#include <QDir>
#include <QFile>
@@ -1578,6 +1579,7 @@ QgsApplication::ApplicationMembers::ApplicationMembers()
mGpsConnectionRegistry = new QgsGPSConnectionRegistry();
mPluginLayerRegistry = new QgsPluginLayerRegistry();
mProcessingRegistry = new QgsProcessingRegistry();
mProcessingRegistry->addProvider( new QgsNativeAlgorithms( mProcessingRegistry ) );
mAnnotationRegistry = new QgsAnnotationRegistry();
}

0 comments on commit 8b4bf88

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