QGIS/python/core/auto_generated/geometry/qgsrectangle.sip.in
2025-08-11 12:34:58 +02:00

448 lines
11 KiB
Plaintext

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geometry/qgsrectangle.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsRectangle
{
%Docstring(signature="appended")
A rectangle specified with double values.
:py:class:`QgsRectangle` is used to store a rectangle when double values
are required. Examples are storing a layer extent or the current view
extent of a map
.. seealso:: :py:class:`QgsBox3D`
%End
%TypeHeaderCode
#include "qgsrectangle.h"
%End
public:
static const QMetaObject staticMetaObject;
public:
QgsRectangle(); // optimised constructor for null rectangle - no need to call normalize here
explicit QgsRectangle( double xMin, double yMin = 0, double xMax = 0, double yMax = 0, bool normalize = true ) /HoldGIL/;
%Docstring
Constructs a QgsRectangle from a set of x and y minimum and maximum
coordinates.
The rectangle will be normalized after creation. Since QGIS 3.20, if
``normalize`` is ``False`` then the normalization step will not be
applied automatically.
%End
QgsRectangle( const QgsPointXY &p1, const QgsPointXY &p2, bool normalize = true ) /HoldGIL/;
%Docstring
Construct a rectangle from two points.
The rectangle is normalized after construction. Since QGIS 3.20, if
``normalize`` is ``False`` then the normalization step will not be
applied automatically.
%End
QgsRectangle( const QRectF &qRectF ) /HoldGIL/;
%Docstring
Construct a rectangle from a QRectF.
The rectangle is NOT normalized after construction.
%End
QgsRectangle( const QgsRectangle &other ) /HoldGIL/;
~QgsRectangle();
static QgsRectangle fromWkt( const QString &wkt );
%Docstring
Creates a new rectangle from a ``wkt`` string. The WKT must contain only
5 vertices, representing a rectangle aligned with X and Y axes.
%End
static QgsRectangle fromCenterAndSize( const QgsPointXY &center, double width, double height );
%Docstring
Creates a new rectangle, given the specified ``center`` point and
``width`` and ``height``.
%End
void set( const QgsPointXY &p1, const QgsPointXY &p2, bool normalize = true );
%Docstring
Sets the rectangle from two :py:class:`QgsPoints`.
The rectangle is normalised after construction. Since QGIS 3.20, if
``normalize`` is ``False`` then the normalization step will not be
applied automatically.
%End
void set( double xMin, double yMin, double xMax, double yMax, bool normalize = true );
%Docstring
Sets the rectangle from four points.
The rectangle is normalised after construction. Since QGIS 3.20, if
``normalize`` is ``False`` then the normalization step will not be
applied automatically.
%End
void setXMinimum( double x ) /HoldGIL/;
%Docstring
Set the minimum x value.
%End
void setXMaximum( double x ) /HoldGIL/;
%Docstring
Set the maximum x value.
%End
void setYMinimum( double y ) /HoldGIL/;
%Docstring
Set the minimum y value.
%End
void setYMaximum( double y ) /HoldGIL/;
%Docstring
Set the maximum y value.
%End
void setNull() /HoldGIL/;
%Docstring
Mark a rectangle as being null (holding no spatial information).
A null rectangle is also empty by definition.
.. seealso:: :py:func:`isNull`
.. seealso:: :py:func:`isEmpty`
.. versionadded:: 3.34
%End
void setMinimal() /Deprecated="Since 3.34. Will be removed in QGIS 4.0. Use setNull()."/;
%Docstring
Set a rectangle so that min corner is at max and max corner is at min.
It is NOT normalized.
.. deprecated:: 3.34
Will be removed in QGIS 4.0. Use :py:func:`~QgsRectangle.setNull`.
%End
double xMaximum() const /HoldGIL/;
%Docstring
Returns the x maximum value (right side of rectangle).
%End
double xMinimum() const /HoldGIL/;
%Docstring
Returns the x minimum value (left side of rectangle).
%End
double yMaximum() const /HoldGIL/;
%Docstring
Returns the y maximum value (top side of rectangle).
%End
double yMinimum() const /HoldGIL/;
%Docstring
Returns the y minimum value (bottom side of rectangle).
%End
void normalize();
%Docstring
Normalize the rectangle so it has non-negative width/height.
%End
double width() const /HoldGIL/;
%Docstring
Returns the width of the rectangle.
.. seealso:: :py:func:`height`
.. seealso:: :py:func:`area`
%End
double height() const /HoldGIL/;
%Docstring
Returns the height of the rectangle.
.. seealso:: :py:func:`width`
.. seealso:: :py:func:`area`
%End
double area() const /HoldGIL/;
%Docstring
Returns the area of the rectangle.
.. seealso:: :py:func:`width`
.. seealso:: :py:func:`height`
.. seealso:: :py:func:`perimeter`
%End
double perimeter() const /HoldGIL/;
%Docstring
Returns the perimeter of the rectangle.
.. seealso:: :py:func:`area`
%End
QgsPointXY center() const /HoldGIL/;
%Docstring
Returns the center point of the rectangle.
%End
void scale( double scaleFactor, const QgsPointXY *c = 0 );
%Docstring
Scale the rectangle around its center point.
%End
void scale( double scaleFactor, double centerX, double centerY );
%Docstring
Scale the rectangle around its center point.
%End
QgsRectangle scaled( double scaleFactor, const QgsPointXY *center = 0 ) const;
%Docstring
Scale the rectangle around its ``center`` point.
.. versionadded:: 3.4
%End
void grow( double delta );
%Docstring
Grows the rectangle in place by the specified amount.
.. seealso:: :py:func:`buffered`
%End
void include( const QgsPointXY &p );
%Docstring
Updates the rectangle to include the specified point.
%End
QgsRectangle buffered( double width ) const;
%Docstring
Gets rectangle enlarged by buffer.
.. note::
In earlier QGIS releases this method was named :py:func:`~QgsRectangle.buffer`.
.. seealso:: :py:func:`grow`
%End
QgsRectangle intersect( const QgsRectangle &rect ) const;
%Docstring
Returns the intersection with the given rectangle.
%End
bool intersects( const QgsRectangle &rect ) const /HoldGIL/;
%Docstring
Returns ``True`` when rectangle intersects with other rectangle.
%End
bool contains( const QgsRectangle &rect ) const /HoldGIL/;
%Docstring
Returns ``True`` when rectangle contains other rectangle.
%End
bool contains( const QgsPointXY &p ) const /HoldGIL/;
%Docstring
Returns ``True`` when rectangle contains a point.
%End
bool contains( double x, double y ) const /HoldGIL/;
%Docstring
Returns ``True`` when rectangle contains the point at (``x``, ``y``).
.. versionadded:: 3.20
%End
void combineExtentWith( const QgsRectangle &rect );
%Docstring
Expands the rectangle so that it covers both the original rectangle and
the given rectangle.
%End
void combineExtentWith( double x, double y );
%Docstring
Expands the rectangle so that it covers both the original rectangle and
the given point.
%End
void combineExtentWith( const QgsPointXY &point );
%Docstring
Expands the rectangle so that it covers both the original rectangle and
the given point.
.. versionadded:: 3.2
%End
double distance( const QgsPointXY &point ) const;
%Docstring
Returns the distance from ``point`` to the nearest point on the boundary
of the rectangle.
.. versionadded:: 3.14
%End
QgsRectangle operator-( QgsVector v ) const;
QgsRectangle operator+( QgsVector v ) const;
QgsRectangle &operator-=( QgsVector v );
QgsRectangle &operator+=( QgsVector v );
bool isEmpty() const;
%Docstring
Returns ``True`` if the rectangle has no area.
An empty rectangle may still be non-null if it contains valid spatial
information (e.g. bounding box of a point or of a vertical or horizontal
segment).
.. seealso:: :py:func:`isNull`
%End
bool isNull() const;
%Docstring
Test if the rectangle is null (holding no spatial information).
A rectangle is considered null if all its coordinates are NaN, if it has
not been defined yet, or if it has been explicitly initialized as null.
A null rectangle is also an empty rectangle and an invalid rectangle.
.. seealso:: :py:func:`setNull`
%End
bool isValid() const;
%Docstring
Test if the rectangle is valid
A rectangle is considered invalid if at least one of its coordinates is
NaN or infinite, or if a maximum coordinate is less than or equal to the
corresponding minimum coordinate.
.. seealso:: :py:func:`isNull`
.. versionadded:: 4.0
%End
bool isMaximal() const;
%Docstring
Test if the rectangle is the maximal possible rectangle.
A rectangle is considered maximal if all boundaries are either at their
maximum possible values or are infinite values.
.. seealso:: :py:func:`isFinite`
.. seealso:: :py:func:`isNull`
.. seealso:: :py:func:`isEmpty`
.. versionadded:: 3.44
%End
QString asWktCoordinates() const;
%Docstring
Returns a string representation of the rectangle in WKT format.
%End
QString asWktPolygon() const;
%Docstring
Returns a string representation of the rectangle as a WKT Polygon.
%End
QRectF toRectF() const;
%Docstring
Returns a QRectF with same coordinates as the rectangle.
%End
QString toString( int precision = 16 ) const;
%Docstring
Returns a string representation of form xmin,ymin : xmax,ymax
Coordinates will be truncated to the specified precision. If the
specified precision is less than 0, a suitable minimum precision is
used.
%End
QString asPolygon() const;
%Docstring
Returns the rectangle as a polygon.
%End
bool operator==( const QgsRectangle &r1 ) const;
bool operator!=( const QgsRectangle &r1 ) const;
bool isFinite() const;
%Docstring
Returns ``True`` if the rectangle has finite boundaries. Will return
``False`` if any of the rectangle boundaries are NaN or Inf.
.. seealso:: :py:func:`isMaximal`
.. seealso:: :py:func:`isNull`
.. seealso:: :py:func:`isEmpty`
%End
void invert();
%Docstring
Swap x/y coordinates in the rectangle.
%End
QgsBox3D toBox3d( double zMin, double zMax ) const;
%Docstring
Converts the rectangle to a 3D box, with the specified ``zMin`` and
``zMax`` z values.
%End
operator QVariant() const;
QgsRectangle snappedToGrid( double spacing ) const;
%Docstring
Returns a copy of this rectangle that is snapped to a grid with the
specified ``spacing`` between the grid lines.
.. versionadded:: 3.4
%End
SIP_PYOBJECT __repr__();
%MethodCode
QString str;
if ( sipCpp->isNull() )
str = QStringLiteral( "<QgsRectangle()>" );
else
str = QStringLiteral( "<QgsRectangle: %1>" ).arg( sipCpp->asWktCoordinates() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geometry/qgsrectangle.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/