Skip to content

Commit abdd875

Browse files
Gustrynyalldawson
authored andcommitted
add constructor to QgsBox3d with a QgsRectangle
1 parent d0475cb commit abdd875

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

python/core/geometry/qgsbox3d.sip

+6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ class QgsBox3d
3737
The box is normalized after construction.
3838
%End
3939

40+
QgsBox3d( const QgsRectangle &rect );
41+
%Docstring
42+
Constructs a QgsBox3D from a rectangle.
43+
Z Minimum and Z Maximum are set to 0.0.
44+
%End
45+
4046
void setXMinimum( double x );
4147
%Docstring
4248
Sets the minimum ``x`` value.

src/core/geometry/qgsbox3d.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ QgsBox3d::QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 )
3232
mBounds2d.normalize();
3333
}
3434

35+
QgsBox3d::QgsBox3d( const QgsRectangle &rect )
36+
: mBounds2d( rect )
37+
{}
38+
3539
void QgsBox3d::setXMinimum( double x )
3640
{
3741
mBounds2d.setXMinimum( x );

src/core/geometry/qgsbox3d.h

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ class CORE_EXPORT QgsBox3d
4747
*/
4848
QgsBox3d( const QgsPoint &p1, const QgsPoint &p2 );
4949

50+
/**
51+
* Constructs a QgsBox3D from a rectangle.
52+
* Z Minimum and Z Maximum are set to 0.0.
53+
*/
54+
QgsBox3d( const QgsRectangle &rect );
55+
5056
/**
5157
* Sets the minimum \a x value.
5258
* \see xMinimum()

tests/src/python/test_qgsbox3d.py

+8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ def testCtor(self):
5252
self.assertEqual(box.yMaximum(), 11.0)
5353
self.assertEqual(box.zMaximum(), 12.0)
5454

55+
box = QgsBox3d(QgsRectangle(5, 6, 11, 13))
56+
self.assertEqual(box.xMinimum(), 5.0)
57+
self.assertEqual(box.yMinimum(), 6.0)
58+
self.assertEqual(box.zMinimum(), 0.0)
59+
self.assertEqual(box.xMaximum(), 11.0)
60+
self.assertEqual(box.yMaximum(), 13.0)
61+
self.assertEqual(box.zMaximum(), 0.0)
62+
5563
def testSetters(self):
5664
box = QgsBox3d(5.0, 6.0, 7.0, 10.0, 11.0, 12.0)
5765

0 commit comments

Comments
 (0)