mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-09 00:08:52 -04:00
This prevents the Python GIL from being released before calling the method (which is the default behaviour). For very cheap to call c++ methods the cost of releasing the GIL can outweigh the cost of the c++ call, which means it's more efficient to retain the hold on the GIL. Ideally we'd do this everywhere, and switch to an explicit ReleaseGIL annotation on functions which are slow or risky (raise exceptions, or do something which can cause a GIL deadlock). But those are very tricky to identify, so instead just explicitly hold the gil on cheap methods which are likely to be called many times and could have an impact on script performance.
364 lines
8.8 KiB
Plaintext
364 lines
8.8 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/geometry/qgsrectangle.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsRectangle
|
|
{
|
|
%Docstring
|
|
A rectangle specified with double values.
|
|
|
|
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:
|
|
|
|
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 ) /HoldGIL/;
|
|
%Docstring
|
|
Constructor
|
|
%End
|
|
|
|
QgsRectangle( const QgsPointXY &p1, const QgsPointXY &p2 ) /HoldGIL/;
|
|
%Docstring
|
|
Construct a rectangle from two points. The rectangle is normalized after construction.
|
|
%End
|
|
|
|
QgsRectangle( const QRectF &qRectF ) /HoldGIL/;
|
|
%Docstring
|
|
Construct a rectangle from a QRectF. The rectangle is normalized after construction.
|
|
%End
|
|
|
|
QgsRectangle( const QgsRectangle &other ) /HoldGIL/;
|
|
%Docstring
|
|
Copy constructor
|
|
%End
|
|
|
|
~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.
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
static QgsRectangle fromCenterAndSize( QgsPointXY center, double width, double height );
|
|
%Docstring
|
|
Creates a new rectangle, given the specified ``center`` point
|
|
and ``width`` and ``height``.
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
void set( const QgsPointXY &p1, const QgsPointXY &p2 );
|
|
%Docstring
|
|
Sets the rectangle from two :py:class:`QgsPoints`. The rectangle is
|
|
normalised after construction.
|
|
%End
|
|
|
|
void set( double xMin, double yMin, double xMax, double yMax );
|
|
%Docstring
|
|
Sets the rectangle from four points. The rectangle is
|
|
normalised after construction.
|
|
%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 setMinimal() /HoldGIL/;
|
|
%Docstring
|
|
Set a rectangle so that min corner is at max
|
|
and max corner is at min. It is NOT normalized.
|
|
%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`
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
double perimeter() const /HoldGIL/;
|
|
%Docstring
|
|
Returns the perimeter of the rectangle.
|
|
|
|
.. seealso:: :py:func:`area`
|
|
|
|
.. versionadded:: 3.0
|
|
%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`
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
QgsRectangle intersect( const QgsRectangle &rect ) const;
|
|
%Docstring
|
|
Returns the intersection with the given rectangle.
|
|
%End
|
|
|
|
bool intersects( const QgsRectangle &rect ) const;
|
|
%Docstring
|
|
Returns ``True`` when rectangle intersects with other rectangle.
|
|
%End
|
|
|
|
bool contains( const QgsRectangle &rect ) const;
|
|
%Docstring
|
|
Returns ``True`` when rectangle contains other rectangle.
|
|
%End
|
|
|
|
bool contains( const QgsPointXY &p ) const;
|
|
%Docstring
|
|
Returns ``True`` when rectangle contains a point.
|
|
%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 is empty.
|
|
An empty rectangle may still be non-null if it contains valid information (e.g. bounding box of a point).
|
|
%End
|
|
|
|
bool isNull() const;
|
|
%Docstring
|
|
Test if the rectangle is null (all coordinates zero or after call to :py:func:`~QgsRectangle.setMinimal`).
|
|
A null rectangle is also an empty rectangle.
|
|
|
|
.. versionadded:: 2.4
|
|
%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.
|
|
%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.
|
|
|
|
.. versionadded:: 3.0
|
|
%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 = 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.pl again *
|
|
************************************************************************/
|