mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-05 00:09:32 -04:00
Add method to test if QgsMapUnitScale is null
This commit is contained in:
parent
4a0ea094fb
commit
255d4b3ce2
@ -36,6 +36,14 @@ Constructor for QgsMapUnitScale
|
||||
1000.0 for a 1:1000 map.
|
||||
%End
|
||||
|
||||
bool isNull() const;
|
||||
%Docstring
|
||||
Returns ``True`` if the scale is null, i.e. it is a default constructed
|
||||
QgsMapUnitScale.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
double minScale;
|
||||
|
||||
double maxScale;
|
||||
|
@ -36,6 +36,14 @@ Constructor for QgsMapUnitScale
|
||||
1000.0 for a 1:1000 map.
|
||||
%End
|
||||
|
||||
bool isNull() const;
|
||||
%Docstring
|
||||
Returns ``True`` if the scale is null, i.e. it is a default constructed
|
||||
QgsMapUnitScale.
|
||||
|
||||
.. versionadded:: 3.44
|
||||
%End
|
||||
|
||||
double minScale;
|
||||
|
||||
double maxScale;
|
||||
|
@ -17,6 +17,16 @@
|
||||
#include "qgsmapunitscale.h"
|
||||
#include "qgsrendercontext.h"
|
||||
|
||||
bool QgsMapUnitScale::isNull() const
|
||||
{
|
||||
return qgsDoubleNear( minScale, 0 )
|
||||
&& qgsDoubleNear( maxScale, 0 )
|
||||
&& !minSizeMMEnabled
|
||||
&& qgsDoubleNear( minSizeMM, 0 )
|
||||
&& !maxSizeMMEnabled
|
||||
&& qgsDoubleNear( maxSizeMM, 0 );
|
||||
}
|
||||
|
||||
double QgsMapUnitScale::computeMapUnitsPerPixel( const QgsRenderContext &c ) const
|
||||
{
|
||||
double mup = c.mapToPixel().mapUnitsPerPixel();
|
||||
|
@ -48,6 +48,13 @@ class CORE_EXPORT QgsMapUnitScale
|
||||
, maxScale( maxScale )
|
||||
{}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the scale is null, i.e. it is a default constructed QgsMapUnitScale.
|
||||
*
|
||||
* \since QGIS 3.44
|
||||
*/
|
||||
bool isNull() const;
|
||||
|
||||
/**
|
||||
* The minimum scale, or 0.0 if unset.
|
||||
* The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map.
|
||||
|
@ -74,6 +74,35 @@ class PyQgsMapUnitScale(unittest.TestCase):
|
||||
|
||||
self.assertEqual(c1, c2)
|
||||
|
||||
def testIsNull(self):
|
||||
# test isNull
|
||||
c1 = QgsMapUnitScale()
|
||||
self.assertTrue(c1.isNull())
|
||||
|
||||
c1 = QgsMapUnitScale()
|
||||
c1.minScale = 1000
|
||||
self.assertFalse(c1.isNull())
|
||||
|
||||
c1 = QgsMapUnitScale()
|
||||
c1.maxScale = 1000
|
||||
self.assertFalse(c1.isNull())
|
||||
|
||||
c1 = QgsMapUnitScale()
|
||||
c1.minSizeMMEnabled = True
|
||||
self.assertFalse(c1.isNull())
|
||||
|
||||
c1 = QgsMapUnitScale()
|
||||
c1.maxSizeMMEnabled = True
|
||||
self.assertFalse(c1.isNull())
|
||||
|
||||
c1 = QgsMapUnitScale()
|
||||
c1.minSizeMM = 3
|
||||
self.assertFalse(c1.isNull())
|
||||
|
||||
c1 = QgsMapUnitScale()
|
||||
c1.maxSizeMM = 3
|
||||
self.assertFalse(c1.isNull())
|
||||
|
||||
def testMapUnitsPerPixel(self):
|
||||
# test computeMapUnitsPerPixel
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user