QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Attributes | List of all members
QgsRectangle Class Reference

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.
QString asPolygon () const
 returns rectangle as a polygon
QString asWktCoordinates () const
 returns string representation in Wkt form
QString asWktPolygon () const
 returns string representation as WKT Polygon
QgsRectangle buffer (double width)
 Get rectangle enlarged by buffer.
QgsPoint center () const
 Center point of the rectangle.
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 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
double height () const
 Height of the rectangle.
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
void invert ()
 swap x/y
bool isEmpty () const
 test if rectangle is empty.
bool isFinite () const
 Returns true if the rectangle has finite boundaries.
bool isNull () const
 test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void normalize ()
 Normalize the rectangle so it has non-negative width/height.
bool operator!= (const QgsRectangle &r1) const
QgsRectangleoperator= (const QgsRectangle &r1)
bool operator== (const QgsRectangle &r1) const
void scale (double scaleFactor, const QgsPoint *c=0)
 Scale the rectangle around its center point.
void scale (double scaleFactor, double centerX, double centerY)
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 setMinimal ()
 Set a rectangle so that min corner is at max and max corner is at min.
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.
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
void unionRect (const QgsRectangle &rect)
 updates rectangle to include passed argument
double width () const
 Width of the rectangle.
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)

Protected Attributes

double xmax
double xmin
double ymax
double ymin

Detailed Description

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.

Constructor & Destructor Documentation

QgsRectangle::QgsRectangle ( double  xmin = 0,
double  ymin = 0,
double  xmax = 0,
double  ymax = 0 
)

Constructor.

Definition at line 32 of file qgsrectangle.cpp.

QgsRectangle::QgsRectangle ( const QgsPoint p1,
const QgsPoint p2 
)

Construct a rectangle from two points. The rectangle is normalized after construction.

Definition at line 38 of file qgsrectangle.cpp.

QgsRectangle::QgsRectangle ( const QRectF &  qRectF)

Construct a rectangle from a QRectF. The rectangle is normalized after construction.

Definition at line 43 of file qgsrectangle.cpp.

QgsRectangle::QgsRectangle ( const QgsRectangle other)

Copy constructor.

Definition at line 51 of file qgsrectangle.cpp.

QgsRectangle::~QgsRectangle ( )
inline

Destructor.

Definition at line 154 of file qgsrectangle.h.

Member Function Documentation

QString QgsRectangle::asPolygon ( ) const

returns rectangle as a polygon

Definition at line 275 of file qgsrectangle.cpp.

QString QgsRectangle::asWktCoordinates ( ) const

returns string representation in Wkt form

Definition at line 206 of file qgsrectangle.cpp.

QString QgsRectangle::asWktPolygon ( ) const

returns string representation as WKT Polygon

Definition at line 215 of file qgsrectangle.cpp.

QgsRectangle QgsRectangle::buffer ( double  width)

Get rectangle enlarged by buffer.

Note
added in 2.1

Definition at line 126 of file qgsrectangle.cpp.

QgsPoint QgsRectangle::center ( ) const
inline

Center point of the rectangle.

Definition at line 208 of file qgsrectangle.h.

void QgsRectangle::combineExtentWith ( QgsRectangle rect)

expand the rectangle so that covers both the original rectangle and the given rectangle

Definition at line 171 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 182 of file qgsrectangle.cpp.

bool QgsRectangle::contains ( const QgsRectangle rect) const

return true when rectangle contains other rectangle

Definition at line 160 of file qgsrectangle.cpp.

bool QgsRectangle::contains ( const QgsPoint p) const

return true when rectangle contains a point

Definition at line 165 of file qgsrectangle.cpp.

double QgsRectangle::height ( ) const
inline

Height of the rectangle.

Definition at line 203 of file qgsrectangle.h.

QgsRectangle QgsRectangle::intersect ( const QgsRectangle rect) const

return the intersection with the given rectangle

Definition at line 131 of file qgsrectangle.cpp.

bool QgsRectangle::intersects ( const QgsRectangle rect) const

returns true when rectangle intersects with other rectangle

Definition at line 147 of file qgsrectangle.cpp.

void QgsRectangle::invert ( )

swap x/y

Definition at line 353 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 193 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 340 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.

Note
added in 2.4

Definition at line 198 of file qgsrectangle.cpp.

void QgsRectangle::normalize ( )

Normalize the rectangle so it has non-negative width/height.

Definition at line 78 of file qgsrectangle.cpp.

bool QgsRectangle::operator!= ( const QgsRectangle r1) const

Comparison operator

Returns
False if rectangles are equal

Definition at line 308 of file qgsrectangle.cpp.

QgsRectangle & QgsRectangle::operator= ( const QgsRectangle r1)

Assignment operator

Parameters
r1QgsRectangle to assign from

Definition at line 314 of file qgsrectangle.cpp.

bool QgsRectangle::operator== ( const QgsRectangle r1) const

Comparison operator

Returns
True if rectangles are equal

Definition at line 299 of file qgsrectangle.cpp.

void QgsRectangle::scale ( double  scaleFactor,
const QgsPoint c = 0 
)

Scale the rectangle around its center point.

Definition at line 99 of file qgsrectangle.cpp.

void QgsRectangle::scale ( double  scaleFactor,
double  centerX,
double  centerY 
)

Definition at line 116 of file qgsrectangle.cpp.

void QgsRectangle::set ( const QgsPoint p1,
const QgsPoint p2 
)

Set the rectangle from two QgsPoints.

The rectangle is normalised after construction.

Definition at line 60 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 69 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 91 of file qgsrectangle.cpp.

void QgsRectangle::setXMaximum ( double  x)
inline

Set the maximum x value.

Definition at line 163 of file qgsrectangle.h.

void QgsRectangle::setXMinimum ( double  x)
inline

Set the minimum x value.

Definition at line 158 of file qgsrectangle.h.

void QgsRectangle::setYMaximum ( double  y)
inline

Set the maximum y value.

Definition at line 173 of file qgsrectangle.h.

void QgsRectangle::setYMinimum ( double  y)
inline

Set the minimum y value.

Definition at line 168 of file qgsrectangle.h.

QRectF QgsRectangle::toRectF ( ) const

returns a QRectF with same coordinates.

Definition at line 230 of file qgsrectangle.cpp.

QString QgsRectangle::toString ( bool  automaticPrecision = false) const

returns string representation of form xmin,ymin xmax,ymax

Definition at line 236 of file qgsrectangle.cpp.

QString QgsRectangle::toString ( int  thePrecision) const

overloaded toString that allows precision of numbers to be set

Definition at line 256 of file qgsrectangle.cpp.

void QgsRectangle::unionRect ( const QgsRectangle rect)

updates rectangle to include passed argument

Definition at line 328 of file qgsrectangle.cpp.

double QgsRectangle::width ( ) const
inline

Width of the rectangle.

Definition at line 198 of file qgsrectangle.h.

double QgsRectangle::xMaximum ( ) const
inline

Get the x maximum value (right side of rectangle)

Definition at line 178 of file qgsrectangle.h.

double QgsRectangle::xMinimum ( ) const
inline

Get the x minimum value (left side of rectangle)

Definition at line 183 of file qgsrectangle.h.

double QgsRectangle::yMaximum ( ) const
inline

Get the y maximum value (top side of rectangle)

Definition at line 188 of file qgsrectangle.h.

double QgsRectangle::yMinimum ( ) const
inline

Get the y minimum value (bottom side of rectangle)

Definition at line 193 of file qgsrectangle.h.

Member Data Documentation

double QgsRectangle::xmax
protected

Definition at line 148 of file qgsrectangle.h.

double QgsRectangle::xmin
protected

Definition at line 146 of file qgsrectangle.h.

double QgsRectangle::ymax
protected

Definition at line 149 of file qgsrectangle.h.

double QgsRectangle::ymin
protected

Definition at line 147 of file qgsrectangle.h.


The documentation for this class was generated from the following files: