Skip to content

Commit

Permalink
[qml] Upgrade QgsRectangle to Q_GADGET
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Nov 23, 2024
1 parent 278caf1 commit c468898
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions python/PyQt6/core/auto_generated/geometry/qgsrectangle.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Examples are storing a layer extent or the current view extent of a map
%TypeHeaderCode
#include "qgsrectangle.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

QgsRectangle(); // optimised constructor for null rectangle - no need to call normalize here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ A :py:class:`QgsRectangle` with associated coordinate reference system.
%TypeHeaderCode
#include "qgsreferencedgeometry.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

QgsReferencedRectangle( const QgsRectangle &rectangle, const QgsCoordinateReferenceSystem &crs );
Expand Down
3 changes: 3 additions & 0 deletions python/core/auto_generated/geometry/qgsrectangle.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Examples are storing a layer extent or the current view extent of a map
%TypeHeaderCode
#include "qgsrectangle.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

QgsRectangle(); // optimised constructor for null rectangle - no need to call normalize here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ A :py:class:`QgsRectangle` with associated coordinate reference system.
%TypeHeaderCode
#include "qgsreferencedgeometry.h"
%End
public:
static const QMetaObject staticMetaObject;

public:

QgsReferencedRectangle( const QgsRectangle &rectangle, const QgsCoordinateReferenceSystem &crs );
Expand Down
20 changes: 17 additions & 3 deletions src/core/geometry/qgsrectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ class QgsBox3D;
*/
class CORE_EXPORT QgsRectangle
{
Q_GADGET

Q_PROPERTY( double xMinimum READ xMinimum WRITE setXMinimum )
Q_PROPERTY( double xMaximum READ xMaximum WRITE setXMaximum )
Q_PROPERTY( double yMinimum READ yMinimum WRITE setYMinimum )
Q_PROPERTY( double yMaximum READ yMaximum WRITE setYMaximum )
Q_PROPERTY( double width READ width )
Q_PROPERTY( double height READ height )
Q_PROPERTY( double area READ area )
Q_PROPERTY( double perimeter READ perimeter )
Q_PROPERTY( QgsPointXY center READ center )
Q_PROPERTY( bool isEmpty READ isEmpty )
Q_PROPERTY( bool isNull READ isNull )

public:

//! Constructor for a null rectangle
Expand Down Expand Up @@ -518,12 +532,12 @@ class CORE_EXPORT QgsRectangle
/**
* Returns a string representation of the rectangle in WKT format.
*/
QString asWktCoordinates() const;
Q_INVOKABLE QString asWktCoordinates() const;

/**
* Returns a string representation of the rectangle as a WKT Polygon.
*/
QString asWktPolygon() const;
Q_INVOKABLE QString asWktPolygon() const;

/**
* Returns a QRectF with same coordinates as the rectangle.
Expand All @@ -538,7 +552,7 @@ class CORE_EXPORT QgsRectangle
* Coordinates will be truncated to the specified precision.
* If the specified precision is less than 0, a suitable minimum precision is used.
*/
QString toString( int precision = 16 ) const;
Q_INVOKABLE QString toString( int precision = 16 ) const;

/**
* Returns the rectangle as a polygon.
Expand Down
2 changes: 2 additions & 0 deletions src/core/geometry/qgsreferencedgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class CORE_EXPORT QgsReferencedGeometryBase
*/
class CORE_EXPORT QgsReferencedRectangle : public QgsRectangle, public QgsReferencedGeometryBase
{
Q_GADGET

public:

/**
Expand Down

0 comments on commit c468898

Please sign in to comment.