Skip to content

Commit

Permalink
add constructor to QgsBox3d with a QgsRectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry authored and nyalldawson committed Dec 15, 2017
1 parent d0475cb commit abdd875
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/core/geometry/qgsbox3d.sip
Expand Up @@ -37,6 +37,12 @@ class QgsBox3d
The box is normalized after construction.
%End

QgsBox3d( const QgsRectangle &rect );
%Docstring
Constructs a QgsBox3D from a rectangle.
Z Minimum and Z Maximum are set to 0.0.
%End

void setXMinimum( double x );
%Docstring
Sets the minimum ``x`` value.
Expand Down
4 changes: 4 additions & 0 deletions src/core/geometry/qgsbox3d.cpp
Expand Up @@ -32,6 +32,10 @@ QgsBox3d::QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 )
mBounds2d.normalize();
}

QgsBox3d::QgsBox3d( const QgsRectangle &rect )
: mBounds2d( rect )
{}

void QgsBox3d::setXMinimum( double x )
{
mBounds2d.setXMinimum( x );
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgsbox3d.h
Expand Up @@ -47,6 +47,12 @@ class CORE_EXPORT QgsBox3d
*/
QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 );

/**
* Constructs a QgsBox3D from a rectangle.
* Z Minimum and Z Maximum are set to 0.0.
*/
QgsBox3d( const QgsRectangle &rect );

/**
* Sets the minimum \a x value.
* \see xMinimum()
Expand Down
8 changes: 8 additions & 0 deletions tests/src/python/test_qgsbox3d.py
Expand Up @@ -52,6 +52,14 @@ def testCtor(self):
self.assertEqual(box.yMaximum(), 11.0)
self.assertEqual(box.zMaximum(), 12.0)

box = QgsBox3d(QgsRectangle(5, 6, 11, 13))
self.assertEqual(box.xMinimum(), 5.0)
self.assertEqual(box.yMinimum(), 6.0)
self.assertEqual(box.zMinimum(), 0.0)
self.assertEqual(box.xMaximum(), 11.0)
self.assertEqual(box.yMaximum(), 13.0)
self.assertEqual(box.zMaximum(), 0.0)

def testSetters(self):
box = QgsBox3d(5.0, 6.0, 7.0, 10.0, 11.0, 12.0)

Expand Down

0 comments on commit abdd875

Please sign in to comment.