23 #include <QTextStream> 33 : xmin( newxmin ), ymin( newymin ), xmax( newxmax ), ymax( newymax )
45 xmin = qRectF.topLeft().x();
46 ymin = qRectF.topLeft().y();
47 xmax = qRectF.bottomRight().x();
48 ymax = qRectF.bottomRight().y();
105 double centerX, centerY;
116 scale( scaleFactor, centerX, centerY );
121 double newWidth =
width() * scaleFactor;
122 double newHeight =
height() * scaleFactor;
123 xmin = centerX - newWidth / 2.0;
124 xmax = centerX + newWidth / 2.0;
125 ymin = centerY - newHeight / 2.0;
126 ymax = centerY + newHeight / 2.0;
221 QString(
"POLYGON((" ) +
235 return QRectF(( qreal )
xmin, ( qreal )
ymin, ( qreal )
xmax - xmin, ( qreal )
ymax - ymin );
241 if ( automaticPrecision )
246 precision =
static_cast<int>( ceil( -1.0 * log10( qMin(
width(),
height() ) ) ) ) + 1;
248 if ( precision > 20 )
265 rep = QString(
"%1,%2 : %3,%4" )
266 .arg(
xmin, 0,
'f', thePrecision )
267 .arg(
ymin, 0,
'f', thePrecision )
268 .arg(
xmax, 0,
'f', thePrecision )
269 .arg(
ymax, 0,
'f', thePrecision );
284 QTextStream foo( &rep );
286 foo.setRealNumberPrecision( 8 );
287 foo.setRealNumberNotation( QTextStream::FixedNotation );
313 return ( !
operator==( r1 ) );
void unionRect(const QgsRectangle &rect)
updates rectangle to include passed argument
QgsRectangle & operator=(const QgsRectangle &r1)
bool intersects(const QgsRectangle &rect) const
returns true when rectangle intersects with other rectangle
A rectangle specified with double values.
bool isEmpty() const
test if rectangle is empty.
QRectF toRectF() const
returns a QRectF with same coordinates.
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.
QgsRectangle buffer(double width)
Get rectangle enlarged by buffer.
bool isFinite() const
Returns true if the rectangle has finite boundaries.
double yMaximum() const
Get the y maximum value (top side of rectangle)
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
bool isNull() const
test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void set(const QgsPoint &p1, const QgsPoint &p2)
Set the rectangle from two QgsPoints.
void combineExtentWith(QgsRectangle *rect)
expand the rectangle so that covers both the original rectangle and the given rectangle ...
QgsRectangle(double xmin=0, double ymin=0, double xmax=0, double ymax=0)
Constructor.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
double xMaximum() const
Get the x maximum value (right side of rectangle)
#define QgsDebugMsgLevel(str, level)
void setYMinimum(double y)
Set the minimum y value.
QString asWktCoordinates() const
returns string representation in Wkt form
A class to represent a point.
bool operator!=(const QgsRectangle &r1) const
QString qgsDoubleToString(const double &a, const int &precision=17)
QString asWktPolygon() const
returns string representation as WKT Polygon
QString asPolygon() const
returns rectangle as a polygon
void setYMaximum(double y)
Set the maximum y value.
QgsRectangle intersect(const QgsRectangle *rect) const
return the intersection with the given rectangle
void normalize()
Normalize the rectangle so it has non-negative width/height.
double width() const
Width of the rectangle.
QString toString(bool automaticPrecision=false) const
returns string representation of form xmin,ymin xmax,ymax
double xMinimum() const
Get the x minimum value (left side of rectangle)
void setXMinimum(double x)
Set the minimum x value.
double height() const
Height of the rectangle.
bool operator==(const QgsRectangle &r1) const
void scale(double scaleFactor, const QgsPoint *c=0)
Scale the rectangle around its center point.