From fde5e77bb03f617bbd2e19146da69927c0b8f57c Mon Sep 17 00:00:00 2001 From: wonder Date: Thu, 15 Jan 2009 18:02:58 +0000 Subject: [PATCH] Added QgsRectangle::contains predicate. git-svn-id: http://svn.osgeo.org/qgis/trunk@9973 c8812cc2-4d05-0410-92ff-de0c093fc19c --- python/core/qgsrect.sip | 3 +++ src/core/qgsrectangle.cpp | 5 +++++ src/core/qgsrectangle.h | 3 +++ 3 files changed, 11 insertions(+) diff --git a/python/core/qgsrect.sip b/python/core/qgsrect.sip index 66c6065e2fc..b57add911c0 100644 --- a/python/core/qgsrect.sip +++ b/python/core/qgsrect.sip @@ -61,6 +61,9 @@ class QgsRectangle QgsRectangle intersect(QgsRectangle *rect); //! returns true when rectangle intersects with other rectangle bool intersects(const QgsRectangle& rect) const; + //! return true when rectangle contains other rectangle + //! @note added in version 1.1 + bool contains( const QgsRectangle& rect ) const; //! expand the rectangle so that covers both the original rectangle and the given rectangle void combineExtentWith(QgsRectangle *rect); //! expand the rectangle so that covers both the original rectangle and the given point diff --git a/src/core/qgsrectangle.cpp b/src/core/qgsrectangle.cpp index bebe83bbe55..9816d292d44 100644 --- a/src/core/qgsrectangle.cpp +++ b/src/core/qgsrectangle.cpp @@ -156,6 +156,11 @@ bool QgsRectangle::intersects( const QgsRectangle& rect ) const return TRUE; } +bool QgsRectangle::contains( const QgsRectangle& rect ) const +{ + return (rect.xmin >= xmin && rect.xmax <= xmax && rect.ymin >= ymin && rect.ymax <= ymax); +} + void QgsRectangle::combineExtentWith( QgsRectangle * rect ) { diff --git a/src/core/qgsrectangle.h b/src/core/qgsrectangle.h index 97c5b8c5b1f..0f9a03a38cd 100644 --- a/src/core/qgsrectangle.h +++ b/src/core/qgsrectangle.h @@ -84,6 +84,9 @@ class CORE_EXPORT QgsRectangle QgsRectangle intersect( QgsRectangle *rect ) const; //! returns true when rectangle intersects with other rectangle bool intersects( const QgsRectangle& rect ) const; + //! return true when rectangle contains other rectangle + //! @note added in version 1.1 + bool contains( const QgsRectangle& rect ) const; //! expand the rectangle so that covers both the original rectangle and the given rectangle void combineExtentWith( QgsRectangle *rect ); //! expand the rectangle so that covers both the original rectangle and the given point