mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-16 00:06:09 -05:00
Rename QgsProcessingParameterOutputVectorLayer to QgsProcessingParameterFeatureSink
This commit is contained in:
parent
770c45da12
commit
5b8affcb56
@ -64,8 +64,8 @@ class QgsProcessingParameterDefinition
|
|||||||
sipType = sipType_QgsProcessingParameterTableField;
|
sipType = sipType_QgsProcessingParameterTableField;
|
||||||
else if ( sipCpp->type() == "source" )
|
else if ( sipCpp->type() == "source" )
|
||||||
sipType = sipType_QgsProcessingParameterFeatureSource;
|
sipType = sipType_QgsProcessingParameterFeatureSource;
|
||||||
else if ( sipCpp->type() == "vectorOut" )
|
else if ( sipCpp->type() == "sink" )
|
||||||
sipType = sipType_QgsProcessingParameterOutputVectorLayer;
|
sipType = sipType_QgsProcessingParameterFeatureSink;
|
||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -1058,12 +1058,12 @@ class QgsProcessingParameterFeatureSource : QgsProcessingParameterDefinition
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class QgsProcessingParameterOutputVectorLayer : QgsProcessingParameterDefinition
|
class QgsProcessingParameterFeatureSink : QgsProcessingParameterDefinition
|
||||||
{
|
{
|
||||||
%Docstring
|
%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
|
.. versionadded:: 3.0
|
||||||
%End
|
%End
|
||||||
|
|
||||||
@ -1072,10 +1072,10 @@ class QgsProcessingParameterOutputVectorLayer : QgsProcessingParameterDefinition
|
|||||||
%End
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QgsProcessingParameterOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
|
QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
|
||||||
bool optional = false );
|
bool optional = false );
|
||||||
%Docstring
|
%Docstring
|
||||||
Constructor for QgsProcessingParameterOutputVectorLayer.
|
Constructor for QgsProcessingParameterFeatureSink.
|
||||||
%End
|
%End
|
||||||
|
|
||||||
virtual QString type() const;
|
virtual QString type() const;
|
||||||
@ -1085,14 +1085,14 @@ class QgsProcessingParameterOutputVectorLayer : QgsProcessingParameterDefinition
|
|||||||
|
|
||||||
QgsProcessingParameterDefinition::LayerType dataType() const;
|
QgsProcessingParameterDefinition::LayerType dataType() const;
|
||||||
%Docstring
|
%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()
|
.. seealso:: setDataType()
|
||||||
:rtype: QgsProcessingParameterDefinition.LayerType
|
:rtype: QgsProcessingParameterDefinition.LayerType
|
||||||
%End
|
%End
|
||||||
|
|
||||||
void setDataType( QgsProcessingParameterDefinition::LayerType type );
|
void setDataType( QgsProcessingParameterDefinition::LayerType type );
|
||||||
%Docstring
|
%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()
|
.. seealso:: dataType()
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ from qgis.core import (QgsGeometry,
|
|||||||
QgsProcessingUtils,
|
QgsProcessingUtils,
|
||||||
QgsProcessingParameterDefinition,
|
QgsProcessingParameterDefinition,
|
||||||
QgsProcessingParameterFeatureSource,
|
QgsProcessingParameterFeatureSource,
|
||||||
QgsProcessingParameterOutputVectorLayer,
|
QgsProcessingParameterFeatureSink,
|
||||||
QgsProcessingOutputVectorLayer)
|
QgsProcessingOutputVectorLayer)
|
||||||
|
|
||||||
from qgis.PyQt.QtGui import QIcon
|
from qgis.PyQt.QtGui import QIcon
|
||||||
@ -54,7 +54,7 @@ class Boundary(QgisAlgorithm):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorLine, QgsProcessingParameterDefinition.TypeVectorPolygon]))
|
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")))
|
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT_LAYER, self.tr("Boundaries")))
|
||||||
|
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
|||||||
@ -35,7 +35,7 @@ from qgis.core import (QgsProject,
|
|||||||
QgsMessageLog,
|
QgsMessageLog,
|
||||||
QgsProcessingParameterDefinition,
|
QgsProcessingParameterDefinition,
|
||||||
QgsProcessingOutputVectorLayer,
|
QgsProcessingOutputVectorLayer,
|
||||||
QgsProcessingParameterOutputVectorLayer)
|
QgsProcessingParameterFeatureSink)
|
||||||
from qgis.gui import QgsMessageBar
|
from qgis.gui import QgsMessageBar
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
|||||||
for param in self.alg.destinationParameterDefinitions():
|
for param in self.alg.destinationParameterDefinitions():
|
||||||
if param.flags() & QgsProcessingParameterDefinition.FlagHidden:
|
if param.flags() & QgsProcessingParameterDefinition.FlagHidden:
|
||||||
continue
|
continue
|
||||||
if isinstance(param, (OutputRaster, QgsProcessingParameterOutputVectorLayer, OutputTable)):
|
if isinstance(param, (OutputRaster, QgsProcessingParameterFeatureSink, OutputTable)):
|
||||||
if self.mainWidget.checkBoxes[param.name()].isChecked():
|
if self.mainWidget.checkBoxes[param.name()].isChecked():
|
||||||
layer_outputs.append(param.name())
|
layer_outputs.append(param.name())
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ from qgis.core import (QgsProcessingParameterDefinition,
|
|||||||
QgsProcessingParameterPoint,
|
QgsProcessingParameterPoint,
|
||||||
QgsProcessingParameterFeatureSource,
|
QgsProcessingParameterFeatureSource,
|
||||||
QgsProcessingOutputVectorLayer,
|
QgsProcessingOutputVectorLayer,
|
||||||
QgsProcessingParameterOutputVectorLayer)
|
QgsProcessingParameterFeatureSink)
|
||||||
from qgis.PyQt import uic
|
from qgis.PyQt import uic
|
||||||
from qgis.PyQt.QtCore import QCoreApplication
|
from qgis.PyQt.QtCore import QCoreApplication
|
||||||
from qgis.PyQt.QtWidgets import (QWidget, QHBoxLayout, QToolButton,
|
from qgis.PyQt.QtWidgets import (QWidget, QHBoxLayout, QToolButton,
|
||||||
@ -157,7 +157,7 @@ class ParametersPanel(BASE, WIDGET):
|
|||||||
widget = DestinationSelectionPanel(output, self.alg)
|
widget = DestinationSelectionPanel(output, self.alg)
|
||||||
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
|
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
|
||||||
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
|
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
|
||||||
if isinstance(output, (OutputRaster, QgsProcessingParameterOutputVectorLayer, OutputTable)):
|
if isinstance(output, (OutputRaster, QgsProcessingParameterFeatureSink, OutputTable)):
|
||||||
check = QCheckBox()
|
check = QCheckBox()
|
||||||
check.setText(self.tr('Open output file after running algorithm'))
|
check.setText(self.tr('Open output file after running algorithm'))
|
||||||
check.setChecked(True)
|
check.setChecked(True)
|
||||||
|
|||||||
@ -66,7 +66,7 @@ void QgsNativeAlgorithms::loadAlgorithms()
|
|||||||
QgsCentroidAlgorithm::QgsCentroidAlgorithm()
|
QgsCentroidAlgorithm::QgsCentroidAlgorithm()
|
||||||
{
|
{
|
||||||
addParameter( new QgsProcessingParameterFeatureSource( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
|
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 ) );
|
addOutput( new QgsProcessingOutputVectorLayer( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Centroids" ), QgsProcessingParameterDefinition::TypeVectorPoint ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ QgsBufferAlgorithm::QgsBufferAlgorithm()
|
|||||||
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "MITRE_LIMIT" ), QObject::tr( "Miter limit" ), QgsProcessingParameterNumber::Double, 2, false, 1 ) );
|
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 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 ) );
|
addOutput( new QgsProcessingOutputVectorLayer( QStringLiteral( "OUTPUT_LAYER" ), QObject::tr( "Buffered" ), QgsProcessingParameterDefinition::TypeVectorPoint ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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 )
|
: QgsProcessingParameterDefinition( name, description, defaultValue, optional )
|
||||||
, mDataType( type )
|
, mDataType( type )
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QgsProcessingParameterOutputVectorLayer::checkValueIsAcceptable( const QVariant &input, QgsProcessingContext * ) const
|
bool QgsProcessingParameterFeatureSink::checkValueIsAcceptable( const QVariant &input, QgsProcessingContext * ) const
|
||||||
{
|
{
|
||||||
if ( !input.isValid() )
|
if ( !input.isValid() )
|
||||||
return mFlags & FlagOptional;
|
return mFlags & FlagOptional;
|
||||||
@ -1246,12 +1246,12 @@ bool QgsProcessingParameterOutputVectorLayer::checkValueIsAcceptable( const QVar
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsProcessingParameterDefinition::LayerType QgsProcessingParameterOutputVectorLayer::dataType() const
|
QgsProcessingParameterDefinition::LayerType QgsProcessingParameterFeatureSink::dataType() const
|
||||||
{
|
{
|
||||||
return mDataType;
|
return mDataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsProcessingParameterOutputVectorLayer::setDataType( QgsProcessingParameterDefinition::LayerType type )
|
void QgsProcessingParameterFeatureSink::setDataType( QgsProcessingParameterDefinition::LayerType type )
|
||||||
{
|
{
|
||||||
mDataType = type;
|
mDataType = type;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,8 +86,8 @@ class CORE_EXPORT QgsProcessingParameterDefinition
|
|||||||
sipType = sipType_QgsProcessingParameterTableField;
|
sipType = sipType_QgsProcessingParameterTableField;
|
||||||
else if ( sipCpp->type() == "source" )
|
else if ( sipCpp->type() == "source" )
|
||||||
sipType = sipType_QgsProcessingParameterFeatureSource;
|
sipType = sipType_QgsProcessingParameterFeatureSource;
|
||||||
else if ( sipCpp->type() == "vectorOut" )
|
else if ( sipCpp->type() == "sink" )
|
||||||
sipType = sipType_QgsProcessingParameterOutputVectorLayer;
|
sipType = sipType_QgsProcessingParameterFeatureSink;
|
||||||
SIP_END
|
SIP_END
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1047,35 +1047,35 @@ class CORE_EXPORT QgsProcessingParameterFeatureSource : public QgsProcessingPara
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class QgsProcessingParameterOutputVectorLayer
|
* \class QgsProcessingParameterFeatureSink
|
||||||
* \ingroup core
|
* \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
|
* \since QGIS 3.0
|
||||||
*/
|
*/
|
||||||
class CORE_EXPORT QgsProcessingParameterOutputVectorLayer : public QgsProcessingParameterDefinition
|
class CORE_EXPORT QgsProcessingParameterFeatureSink : public QgsProcessingParameterDefinition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for QgsProcessingParameterOutputVectorLayer.
|
* Constructor for QgsProcessingParameterFeatureSink.
|
||||||
*/
|
*/
|
||||||
QgsProcessingParameterOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
|
QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
|
||||||
bool optional = false );
|
bool optional = false );
|
||||||
|
|
||||||
QString type() const override { return QStringLiteral( "vectorOut" ); }
|
QString type() const override { return QStringLiteral( "sink" ); }
|
||||||
bool isDestination() const override { return true; }
|
bool isDestination() const override { return true; }
|
||||||
bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
|
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()
|
* \see setDataType()
|
||||||
*/
|
*/
|
||||||
QgsProcessingParameterDefinition::LayerType dataType() const;
|
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()
|
* \see dataType()
|
||||||
*/
|
*/
|
||||||
void setDataType( QgsProcessingParameterDefinition::LayerType type );
|
void setDataType( QgsProcessingParameterDefinition::LayerType type );
|
||||||
|
|||||||
@ -91,10 +91,10 @@ class DummyAlgorithm : public QgsProcessingAlgorithm
|
|||||||
|
|
||||||
//destination styleparameters
|
//destination styleparameters
|
||||||
QVERIFY( destinationParameterDefinitions().isEmpty() );
|
QVERIFY( destinationParameterDefinitions().isEmpty() );
|
||||||
QgsProcessingParameterOutputVectorLayer *p5 = new QgsProcessingParameterOutputVectorLayer( "p5" );
|
QgsProcessingParameterFeatureSink *p5 = new QgsProcessingParameterFeatureSink( "p5" );
|
||||||
QVERIFY( addParameter( p5 ) );
|
QVERIFY( addParameter( p5 ) );
|
||||||
QCOMPARE( destinationParameterDefinitions(), QgsProcessingParameterDefinitions() << p5 );
|
QCOMPARE( destinationParameterDefinitions(), QgsProcessingParameterDefinitions() << p5 );
|
||||||
QgsProcessingParameterOutputVectorLayer *p6 = new QgsProcessingParameterOutputVectorLayer( "p6" );
|
QgsProcessingParameterFeatureSink *p6 = new QgsProcessingParameterFeatureSink( "p6" );
|
||||||
QVERIFY( addParameter( p6 ) );
|
QVERIFY( addParameter( p6 ) );
|
||||||
QCOMPARE( destinationParameterDefinitions(), QgsProcessingParameterDefinitions() << p5 << p6 );
|
QCOMPARE( destinationParameterDefinitions(), QgsProcessingParameterDefinitions() << p5 << p6 );
|
||||||
}
|
}
|
||||||
@ -2186,7 +2186,7 @@ void TestQgsProcessing::parameterOutputVectorLayer()
|
|||||||
context.setProject( &p );
|
context.setProject( &p );
|
||||||
|
|
||||||
// not optional!
|
// 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( false ) );
|
||||||
QVERIFY( !def->checkValueIsAcceptable( true ) );
|
QVERIFY( !def->checkValueIsAcceptable( true ) );
|
||||||
QVERIFY( !def->checkValueIsAcceptable( 5 ) );
|
QVERIFY( !def->checkValueIsAcceptable( 5 ) );
|
||||||
@ -2199,7 +2199,7 @@ void TestQgsProcessing::parameterOutputVectorLayer()
|
|||||||
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp", &context ) );
|
QVERIFY( def->checkValueIsAcceptable( "c:/Users/admin/Desktop/roads_clipped_transformed_v1_reprojected_final_clipped_aAAA.shp", &context ) );
|
||||||
|
|
||||||
// optional
|
// 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( false ) );
|
||||||
QVERIFY( !def->checkValueIsAcceptable( true ) );
|
QVERIFY( !def->checkValueIsAcceptable( true ) );
|
||||||
QVERIFY( !def->checkValueIsAcceptable( 5 ) );
|
QVERIFY( !def->checkValueIsAcceptable( 5 ) );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user