QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
A rectangle specified with double values. More...
#include <qgsrectangle.h>
Public Member Functions | |
QgsRectangle (double xmin=0, double ymin=0, double xmax=0, double ymax=0) | |
Constructor. More... | |
QgsRectangle (const QgsPoint &p1, const QgsPoint &p2) | |
Construct a rectangle from two points. The rectangle is normalized after construction. More... | |
QgsRectangle (const QRectF &qRectF) | |
Construct a rectangle from a QRectF. The rectangle is normalized after construction. More... | |
QgsRectangle (const QgsRectangle &other) | |
Copy constructor. More... | |
~QgsRectangle () | |
Destructor. More... | |
QString | asPolygon () const |
returns rectangle as a polygon More... | |
QString | asWktCoordinates () const |
returns string representation in Wkt form More... | |
QString | asWktPolygon () const |
returns string representation as WKT Polygon More... | |
QgsRectangle | buffer (double width) |
Get rectangle enlarged by buffer. More... | |
QgsPoint | center () const |
Center point of the rectangle. More... | |
void | combineExtentWith (const QgsRectangle &rect) |
expand the rectangle so that covers both the original rectangle and the given rectangle More... | |
void | combineExtentWith (double x, double y) |
expand the rectangle so that covers both the original rectangle and the given point More... | |
bool | contains (const QgsRectangle &rect) const |
return true when rectangle contains other rectangle More... | |
bool | contains (const QgsPoint &p) const |
return true when rectangle contains a point More... | |
void | grow (double delta) |
Grow the rectangle by the specified amount. More... | |
double | height () const |
Height of the rectangle. More... | |
void | include (const QgsPoint &p) |
Updates the rectangle to include the specified point. More... | |
QgsRectangle | intersect (const QgsRectangle *rect) const |
return the intersection with the given rectangle More... | |
bool | intersects (const QgsRectangle &rect) const |
returns true when rectangle intersects with other rectangle More... | |
void | invert () |
swap x/y More... | |
bool | isEmpty () const |
test if rectangle is empty. More... | |
bool | isFinite () const |
Returns true if the rectangle has finite boundaries. More... | |
bool | isNull () const |
test if the rectangle is null (all coordinates zero or after call to setMinimal()). More... | |
void | normalize () |
Normalize the rectangle so it has non-negative width/height. More... | |
bool | operator!= (const QgsRectangle &r1) const |
Comparison operator. More... | |
QgsRectangle & | operator= (const QgsRectangle &r1) |
Assignment operator. More... | |
bool | operator== (const QgsRectangle &r1) const |
Comparison operator. More... | |
void | scale (double scaleFactor, const QgsPoint *c=nullptr) |
Scale the rectangle around its center point. More... | |
void | scale (double scaleFactor, double centerX, double centerY) |
void | set (const QgsPoint &p1, const QgsPoint &p2) |
Set the rectangle from two QgsPoints. More... | |
void | set (double xmin, double ymin, double xmax, double ymax) |
Set the rectangle from four points. More... | |
void | setMinimal () |
Set a rectangle so that min corner is at max and max corner is at min. More... | |
void | setXMaximum (double x) |
Set the maximum x value. More... | |
void | setXMinimum (double x) |
Set the minimum x value. More... | |
void | setYMaximum (double y) |
Set the maximum y value. More... | |
void | setYMinimum (double y) |
Set the minimum y value. More... | |
QRectF | toRectF () const |
returns a QRectF with same coordinates. More... | |
QString | toString (bool automaticPrecision=false) const |
returns string representation of form xmin,ymin xmax,ymax More... | |
QString | toString (int thePrecision) const |
overloaded toString that allows precision of numbers to be set More... | |
void | unionRect (const QgsRectangle &rect) |
Updates rectangle to include passed argument. More... | |
double | width () const |
Width of the rectangle. More... | |
double | xMaximum () const |
Get the x maximum value (right side of rectangle) More... | |
double | xMinimum () const |
Get the x minimum value (left side of rectangle) More... | |
double | yMaximum () const |
Get the y maximum value (top side of rectangle) More... | |
double | yMinimum () const |
Get the y minimum value (bottom side of rectangle) More... | |
Protected Attributes | |
double | xmax |
double | xmin |
double | ymax |
double | ymin |
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 35 of file qgsrectangle.h.
QgsRectangle::QgsRectangle | ( | double | xmin = 0 , |
double | ymin = 0 , |
||
double | xmax = 0 , |
||
double | ymax = 0 |
||
) |
Constructor.
Definition at line 32 of file qgsrectangle.cpp.
Construct a rectangle from two points. The rectangle is normalized after construction.
Definition at line 41 of file qgsrectangle.cpp.
QgsRectangle::QgsRectangle | ( | const QRectF & | qRectF | ) |
Construct a rectangle from a QRectF. The rectangle is normalized after construction.
Definition at line 46 of file qgsrectangle.cpp.
QgsRectangle::QgsRectangle | ( | const QgsRectangle & | other | ) |
Copy constructor.
Definition at line 54 of file qgsrectangle.cpp.
|
inline |
Destructor.
Definition at line 163 of file qgsrectangle.h.
QString QgsRectangle::asPolygon | ( | ) | const |
returns rectangle as a polygon
Definition at line 301 of file qgsrectangle.cpp.
QString QgsRectangle::asWktCoordinates | ( | ) | const |
returns string representation in Wkt form
Definition at line 232 of file qgsrectangle.cpp.
QString QgsRectangle::asWktPolygon | ( | ) | const |
returns string representation as WKT Polygon
Definition at line 241 of file qgsrectangle.cpp.
QgsRectangle QgsRectangle::buffer | ( | double | width | ) |
|
inline |
Center point of the rectangle.
Definition at line 217 of file qgsrectangle.h.
void QgsRectangle::combineExtentWith | ( | const QgsRectangle & | rect | ) |
expand the rectangle so that covers both the original rectangle and the given rectangle
Definition at line 197 of file qgsrectangle.cpp.
void QgsRectangle::combineExtentWith | ( | double | x, |
double | y | ||
) |
expand the rectangle so that covers both the original rectangle and the given point
Definition at line 208 of file qgsrectangle.cpp.
bool QgsRectangle::contains | ( | const QgsRectangle & | rect | ) | const |
return true when rectangle contains other rectangle
Definition at line 186 of file qgsrectangle.cpp.
bool QgsRectangle::contains | ( | const QgsPoint & | p | ) | const |
return true when rectangle contains a point
Definition at line 191 of file qgsrectangle.cpp.
void QgsRectangle::grow | ( | double | delta | ) |
Grow the rectangle by the specified amount.
Definition at line 132 of file qgsrectangle.cpp.
|
inline |
Height of the rectangle.
Definition at line 212 of file qgsrectangle.h.
void QgsRectangle::include | ( | const QgsPoint & | p | ) |
Updates the rectangle to include the specified point.
Definition at line 140 of file qgsrectangle.cpp.
QgsRectangle QgsRectangle::intersect | ( | const QgsRectangle * | rect | ) | const |
return the intersection with the given rectangle
Definition at line 157 of file qgsrectangle.cpp.
bool QgsRectangle::intersects | ( | const QgsRectangle & | rect | ) | const |
returns true when rectangle intersects with other rectangle
Definition at line 173 of file qgsrectangle.cpp.
void QgsRectangle::invert | ( | ) |
swap x/y
Definition at line 379 of file qgsrectangle.cpp.
bool QgsRectangle::isEmpty | ( | ) | const |
test if rectangle is empty.
Empty rectangle may still be non-null if it contains valid information (e.g. bounding box of a point)
Definition at line 219 of file qgsrectangle.cpp.
bool QgsRectangle::isFinite | ( | ) | const |
Returns true if the rectangle has finite boundaries.
Will return false if any of the rectangle boundaries are NaN or Inf.
Definition at line 366 of file qgsrectangle.cpp.
bool QgsRectangle::isNull | ( | ) | const |
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
Null rectangle is also an empty rectangle.
Definition at line 224 of file qgsrectangle.cpp.
void QgsRectangle::normalize | ( | ) |
Normalize the rectangle so it has non-negative width/height.
Definition at line 81 of file qgsrectangle.cpp.
bool QgsRectangle::operator!= | ( | const QgsRectangle & | r1 | ) | const |
Comparison operator.
Definition at line 334 of file qgsrectangle.cpp.
QgsRectangle & QgsRectangle::operator= | ( | const QgsRectangle & | r1 | ) |
Assignment operator.
r1 | QgsRectangle to assign from |
Definition at line 340 of file qgsrectangle.cpp.
bool QgsRectangle::operator== | ( | const QgsRectangle & | r1 | ) | const |
Comparison operator.
Definition at line 325 of file qgsrectangle.cpp.
void QgsRectangle::scale | ( | double | scaleFactor, |
const QgsPoint * | c = nullptr |
||
) |
Scale the rectangle around its center point.
Definition at line 105 of file qgsrectangle.cpp.
void QgsRectangle::scale | ( | double | scaleFactor, |
double | centerX, | ||
double | centerY | ||
) |
Definition at line 122 of file qgsrectangle.cpp.
Set the rectangle from two QgsPoints.
The rectangle is normalised after construction.
Definition at line 63 of file qgsrectangle.cpp.
void QgsRectangle::set | ( | double | xmin, |
double | ymin, | ||
double | xmax, | ||
double | ymax | ||
) |
Set the rectangle from four points.
The rectangle is normalised after construction.
Definition at line 72 of file qgsrectangle.cpp.
void QgsRectangle::setMinimal | ( | ) |
Set a rectangle so that min corner is at max and max corner is at min.
It is NOT normalized.
Definition at line 97 of file qgsrectangle.cpp.
|
inline |
Set the maximum x value.
Definition at line 172 of file qgsrectangle.h.
|
inline |
Set the minimum x value.
Definition at line 167 of file qgsrectangle.h.
|
inline |
Set the maximum y value.
Definition at line 182 of file qgsrectangle.h.
|
inline |
Set the minimum y value.
Definition at line 177 of file qgsrectangle.h.
QRectF QgsRectangle::toRectF | ( | ) | const |
returns a QRectF with same coordinates.
Definition at line 256 of file qgsrectangle.cpp.
QString QgsRectangle::toString | ( | bool | automaticPrecision = false | ) | const |
returns string representation of form xmin,ymin xmax,ymax
Definition at line 262 of file qgsrectangle.cpp.
QString QgsRectangle::toString | ( | int | thePrecision | ) | const |
overloaded toString that allows precision of numbers to be set
Definition at line 282 of file qgsrectangle.cpp.
void QgsRectangle::unionRect | ( | const QgsRectangle & | rect | ) |
Updates rectangle to include passed argument.
Definition at line 354 of file qgsrectangle.cpp.
|
inline |
Width of the rectangle.
Definition at line 207 of file qgsrectangle.h.
|
inline |
Get the x maximum value (right side of rectangle)
Definition at line 187 of file qgsrectangle.h.
|
inline |
Get the x minimum value (left side of rectangle)
Definition at line 192 of file qgsrectangle.h.
|
inline |
Get the y maximum value (top side of rectangle)
Definition at line 197 of file qgsrectangle.h.
|
inline |
Get the y minimum value (bottom side of rectangle)
Definition at line 202 of file qgsrectangle.h.
|
protected |
Definition at line 153 of file qgsrectangle.h.
|
protected |
Definition at line 151 of file qgsrectangle.h.
|
protected |
Definition at line 154 of file qgsrectangle.h.
|
protected |
Definition at line 152 of file qgsrectangle.h.