Skip to content
Permalink
Browse files

Add Python repr for QgsVertexId

  • Loading branch information
nyalldawson committed May 22, 2020
1 parent eec8ca4 commit 93648dd55228791b073f339f6c775dac37c78491
@@ -838,6 +838,13 @@ Returns ``True`` if the vertex id is valid
int ring;
int vertex;
VertexType type;

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsVertexId: %1,%2,%3%4>" ).arg( sipCpp->part ).arg( sipCpp->ring ).arg( sipCpp->vertex ).arg( sipCpp->type == QgsVertexId::CurveVertex ? QStringLiteral( " CurveVertex" ) : QString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

};


@@ -1063,6 +1063,15 @@ struct CORE_EXPORT QgsVertexId
int ring;
int vertex;
VertexType type;

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QStringLiteral( "<QgsVertexId: %1,%2,%3%4>" ).arg( sipCpp->part ).arg( sipCpp->ring ).arg( sipCpp->vertex ).arg( sipCpp->type == QgsVertexId::CurveVertex ? QStringLiteral( " CurveVertex" ) : QString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

};

#ifndef SIP_RUN
@@ -18,7 +18,8 @@
QgsCurvePolygon, QgsEllipse, QgsLineString, QgsMultiCurve, QgsRectangle, QgsExpression, QgsField, QgsError,\
QgsMimeDataUtils, QgsVector, QgsVector3D, QgsVectorLayer, QgsReferencedPointXY, QgsReferencedRectangle,\
QgsCoordinateReferenceSystem, QgsCoordinateTransform, QgsProject, QgsClassificationRange, QgsBookmark, \
QgsLayoutMeasurement, QgsLayoutPoint, QgsLayoutSize, QgsUnitTypes, QgsConditionalStyle, QgsTableCell, QgsProperty
QgsLayoutMeasurement, QgsLayoutPoint, QgsLayoutSize, QgsUnitTypes, QgsConditionalStyle, QgsTableCell, QgsProperty, \
QgsVertexId

start_app()

@@ -241,6 +242,14 @@ def testQgsProperty(self):
p = QgsProperty()
self.assertEqual(p.__repr__(), '<QgsProperty: invalid>')

def testQgsVertexId(self):
v = QgsVertexId()
self.assertEqual(v.__repr__(), '<QgsVertexId: -1,-1,-1>')
v = QgsVertexId(1, 2, 3)
self.assertEqual(v.__repr__(), '<QgsVertexId: 1,2,3>')
v = QgsVertexId(1, 2, 3, _type=QgsVertexId.CurveVertex)
self.assertEqual(v.__repr__(), '<QgsVertexId: 1,2,3 CurveVertex>')


if __name__ == "__main__":
unittest.main()

0 comments on commit 93648dd

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