[qml] Upgrade QgsRectangle to Q_GADGET

This commit is contained in:
Mathieu Pellerin 2024-11-22 08:06:29 +07:00 committed by Nyall Dawson
parent 3ec4a8aab3
commit cbef4f7172
7 changed files with 32 additions and 3 deletions

View File

@ -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

View File

@ -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 );

View File

@ -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

View File

@ -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 );

View File

@ -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
@ -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.
@ -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.

View File

@ -16,6 +16,7 @@
***************************************************************************/
#include "qgsreferencedgeometry.h"
#include "moc_qgsreferencedgeometry.cpp"
QgsReferencedGeometryBase::QgsReferencedGeometryBase( const QgsCoordinateReferenceSystem &crs )
: mCrs( crs )

View File

@ -70,6 +70,8 @@ class CORE_EXPORT QgsReferencedGeometryBase
*/
class CORE_EXPORT QgsReferencedRectangle : public QgsRectangle, public QgsReferencedGeometryBase
{
Q_GADGET
public:
/**