|
QGIS API Documentation 3.99.0-Master (2fe06baccd8)
|
A rectangle specified with double values. More...
#include <qgsrectangle.h>

Public Member Functions | |
| QgsRectangle ()=default | |
| Constructor for a null rectangle. | |
| QgsRectangle (const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true) | |
| Construct a rectangle from two points. | |
| QgsRectangle (const QgsRectangle &other) | |
| QgsRectangle (const QRectF &qRectF) | |
| Construct a rectangle from a QRectF. | |
| QgsRectangle (double xMin, double yMin=0, double xMax=0, double yMax=0, bool normalize=true) | |
| Constructs a QgsRectangle from a set of x and y minimum and maximum coordinates. | |
| ~QgsRectangle ()=default | |
| double | area () const |
| Returns the area of the rectangle. | |
| QString | asPolygon () const |
| Returns the rectangle as a polygon. | |
| Q_INVOKABLE QString | asWktCoordinates () const |
| Returns a string representation of the rectangle in WKT format. | |
| Q_INVOKABLE QString | asWktPolygon () const |
| Returns a string representation of the rectangle as a WKT Polygon. | |
| QgsRectangle | buffered (double width) const |
| Gets rectangle enlarged by buffer. | |
| QgsPointXY | center () const |
| Returns the center point of the rectangle. | |
| void | combineExtentWith (const QgsPointXY &point) |
| Expands the rectangle so that it covers both the original rectangle and the given point. | |
| void | combineExtentWith (const QgsRectangle &rect) |
| Expands the rectangle so that it covers both the original rectangle and the given rectangle. | |
| void | combineExtentWith (double x, double y) |
| Expands the rectangle so that it covers both the original rectangle and the given point. | |
| bool | contains (const QgsPointXY &p) const |
Returns true when rectangle contains a point. | |
| bool | contains (const QgsRectangle &rect) const |
Returns true when rectangle contains other rectangle. | |
| bool | contains (double x, double y) const |
Returns true when rectangle contains the point at (x, y). | |
| double | distance (const QgsPointXY &point) const |
| Returns the distance from point to the nearest point on the boundary of the rectangle. | |
| void | grow (double delta) |
| Grows the rectangle in place by the specified amount. | |
| double | height () const |
| Returns the height of the rectangle. | |
| void | include (const QgsPointXY &p) |
| Updates the rectangle to include the specified point. | |
| QgsRectangle | intersect (const QgsRectangle &rect) const |
| Returns the intersection with the given rectangle. | |
| bool | intersects (const QgsRectangle &rect) const |
Returns true when rectangle intersects with other rectangle. | |
| void | invert () |
| Swap x/y coordinates in the rectangle. | |
| bool | isEmpty () const |
Returns true if the rectangle has no area. | |
| bool | isFinite () const |
Returns true if the rectangle has finite boundaries. | |
| bool | isMaximal () const |
| Test if the rectangle is the maximal possible rectangle. | |
| bool | isNull () const |
| Test if the rectangle is null (holding no spatial information). | |
| bool | isValid () const |
| Test if the rectangle is valid. | |
| void | normalize () |
| Normalize the rectangle so it has non-negative width/height. | |
| operator QVariant () const | |
| Allows direct construction of QVariants from rectangles. | |
| bool | operator!= (const QgsRectangle &r1) const |
| QgsRectangle | operator+ (QgsVector v) const |
| Returns a rectangle offset from this one in the direction of the vector. | |
| QgsRectangle & | operator+= (QgsVector v) |
| Moves this rectangle in the direction of the vector. | |
| QgsRectangle | operator- (QgsVector v) const |
| Returns a rectangle offset from this one in the direction of the reversed vector. | |
| QgsRectangle & | operator-= (QgsVector v) |
| Moves this rectangle in the direction of the reversed vector. | |
| QgsRectangle & | operator= (const QgsRectangle &r1) |
| bool | operator== (const QgsRectangle &r1) const |
| double | perimeter () const |
| Returns the perimeter of the rectangle. | |
| void | scale (double scaleFactor, const QgsPointXY *c=nullptr) |
| Scale the rectangle around its center point. | |
| void | scale (double scaleFactor, double centerX, double centerY) |
| Scale the rectangle around its center point. | |
| QgsRectangle | scaled (double scaleFactor, const QgsPointXY *center=nullptr) const |
| Scale the rectangle around its center point. | |
| void | set (const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true) |
| Sets the rectangle from two QgsPoints. | |
| void | set (double xMin, double yMin, double xMax, double yMax, bool normalize=true) |
| Sets the rectangle from four points. | |
| Q_DECL_DEPRECATED void | setMinimal () |
| Set a rectangle so that min corner is at max and max corner is at min. | |
| void | setNull () |
| Mark a rectangle as being null (holding no spatial information). | |
| void | setXMaximum (double x) |
| Set the maximum x value. | |
| void | setXMinimum (double x) |
| Set the minimum x value. | |
| void | setYMaximum (double y) |
| Set the maximum y value. | |
| void | setYMinimum (double y) |
| Set the minimum y value. | |
| QgsRectangle | snappedToGrid (double spacing) const |
| Returns a copy of this rectangle that is snapped to a grid with the specified spacing between the grid lines. | |
| QgsBox3D | toBox3d (double zMin, double zMax) const |
| Converts the rectangle to a 3D box, with the specified zMin and zMax z values. | |
| QRectF | toRectF () const |
| Returns a QRectF with same coordinates as the rectangle. | |
| Q_INVOKABLE QString | toString (int precision=16) const |
| Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the specified precision. | |
| double | width () const |
| Returns the width of the rectangle. | |
| double | xMaximum () const |
| Returns the x maximum value (right side of rectangle). | |
| double | xMinimum () const |
| Returns the x minimum value (left side of rectangle). | |
| double | yMaximum () const |
| Returns the y maximum value (top side of rectangle). | |
| double | yMinimum () const |
| Returns the y minimum value (bottom side of rectangle). | |
Static Public Member Functions | |
| static QgsRectangle | fromCenterAndSize (const QgsPointXY ¢er, double width, double height) |
| Creates a new rectangle, given the specified center point and width and height. | |
| static QgsRectangle | fromWkt (const QString &wkt) |
| Creates a new rectangle from a wkt string. | |
Properties | |
| double | area |
| QgsPointXY | center |
| double | height |
| bool | isEmpty |
| bool | isNull |
| bool | isValid |
| double | perimeter |
| double | width |
| double | xMaximum |
| double | xMinimum |
| double | yMaximum |
| double | yMinimum |
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
Definition at line 43 of file qgsrectangle.h.
|
default |
Constructor for a null rectangle.
|
inlineexplicit |
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.
Definition at line 71 of file qgsrectangle.h.
|
inline |
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.
Definition at line 87 of file qgsrectangle.h.
|
inline |
Construct a rectangle from a QRectF.
The rectangle is NOT normalized after construction.
Definition at line 97 of file qgsrectangle.h.
|
inline |
Definition at line 105 of file qgsrectangle.h.
|
default |
|
inline |
Returns the area of the rectangle.
Definition at line 267 of file qgsrectangle.h.
| QString QgsRectangle::asPolygon | ( | ) | const |
Returns the rectangle as a polygon.
Definition at line 166 of file qgsrectangle.cpp.
| QString QgsRectangle::asWktCoordinates | ( | ) | const |
Returns a string representation of the rectangle in WKT format.
Definition at line 112 of file qgsrectangle.cpp.
| QString QgsRectangle::asWktPolygon | ( | ) | const |
Returns a string representation of the rectangle as a WKT Polygon.
Definition at line 121 of file qgsrectangle.cpp.
|
inline |
Gets rectangle enlarged by buffer.
Definition at line 361 of file qgsrectangle.h.
|
inline |
Returns the center point of the rectangle.
Definition at line 278 of file qgsrectangle.h.
|
inline |
Expands the rectangle so that it covers both the original rectangle and the given point.
Definition at line 468 of file qgsrectangle.h.
|
inline |
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
Definition at line 434 of file qgsrectangle.h.
|
inline |
Expands the rectangle so that it covers both the original rectangle and the given point.
Definition at line 450 of file qgsrectangle.h.
|
inline |
Returns true when rectangle contains a point.
Definition at line 414 of file qgsrectangle.h.
|
inline |
Returns true when rectangle contains other rectangle.
Definition at line 406 of file qgsrectangle.h.
|
inline |
Returns true when rectangle contains the point at (x, y).
Definition at line 425 of file qgsrectangle.h.
|
inline |
Returns the distance from point to the nearest point on the boundary of the rectangle.
Definition at line 477 of file qgsrectangle.h.
|
static |
Creates a new rectangle, given the specified center point and width and height.
Definition at line 60 of file qgsrectangle.cpp.
|
static |
Creates a new rectangle from a wkt string.
The WKT must contain only 5 vertices, representing a rectangle aligned with X and Y axes.
Definition at line 37 of file qgsrectangle.cpp.
|
inline |
Grows the rectangle in place by the specified amount.
Definition at line 323 of file qgsrectangle.h.
|
inline |
Returns the height of the rectangle.
Definition at line 259 of file qgsrectangle.h.
|
inline |
Updates the rectangle to include the specified point.
Definition at line 336 of file qgsrectangle.h.
|
inline |
Returns the intersection with the given rectangle.
Definition at line 371 of file qgsrectangle.h.
|
inline |
Returns true when rectangle intersects with other rectangle.
Definition at line 387 of file qgsrectangle.h.
|
inline |
Swap x/y coordinates in the rectangle.
Definition at line 657 of file qgsrectangle.h.
|
inline |
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).
Definition at line 513 of file qgsrectangle.h.
|
inline |
Returns true if the rectangle has finite boundaries.
Will return false if any of the rectangle boundaries are NaN or Inf.
Definition at line 641 of file qgsrectangle.h.
|
inline |
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.
Definition at line 567 of file qgsrectangle.h.
|
inline |
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.
Definition at line 528 of file qgsrectangle.h.
|
inline |
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.
Definition at line 546 of file qgsrectangle.h.
|
inline |
Normalize the rectangle so it has non-negative width/height.
Definition at line 232 of file qgsrectangle.h.
|
inline |
Allows direct construction of QVariants from rectangles.
Definition at line 670 of file qgsrectangle.h.
|
inline |
Definition at line 615 of file qgsrectangle.h.
| QgsRectangle QgsRectangle::operator+ | ( | QgsVector | v | ) | const |
Returns a rectangle offset from this one in the direction of the vector.
Definition at line 85 of file qgsrectangle.cpp.
| QgsRectangle & QgsRectangle::operator+= | ( | QgsVector | v | ) |
Moves this rectangle in the direction of the vector.
Definition at line 103 of file qgsrectangle.cpp.
| QgsRectangle QgsRectangle::operator- | ( | QgsVector | v | ) | const |
Returns a rectangle offset from this one in the direction of the reversed vector.
Definition at line 76 of file qgsrectangle.cpp.
| QgsRectangle & QgsRectangle::operator-= | ( | QgsVector | v | ) |
Moves this rectangle in the direction of the reversed vector.
Definition at line 94 of file qgsrectangle.cpp.
|
inline |
Definition at line 620 of file qgsrectangle.h.
|
inline |
Definition at line 605 of file qgsrectangle.h.
|
inline |
Returns the perimeter of the rectangle.
Definition at line 273 of file qgsrectangle.h.
|
inline |
Scale the rectangle around its center point.
Definition at line 283 of file qgsrectangle.h.
|
inline |
Scale the rectangle around its center point.
Definition at line 303 of file qgsrectangle.h.
| QgsRectangle QgsRectangle::scaled | ( | double | scaleFactor, |
| const QgsPointXY * | center = nullptr ) const |
Scale the rectangle around its center point.
Definition at line 69 of file qgsrectangle.cpp.
|
inline |
Sets the rectangle from two QgsPoints.
The rectangle is normalised after construction. Since QGIS 3.20, if normalize is false then the normalization step will not be applied automatically.
Definition at line 136 of file qgsrectangle.h.
|
inline |
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.
Definition at line 152 of file qgsrectangle.h.
|
inline |
Set a rectangle so that min corner is at max and max corner is at min.
It is NOT normalized.
Definition at line 204 of file qgsrectangle.h.
|
inline |
Mark a rectangle as being null (holding no spatial information).
A null rectangle is also empty by definition.
Definition at line 192 of file qgsrectangle.h.
|
inline |
Set the maximum x value.
Definition at line 170 of file qgsrectangle.h.
|
inline |
Set the minimum x value.
Definition at line 165 of file qgsrectangle.h.
|
inline |
Set the maximum y value.
Definition at line 180 of file qgsrectangle.h.
|
inline |
Set the minimum y value.
Definition at line 175 of file qgsrectangle.h.
| QgsRectangle QgsRectangle::snappedToGrid | ( | double | spacing | ) | const |
Returns a copy of this rectangle that is snapped to a grid with the specified spacing between the grid lines.
Definition at line 197 of file qgsrectangle.cpp.
| QgsBox3D QgsRectangle::toBox3d | ( | double | zMin, |
| double | zMax ) const |
Converts the rectangle to a 3D box, with the specified zMin and zMax z values.
Definition at line 192 of file qgsrectangle.cpp.
|
inline |
Returns a QRectF with same coordinates as the rectangle.
Definition at line 588 of file qgsrectangle.h.
| QString QgsRectangle::toString | ( | int | precision = 16 | ) | const |
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.
Definition at line 136 of file qgsrectangle.cpp.
|
inline |
Returns the width of the rectangle.
Definition at line 252 of file qgsrectangle.h.
|
inline |
Returns the x maximum value (right side of rectangle).
Definition at line 212 of file qgsrectangle.h.
|
inline |
Returns the x minimum value (left side of rectangle).
Definition at line 217 of file qgsrectangle.h.
|
inline |
Returns the y maximum value (top side of rectangle).
Definition at line 222 of file qgsrectangle.h.
|
inline |
Returns the y minimum value (bottom side of rectangle).
Definition at line 227 of file qgsrectangle.h.
|
read |
Definition at line 53 of file qgsrectangle.h.
|
read |
Definition at line 55 of file qgsrectangle.h.
|
read |
Definition at line 52 of file qgsrectangle.h.
|
read |
Definition at line 56 of file qgsrectangle.h.
|
read |
Definition at line 57 of file qgsrectangle.h.
|
read |
Definition at line 58 of file qgsrectangle.h.
|
read |
Definition at line 54 of file qgsrectangle.h.
|
read |
Definition at line 51 of file qgsrectangle.h.
|
readwrite |
Definition at line 48 of file qgsrectangle.h.
|
readwrite |
Definition at line 47 of file qgsrectangle.h.
|
readwrite |
Definition at line 50 of file qgsrectangle.h.
|
readwrite |
Definition at line 49 of file qgsrectangle.h.