Skip to content
Permalink
Browse files

use SIP to define Python __repr__ rather than injections

because it's a bit more clever!
  • Loading branch information
3nids committed Jun 19, 2018
1 parent a719605 commit 763dfd29986e6820eb3c58719c4840c2ecea8310
Showing with 170 additions and 51 deletions.
  1. +0 −2 python/core/auto_additions/qgscircle.py
  2. +0 −2 python/core/auto_additions/qgscircularstring.py
  3. +0 −2 python/core/auto_additions/qgscompoundcurve.py
  4. +0 −2 python/core/auto_additions/qgscurvepolygon.py
  5. +0 −2 python/core/auto_additions/qgsellipse.py
  6. +0 −1 python/core/auto_additions/qgsgeometry.py
  7. +0 −2 python/core/auto_additions/qgslinestring.py
  8. +0 −2 python/core/auto_additions/qgsmulticurve.py
  9. +0 −2 python/core/auto_additions/qgsmultilinestring.py
  10. +0 −2 python/core/auto_additions/qgsmultipoint.py
  11. +0 −2 python/core/auto_additions/qgsmultipolygon.py
  12. +0 −2 python/core/auto_additions/qgspoint.py
  13. +0 −2 python/core/auto_additions/qgspointxy.py
  14. +0 −2 python/core/auto_additions/qgspolygon.py
  15. +0 −2 python/core/auto_additions/qgsrectangle.py
  16. +5 −1 python/core/auto_generated/geometry/qgscircle.sip.in
  17. +5 −0 python/core/auto_generated/geometry/qgscircularstring.sip.in
  18. +5 −0 python/core/auto_generated/geometry/qgscompoundcurve.sip.in
  19. +5 −0 python/core/auto_generated/geometry/qgscurvepolygon.sip.in
  20. +5 −0 python/core/auto_generated/geometry/qgsellipse.sip.in
  21. +5 −0 python/core/auto_generated/geometry/qgsgeometry.sip.in
  22. +5 −0 python/core/auto_generated/geometry/qgslinestring.sip.in
  23. +5 −1 python/core/auto_generated/geometry/qgsmulticurve.sip.in
  24. +5 −0 python/core/auto_generated/geometry/qgsmultilinestring.sip.in
  25. +5 −0 python/core/auto_generated/geometry/qgsmultipoint.sip.in
  26. +5 −0 python/core/auto_generated/geometry/qgsmultipolygon.sip.in
  27. +5 −0 python/core/auto_generated/geometry/qgspoint.sip.in
  28. +5 −0 python/core/auto_generated/geometry/qgspolygon.sip.in
  29. +5 −0 python/core/auto_generated/geometry/qgsrectangle.sip.in
  30. +1 −2 python/core/auto_generated/qgspointxy.sip.in
  31. +7 −2 src/core/geometry/qgscircle.h
  32. +7 −1 src/core/geometry/qgscircularstring.h
  33. +7 −1 src/core/geometry/qgscompoundcurve.h
  34. +7 −1 src/core/geometry/qgscurvepolygon.h
  35. +7 −1 src/core/geometry/qgsellipse.h
  36. +7 −1 src/core/geometry/qgsgeometry.h
  37. +7 −1 src/core/geometry/qgslinestring.h
  38. +7 −2 src/core/geometry/qgsmulticurve.h
  39. +7 −1 src/core/geometry/qgsmultilinestring.h
  40. +7 −1 src/core/geometry/qgsmultipoint.h
  41. +7 −1 src/core/geometry/qgsmultipolygon.h
  42. +7 −1 src/core/geometry/qgspoint.h
  43. +7 −1 src/core/geometry/qgspolygon.h
  44. +7 −1 src/core/geometry/qgsrectangle.h
  45. +1 −2 src/core/qgspointxy.h

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -2,4 +2,3 @@
QgsGeometry.BufferSide.baseClass = QgsGeometry
QgsGeometry.EndCapStyle.baseClass = QgsGeometry
QgsGeometry.JoinStyle.baseClass = QgsGeometry
QgsGeometry.__repr__ = lambda self: '<QgsGeometry {}>'.format(self.asWkt())

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -253,7 +253,11 @@ Returns true if the circle contains the ``point``.
virtual QString toString( int pointPrecision = 17, int radiusPrecision = 17, int azimuthPrecision = 2 ) const;



SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsCircle %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End
};

/************************************************************************
@@ -162,6 +162,11 @@ Sets the circular string's points
virtual QgsCircularString *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsCircularString %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -166,6 +166,11 @@ Appends first point if not already closed.
virtual QgsCompoundCurve *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsCompoundCurve %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -216,6 +216,11 @@ Returns approximate rotation angle for a vertex. Usually average angle between a
virtual QgsCurvePolygon *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsCurvePolygon %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -248,6 +248,11 @@ returns a string representation of the ellipse.
Members will be truncated to the specified precision.
%End

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsEllipse %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -1290,6 +1290,11 @@ Exports the geometry to WKT
precision parameter added in QGIS 2.4
%End

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsGeometry %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

QString asJson( int precision = 17 ) const;
%Docstring
@@ -317,6 +317,11 @@ of the curve.
virtual QgsLineString *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsLineString %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -56,7 +56,11 @@ Returns a copy of the multi curve, where each component curve has had its line d
virtual QgsMultiCurve *createEmptyWithSameType() const /Factory/;



SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsMulitCurve %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

};

@@ -53,6 +53,11 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult
virtual QgsMultiLineString *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsMultiLineString %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -55,6 +55,11 @@ Multi point geometry collection.
virtual QgsMultiPoint *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsMultiPoint %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -54,6 +54,11 @@ Returns the geometry converted to the more generic curve type :py:class:`QgsMult
virtual QgsMultiPolygon *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsMultiPolygon %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -426,6 +426,11 @@ Angle undefined. Always returns 0.0
virtual QgsPoint *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsPoint %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -65,6 +65,11 @@ negative if the point lies outside the polygon.
virtual QgsPolygon *createEmptyWithSameType() const /Factory/;


SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsPolygon %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

protected:

@@ -322,6 +322,11 @@ Converts the rectangle to a 3D box, with the specified

operator QVariant() const;

SIP_PYOBJECT __repr__();
%MethodCode
QString str = QString( "<QgsRectangle %1>" ).arg( sipCpp->asWktCoordinates() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

};

@@ -230,8 +230,7 @@ Multiply x and y by the given value

SIP_PYOBJECT __repr__();
%MethodCode
QString str = "(" + QString::number( sipCpp->x() ) + "," + QString::number( sipCpp->y() ) + ")";
//QString str("(%f,%f)").arg(sipCpp->x()).arg(sipCpp->y());
QString str = QString( "<QgsPointXY %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
%End

@@ -247,8 +247,13 @@ class CORE_EXPORT QgsCircle : public QgsEllipse

QString toString( int pointPrecision = 17, int radiusPrecision = 17, int azimuthPrecision = 2 ) const override;

SIP_PYTHON_SPECIAL_REPR( "'<QgsPoint {}>'.format(self.toString())" )

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsCircle %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif
};

#endif // QGSCIRCLE_H
@@ -146,7 +146,13 @@ class CORE_EXPORT QgsCircularString: public QgsCurve

QgsCircularString *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsCircularString {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsCircularString %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:

@@ -146,7 +146,13 @@ class CORE_EXPORT QgsCompoundCurve: public QgsCurve

QgsCompoundCurve *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsCompoundCurve {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsCompoundCurve %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:

@@ -204,7 +204,13 @@ class CORE_EXPORT QgsCurvePolygon: public QgsSurface

QgsCurvePolygon *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsCurvePolygon {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsCurvePolygon %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:

@@ -240,7 +240,13 @@ class CORE_EXPORT QgsEllipse
*/
virtual QString toString( int pointPrecision = 17, int axisPrecision = 17, int azimuthPrecision = 2 ) const;

SIP_PYTHON_SPECIAL_REPR( "'<QgsEllipse {}>'.format(self.toString())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsEllipse %1>" ).arg( sipCpp->toString() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:
QgsPoint mCenter;
@@ -1248,7 +1248,13 @@ class CORE_EXPORT QgsGeometry
*/
QString asWkt( int precision = 17 ) const;

SIP_PYTHON_SPECIAL_REPR( "'<QgsGeometry {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsGeometry %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

/**
* Exports the geometry to a GeoJSON string.
@@ -346,7 +346,13 @@ class CORE_EXPORT QgsLineString: public QgsCurve

QgsLineString *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsLineString {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsLineString %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:

@@ -73,8 +73,13 @@ class CORE_EXPORT QgsMultiCurve: public QgsGeometryCollection

QgsMultiCurve *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsMulitCurve {}>'.format(self.asWkt())" )

#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsMulitCurve %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

};

@@ -65,7 +65,13 @@ class CORE_EXPORT QgsMultiLineString: public QgsMultiCurve

QgsMultiLineString *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsMultiLineString {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsMultiLineString %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:

@@ -66,7 +66,13 @@ class CORE_EXPORT QgsMultiPoint: public QgsGeometryCollection

QgsMultiPoint *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsMultiPoint {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsMultiPoint %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:

@@ -65,7 +65,13 @@ class CORE_EXPORT QgsMultiPolygon: public QgsMultiSurface

QgsMultiPolygon *createEmptyWithSameType() const override SIP_FACTORY;

SIP_PYTHON_SPECIAL_REPR( "'<QgsMultiPolygon {}>'.format(self.asWkt())" )
#ifdef SIP_RUN
SIP_PYOBJECT __repr__();
% MethodCode
QString str = QString( "<QgsMultiPolygon %1>" ).arg( sipCpp->asWkt() );
sipRes = PyUnicode_FromString( str.toUtf8().data() );
% End
#endif

protected:

0 comments on commit 763dfd2

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