use Enum for Result of addTopologicalPoints

This commit is contained in:
lbartoletti 2019-07-31 07:24:00 +02:00 committed by Nyall Dawson
parent aac1e23de0
commit 2354065e90
3 changed files with 31 additions and 22 deletions

View File

@ -61,23 +61,26 @@ returned object
Returns the current vector layer of the map canvas or 0
%End
int addTopologicalPoints( const QVector<QgsPointXY> &geom );
enum TopologicalResult
{
Success,
InvalidCanvas,
InvalidLayer,
};
TopologicalResult addTopologicalPoints( const QVector<QgsPointXY> &geom );
%Docstring
Adds vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
:param geom: list of points (in layer coordinate system)
:return: 0 in case of success
%End
int addTopologicalPoints( const QVector<QgsPoint> &geom );
TopologicalResult addTopologicalPoints( const QVector<QgsPoint> &geom );
%Docstring
Adds vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
:param geom: list of points (in layer coordinate system)
:return: 0 in case of success
.. versionadded:: 3.10
%End

View File

@ -92,11 +92,11 @@ QgsVectorLayer *QgsMapToolEdit::currentVectorLayer()
}
int QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPoint> &geom )
QgsMapToolEdit::TopologicalResult QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPoint> &geom )
{
if ( !mCanvas )
{
return 1;
return QgsMapToolEdit::InvalidCanvas;
}
//find out current vector layer
@ -104,7 +104,7 @@ int QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPoint> &geom )
if ( !vlayer )
{
return 2;
return QgsMapToolEdit::InvalidLayer;
}
QVector<QgsPoint>::const_iterator list_it = geom.constBegin();
@ -112,14 +112,14 @@ int QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPoint> &geom )
{
vlayer->addTopologicalPoints( *list_it );
}
return 0;
return QgsMapToolEdit::Success;
}
int QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPointXY> &geom )
QgsMapToolEdit::TopologicalResult QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPointXY> &geom )
{
if ( !mCanvas )
{
return 1;
return QgsMapToolEdit::InvalidCanvas;
}
//find out current vector layer
@ -127,7 +127,7 @@ int QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPointXY> &geom )
if ( !vlayer )
{
return 2;
return QgsMapToolEdit::InvalidLayer;
}
QVector<QgsPointXY>::const_iterator list_it = geom.constBegin();
@ -135,7 +135,7 @@ int QgsMapToolEdit::addTopologicalPoints( const QVector<QgsPointXY> &geom )
{
vlayer->addTopologicalPoints( *list_it );
}
return 0;
return QgsMapToolEdit::Success;
}
QgsGeometryRubberBand *QgsMapToolEdit::createGeometryRubberBand( QgsWkbTypes::GeometryType geometryType, bool alternativeBand ) const

View File

@ -67,20 +67,26 @@ class GUI_EXPORT QgsMapToolEdit: public QgsMapTool
//! Returns the current vector layer of the map canvas or 0
QgsVectorLayer *currentVectorLayer();
/**
* Adds vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
* \param geom list of points (in layer coordinate system)
* \returns 0 in case of success
*/
int addTopologicalPoints( const QVector<QgsPointXY> &geom );
//! Result of addTopologicalPoints
enum TopologicalResult
{
Success = 0, //!< AddTopologicalPoints was successful
InvalidCanvas = 1, //!< AddTopologicalPoints failed due to an invalid canvas
InvalidLayer = 2, //!< AddTopologicalPoints failed due to an invalid canvas
};
/**
* Adds vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
* \param geom list of points (in layer coordinate system)
*/
TopologicalResult addTopologicalPoints( const QVector<QgsPointXY> &geom );
/**
* Adds vertices to other features to keep topology up to date, e.g. to neighbouring polygons.
* \param geom list of points (in layer coordinate system)
* \returns 0 in case of success
* \since QGIS 3.10
*/
int addTopologicalPoints( const QVector<QgsPoint> &geom );
TopologicalResult addTopologicalPoints( const QVector<QgsPoint> &geom );
//! Display a timed message bar noting the active layer is not vector.
void notifyNotVectorLayer();