QGIS API Documentation
2.6.0-Brighton
|
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. | |
QgsRectangle (const QgsPoint &p1, const QgsPoint &p2) | |
Construct a rectangle from two points. The rectangle is normalized after construction. | |
QgsRectangle (const QRectF &qRectF) | |
Construct a rectangle from a QRectF. The rectangle is normalized after construction. | |
QgsRectangle (const QgsRectangle &other) | |
Copy constructor. | |
~QgsRectangle () | |
Destructor. | |
void | set (const QgsPoint &p1, const QgsPoint &p2) |
Set the rectangle from two QgsPoints. | |
void | set (double xmin, double ymin, double xmax, double ymax) |
Set the rectangle from four points. | |
void | setXMinimum (double x) |
Set the minimum x value. | |
void | setXMaximum (double x) |
Set the maximum x value. | |
void | setYMinimum (double y) |
Set the minimum y value. | |
void | setYMaximum (double y) |
Set the maximum y value. | |
void | setMinimal () |
Set a rectangle so that min corner is at max and max corner is at min. | |
double | xMaximum () const |
Get the x maximum value (right side of rectangle) | |
double | xMinimum () const |
Get the x minimum value (left side of rectangle) | |
double | yMaximum () const |
Get the y maximum value (top side of rectangle) | |
double | yMinimum () const |
Get the y minimum value (bottom side of rectangle) | |
void | normalize () |
Normalize the rectangle so it has non-negative width/height. | |
double | width () const |
Width of the rectangle. | |
double | height () const |
Height of the rectangle. | |
QgsPoint | center () const |
Center point of the rectangle. | |
void | scale (double scaleFactor, const QgsPoint *c=0) |
Scale the rectangle around its center point. | |
void | scale (double scaleFactor, double centerX, double centerY) |
QgsRectangle | buffer (double width) |
Get rectangle enlarged by buffer. | |
QgsRectangle | intersect (const QgsRectangle *rect) const |
return the intersection with the given rectangle | |
bool | intersects (const QgsRectangle &rect) const |
returns true when rectangle intersects with other rectangle | |
bool | contains (const QgsRectangle &rect) const |
return true when rectangle contains other rectangle | |
bool | contains (const QgsPoint &p) const |
return true when rectangle contains a point | |
void | combineExtentWith (QgsRectangle *rect) |
expand the rectangle so that covers both the original rectangle and the given rectangle | |
void | combineExtentWith (double x, double y) |
expand the rectangle so that covers both the original rectangle and the given point | |
bool | isEmpty () const |
test if rectangle is empty. | |
bool | isNull () const |
test if the rectangle is null (all coordinates zero or after call to setMinimal()). | |
QString | asWktCoordinates () const |
returns string representation in Wkt form | |
QString | asWktPolygon () const |
returns string representation as WKT Polygon | |
QRectF | toRectF () const |
returns a QRectF with same coordinates. | |
QString | toString (bool automaticPrecision=false) const |
returns string representation of form xmin,ymin xmax,ymax | |
QString | toString (int thePrecision) const |
overloaded toString that allows precision of numbers to be set | |
QString | asPolygon () const |
returns rectangle as a polygon | |
bool | operator== (const QgsRectangle &r1) const |
bool | operator!= (const QgsRectangle &r1) const |
QgsRectangle & | operator= (const QgsRectangle &r1) |
void | unionRect (const QgsRectangle &rect) |
updates rectangle to include passed argument | |
bool | isFinite () const |
Returns true if the rectangle has finite boundaries. | |
void | invert () |
swap x/y |
Protected Attributes | |
double | xmin |
double | ymin |
double | xmax |
double | ymax |
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
QgsRectangle::QgsRectangle | ( | double | xmin = 0 , |
double | ymin = 0 , |
||
double | xmax = 0 , |
||
double | ymax = 0 |
||
) |
Constructor.
Construct a rectangle from two points. The rectangle is normalized after construction.
QgsRectangle::QgsRectangle | ( | const QRectF & | qRectF | ) |
Construct a rectangle from a QRectF. The rectangle is normalized after construction.
QgsRectangle::QgsRectangle | ( | const QgsRectangle & | other | ) |
Copy constructor.
|
inline |
Destructor.
QString QgsRectangle::asPolygon | ( | ) | const |
returns rectangle as a polygon
QString QgsRectangle::asWktCoordinates | ( | ) | const |
returns string representation in Wkt form
QString QgsRectangle::asWktPolygon | ( | ) | const |
returns string representation as WKT Polygon
QgsRectangle QgsRectangle::buffer | ( | double | width | ) |
Get rectangle enlarged by buffer.
|
inline |
Center point of the rectangle.
void QgsRectangle::combineExtentWith | ( | QgsRectangle * | rect | ) |
expand the rectangle so that covers both the original rectangle and the given rectangle
void QgsRectangle::combineExtentWith | ( | double | x, |
double | y | ||
) |
expand the rectangle so that covers both the original rectangle and the given point
bool QgsRectangle::contains | ( | const QgsRectangle & | rect | ) | const |
return true when rectangle contains other rectangle
bool QgsRectangle::contains | ( | const QgsPoint & | p | ) | const |
return true when rectangle contains a point
|
inline |
Height of the rectangle.
QgsRectangle QgsRectangle::intersect | ( | const QgsRectangle * | rect | ) | const |
return the intersection with the given rectangle
bool QgsRectangle::intersects | ( | const QgsRectangle & | rect | ) | const |
returns true when rectangle intersects with other rectangle
void QgsRectangle::invert | ( | ) |
swap x/y
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)
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.
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.
void QgsRectangle::normalize | ( | ) |
Normalize the rectangle so it has non-negative width/height.
bool QgsRectangle::operator!= | ( | const QgsRectangle & | r1 | ) | const |
Comparison operator
QgsRectangle & QgsRectangle::operator= | ( | const QgsRectangle & | r1 | ) |
Assignment operator
r1 | QgsRectangle to assign from |
bool QgsRectangle::operator== | ( | const QgsRectangle & | r1 | ) | const |
Comparison operator
void QgsRectangle::scale | ( | double | scaleFactor, |
const QgsPoint * | c = 0 |
||
) |
Scale the rectangle around its center point.
void QgsRectangle::scale | ( | double | scaleFactor, |
double | centerX, | ||
double | centerY | ||
) |
Set the rectangle from two QgsPoints.
The rectangle is normalised after construction.
void QgsRectangle::set | ( | double | xmin, |
double | ymin, | ||
double | xmax, | ||
double | ymax | ||
) |
Set the rectangle from four points.
The rectangle is normalised after construction.
void QgsRectangle::setMinimal | ( | ) |
Set a rectangle so that min corner is at max and max corner is at min.
It is NOT normalized.
|
inline |
Set the maximum x value.
|
inline |
Set the minimum x value.
|
inline |
Set the maximum y value.
|
inline |
Set the minimum y value.
QRectF QgsRectangle::toRectF | ( | ) | const |
returns a QRectF with same coordinates.
QString QgsRectangle::toString | ( | bool | automaticPrecision = false | ) | const |
returns string representation of form xmin,ymin xmax,ymax
QString QgsRectangle::toString | ( | int | thePrecision | ) | const |
overloaded toString that allows precision of numbers to be set
void QgsRectangle::unionRect | ( | const QgsRectangle & | rect | ) |
updates rectangle to include passed argument
|
inline |
Width of the rectangle.
|
inline |
Get the x maximum value (right side of rectangle)
|
inline |
Get the x minimum value (left side of rectangle)
|
inline |
Get the y maximum value (top side of rectangle)
|
inline |
Get the y minimum value (bottom side of rectangle)
|
protected |
|
protected |
|
protected |
|
protected |