Skip to content

Commit

Permalink
Rename QgsProcessingParameterOutputVectorLayer to QgsProcessingParame…
Browse files Browse the repository at this point in the history
…terFeatureSink
  • Loading branch information
nyalldawson committed Jun 5, 2017
1 parent 770c45d commit 5b8affc
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
20 changes: 10 additions & 10 deletions python/core/processing/qgsprocessingparameters.sip
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class QgsProcessingParameterDefinition
sipType = sipType_QgsProcessingParameterTableField;
else if ( sipCpp->type() == "source" )
sipType = sipType_QgsProcessingParameterFeatureSource;
else if ( sipCpp->type() == "vectorOut" )
sipType = sipType_QgsProcessingParameterOutputVectorLayer;
else if ( sipCpp->type() == "sink" )
sipType = sipType_QgsProcessingParameterFeatureSink;
%End
public:

Expand Down Expand Up @@ -1058,12 +1058,12 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition
};


class QgsProcessingParameterOutputVectorLayer : QgsProcessingParameterDefinition
class QgsProcessingParameterFeatureSink : QgsProcessingParameterDefinition
{
%Docstring
A vector layer output for processing algorithms.
A feature sink output for processing algorithms.

A parameter which represents the destination for a vector layer created by an algorithm.
A parameter which represents the destination feature sink for features created by an algorithm.
.. versionadded:: 3.0
%End

Expand All @@ -1072,10 +1072,10 @@ class QgsProcessingParameterOutputVectorLayer : QgsProcessingParameterDefinition
%End
public:

QgsProcessingParameterOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );
QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterOutputVectorLayer.
Constructor for QgsProcessingParameterFeatureSink.
%End

virtual QString type() const;
Expand All @@ -1085,14 +1085,14 @@ class QgsProcessingParameterOutputVectorLayer : QgsProcessingParameterDefinition

QgsProcessingParameterDefinition::LayerType dataType() const;
%Docstring
Returns the layer type for the output layer associated with the parameter.
Returns the layer type for sinks associated with the parameter.
.. seealso:: setDataType()
:rtype: QgsProcessingParameterDefinition.LayerType
%End

void setDataType( QgsProcessingParameterDefinition::LayerType type );
%Docstring
Sets the layer ``type`` for the output layer associated with the parameter.
Sets the layer ``type`` for the sinks associated with the parameter.
.. seealso:: dataType()
%End

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/qgis/Boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
QgsProcessingUtils,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterOutputVectorLayer,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer)

from qgis.PyQt.QtGui import QIcon
Expand All @@ -54,7 +54,7 @@ class Boundary(QgisAlgorithm):
def __init__(self):
super().__init__()
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorLine, QgsProcessingParameterDefinition.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterOutputVectorLayer(self.OUTPUT_LAYER, self.tr('Boundary')))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Boundary')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT_LAYER, self.tr("Boundaries")))

def icon(self):
Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/AlgorithmDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
QgsMessageLog,
QgsProcessingParameterDefinition,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterOutputVectorLayer)
QgsProcessingParameterFeatureSink)
from qgis.gui import QgsMessageBar
from qgis.utils import iface

Expand Down Expand Up @@ -118,7 +118,7 @@ def getLayersToOpen(self):
for param in self.alg.destinationParameterDefinitions():
if param.flags() & QgsProcessingParameterDefinition.FlagHidden:
continue
if isinstance(param, (OutputRaster, QgsProcessingParameterOutputVectorLayer, OutputTable)):
if isinstance(param, (OutputRaster, QgsProcessingParameterFeatureSink, OutputTable)):
if self.mainWidget.checkBoxes[param.name()].isChecked():
layer_outputs.append(param.name())

Expand Down
4 changes: 2 additions & 2 deletions python/plugins/processing/gui/ParametersPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
QgsProcessingParameterPoint,
QgsProcessingParameterFeatureSource,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterOutputVectorLayer)
QgsProcessingParameterFeatureSink)
from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtWidgets import (QWidget, QHBoxLayout, QToolButton,
Expand Down Expand Up @@ -157,7 +157,7 @@ def initWidgets(self):
widget = DestinationSelectionPanel(output, self.alg)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
if isinstance(output, (OutputRaster, QgsProcessingParameterOutputVectorLayer, OutputTable)):
if isinstance(output, (OutputRaster, QgsProcessingParameterFeatureSink, OutputTable)):
check = QCheckBox()
check.setText(self.tr('Open output file after running algorithm'))
check.setChecked(True)
Expand Down
4 changes: 2 additions & 2 deletions src/core/processing/qgsnativealgorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void QgsNativeAlgorithms::loadAlgorithms()
QgsCentroidAlgorithm::QgsCentroidAlgorithm()
{
addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterOutputVectorLayer( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Centroids" ), QgsProcessingParameterDefinition::TypeVectorPoint ) );
addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Centroids" ), QgsProcessingParameterDefinition::TypeVectorPoint ) );
addOutput( new QgsProcessingOutputVectorLayer( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Centroids" ), QgsProcessingParameterDefinition::TypeVectorPoint ) );
}

Expand Down Expand Up @@ -136,7 +136,7 @@ QgsBufferAlgorithm::QgsBufferAlgorithm()
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "MITRE_LIMIT" ), QObject::tr( "Miter limit" ), QgsProcessingParameterNumber::Double, 2, false, 1 ) );

addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "DISSOLVE" ), QObject::tr( "Dissolve result" ), false ) );
addParameter( new QgsProcessingParameterOutputVectorLayer( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Buffered" ), QgsProcessingParameterDefinition::TypeVectorPolygon ) );
addParameter( new QgsProcessingParameterFeatureSink( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Buffered" ), QgsProcessingParameterDefinition::TypeVectorPolygon ) );
addOutput( new QgsProcessingOutputVectorLayer( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Buffered" ), QgsProcessingParameterDefinition::TypeVectorPoint ) );
}

Expand Down
8 changes: 4 additions & 4 deletions src/core/processing/qgsprocessingparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,14 +1220,14 @@ void QgsProcessingParameterFeatureSource::setDataTypes( const QList<int> &types
}


QgsProcessingParameterOutputVectorLayer::QgsProcessingParameterOutputVectorLayer( const QString &name, const QString &description, QgsProcessingParameterDefinition::LayerType type, const QVariant &defaultValue, bool optional )
QgsProcessingParameterFeatureSink::QgsProcessingParameterFeatureSink( const QString &name, const QString &description, QgsProcessingParameterDefinition::LayerType type, const QVariant &defaultValue, bool optional )
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
, mDataType( type )
{

}

bool QgsProcessingParameterOutputVectorLayer::checkValueIsAcceptable( const QVariant &input, QgsProcessingContext * ) const
bool QgsProcessingParameterFeatureSink::checkValueIsAcceptable( const QVariant &input, QgsProcessingContext * ) const
{
if ( !input.isValid() )
return mFlags & FlagOptional;
Expand All @@ -1246,12 +1246,12 @@ bool QgsProcessingParameterOutputVectorLayer::checkValueIsAcceptable( const QVar
return true;
}

QgsProcessingParameterDefinition::LayerType QgsProcessingParameterOutputVectorLayer::dataType() const
QgsProcessingParameterDefinition::LayerType QgsProcessingParameterFeatureSink::dataType() const
{
return mDataType;
}

void QgsProcessingParameterOutputVectorLayer::setDataType( QgsProcessingParameterDefinition::LayerType type )
void QgsProcessingParameterFeatureSink::setDataType( QgsProcessingParameterDefinition::LayerType type )
{
mDataType = type;
}
24 changes: 12 additions & 12 deletions src/core/processing/qgsprocessingparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ class CORE_EXPORT QgsProcessingParameterDefinition
sipType = sipType_QgsProcessingParameterTableField;
else if ( sipCpp->type() == "source" )
sipType = sipType_QgsProcessingParameterFeatureSource;
else if ( sipCpp->type() == "vectorOut" )
sipType = sipType_QgsProcessingParameterOutputVectorLayer;
else if ( sipCpp->type() == "sink" )
sipType = sipType_QgsProcessingParameterFeatureSink;
SIP_END
#endif

Expand Down Expand Up @@ -1047,35 +1047,35 @@ class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingPara


/**
* \class QgsProcessingParameterOutputVectorLayer
* \class QgsProcessingParameterFeatureSink
* \ingroup core
* A vector layer output for processing algorithms.
* A feature sink output for processing algorithms.
*
* A parameter which represents the destination for a vector layer created by an algorithm.
* A parameter which represents the destination feature sink for features created by an algorithm.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsProcessingParameterOutputVectorLayer : public QgsProcessingParameterDefinition
class CORE_EXPORT QgsProcessingParameterFeatureSink : public QgsProcessingParameterDefinition
{
public:

/**
* Constructor for QgsProcessingParameterOutputVectorLayer.
* Constructor for QgsProcessingParameterFeatureSink.
*/
QgsProcessingParameterOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );
QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );

QString type() const override { return QStringLiteral( "vectorOut" ); }
QString type() const override { return QStringLiteral( "sink" ); }
bool isDestination() const override { return true; }
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;

/**
* Returns the layer type for the output layer associated with the parameter.
* Returns the layer type for sinks associated with the parameter.
* \see setDataType()
*/
QgsProcessingParameterDefinition::LayerType dataType() const;

/**
* Sets the layer \a type for the output layer associated with the parameter.
* Sets the layer \a type for the sinks associated with the parameter.
* \see dataType()
*/
void setDataType( QgsProcessingParameterDefinition::LayerType type );
Expand Down
8 changes: 4 additions & 4 deletions tests/src/core/testqgsprocessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ class DummyAlgorithm : public QgsProcessingAlgorithm

//destination styleparameters
QVERIFY( destinationParameterDefinitions().isEmpty() );
QgsProcessingParameterOutputVectorLayer *p5 = new QgsProcessingParameterOutputVectorLayer( "p5" );
QgsProcessingParameterFeatureSink *p5 = new QgsProcessingParameterFeatureSink( "p5" );
QVERIFY( addParameter( p5 ) );
QCOMPARE( destinationParameterDefinitions(), QgsProcessingParameterDefinitions() << p5 );
QgsProcessingParameterOutputVectorLayer *p6 = new QgsProcessingParameterOutputVectorLayer( "p6" );
QgsProcessingParameterFeatureSink *p6 = new QgsProcessingParameterFeatureSink( "p6" );
QVERIFY( addParameter( p6 ) );
QCOMPARE( destinationParameterDefinitions(), QgsProcessingParameterDefinitions() << p5 << p6 );
}
Expand Down Expand Up @@ -2186,7 +2186,7 @@ void TestQgsProcessing::parameterOutputVectorLayer()
context.setProject( &p );

// not optional!
std::unique_ptr< QgsProcessingParameterOutputVectorLayer > def( new QgsProcessingParameterOutputVectorLayer( "non_optional", QString(), QgsProcessingParameterDefinition::TypeVectorAny, QString( "EPSG:3113" ), false ) );
std::unique_ptr< QgsProcessingParameterFeatureSink > def( new QgsProcessingParameterFeatureSink( "non_optional", QString(), QgsProcessingParameterDefinition::TypeVectorAny, QString( "EPSG:3113" ), false ) );
QVERIFY( !def->checkValueIsAcceptable( false ) );
QVERIFY( !def->checkValueIsAcceptable( true ) );
QVERIFY( !def->checkValueIsAcceptable( 5 ) );
Expand All @@ -2199,7 +2199,7 @@ void TestQgsProcessing::parameterOutputVectorLayer()
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp", &context ) );

// optional
def.reset( new QgsProcessingParameterOutputVectorLayer( "optional", QString(), QgsProcessingParameterDefinition::TypeVectorAny, QString(), true ) );
def.reset( new QgsProcessingParameterFeatureSink( "optional", QString(), QgsProcessingParameterDefinition::TypeVectorAny, QString(), true ) );
QVERIFY( !def->checkValueIsAcceptable( false ) );
QVERIFY( !def->checkValueIsAcceptable( true ) );
QVERIFY( !def->checkValueIsAcceptable( 5 ) );
Expand Down

0 comments on commit 5b8affc

Please sign in to comment.