Skip to content
Permalink
Browse files

Update SIP file for QgsRectangle

  • Loading branch information
Zverik authored and 3nids committed Jun 26, 2017
1 parent 7941759 commit 80bc6d2674526d76fe0e7d462d581552272ec829
Showing with 38 additions and 1 deletion.
  1. +28 −0 python/core/geometry/qgsrectangle.sip
  2. +10 −1 tests/src/python/test_qgsrectangle.py
@@ -210,6 +210,34 @@ Copy constructor
Expand the rectangle so that covers both the original rectangle and the given point.
%End

QgsRectangle operator-( const QgsVector v ) const;
%Docstring
Returns a rectangle offset from this one in the direction of the reversed vector.
.. versionadded:: 3.0
:rtype: QgsRectangle
%End

QgsRectangle operator+( const QgsVector v ) const;
%Docstring
Returns a rectangle offset from this one in the direction of the vector.
.. versionadded:: 3.0
:rtype: QgsRectangle
%End

QgsRectangle &operator-=( const QgsVector v );
%Docstring
Moves this rectangle in the direction of the reversed vector.
.. versionadded:: 3.0
:rtype: QgsRectangle
%End

QgsRectangle &operator+=( const QgsVector v );
%Docstring
Moves this rectangle in the direction of the vector.
.. versionadded:: 3.0
:rtype: QgsRectangle
%End

bool isEmpty() const;
%Docstring
Returns true if the rectangle is empty.
@@ -14,7 +14,7 @@

import qgis # NOQA

from qgis.core import QgsRectangle, QgsPointXY
from qgis.core import QgsRectangle, QgsPointXY, QgsVector

from qgis.testing import start_app, unittest
from utilities import compareWkt
@@ -252,6 +252,15 @@ def testToBox3d(self):
self.assertEqual(box.yMaximum(), 0.3)
self.assertEqual(box.zMaximum(), 0.5)

def testOperators(self):
rect1 = QgsRectangle(10, 20, 40, 40)
rect2 = rect1 + QgsVector(3, 5.5)
assert rect2 == QgsRectangle(13, 25.5, 43, 45.5), "QgsRectangle + operator does no work"

# Subtracting the center point, so it becomes zero.
rect1 -= rect1.center() - QgsPointXY(0, 0)
assert rect1.center() == QgsPointXY(0, 0)


if __name__ == '__main__':
unittest.main()

0 comments on commit 80bc6d2

Please sign in to comment.
You can’t perform that action at this time.