diff --git a/src/qgsrect.cpp b/src/qgsrect.cpp index 4a06bbbfb1b..002b924c05b 100644 --- a/src/qgsrect.cpp +++ b/src/qgsrect.cpp @@ -34,11 +34,7 @@ QgsRect::QgsRect(double newxmin, double newymin, double newxmax, double newymax) QgsRect::QgsRect(QgsPoint const & p1, QgsPoint const & p2) { - xmin = p1.x(); - xmax = p2.x(); - ymin = p1.y(); - ymax = p2.y(); - normalize(); + set(p1, p2); } QgsRect::QgsRect(const QgsRect &r) @@ -49,6 +45,15 @@ QgsRect::QgsRect(const QgsRect &r) ymax = r.yMax(); } +void QgsRect::set(const QgsPoint& p1, const QgsPoint& p2) +{ + xmin = p1.x(); + xmax = p2.x(); + ymin = p1.y(); + ymax = p2.y(); + normalize(); +} + void QgsRect::normalize() { double temp; diff --git a/src/qgsrect.h b/src/qgsrect.h index ee713e78aba..f1e2c8b8412 100644 --- a/src/qgsrect.h +++ b/src/qgsrect.h @@ -45,6 +45,9 @@ class QgsRect QgsRect(const QgsRect &other); //! Destructor ~QgsRect(); + //! Set the rectangle from two QgsPoints. The rectangle is + //normalised after construction. + void set(const QgsPoint& p1, const QgsPoint& p2); //! Set the minimum x value void setXmin(double x); //! Set the maximum x value