def testUsedAttributes(self): renderer = QgsPointCloudRgbRenderer() renderer.setBlueAttribute('b') renderer.setGreenAttribute('g') renderer.setRedAttribute('r') rc = QgsRenderContext() prc = QgsPointCloudRenderContext(rc, QgsVector3D(), QgsVector3D()) self.assertEqual(renderer.usedAttributes(prc), {'r', 'g', 'b'})
def testUsedAttributes(self): renderer = QgsPointCloudRgbRenderer() renderer.setBlueAttribute('b') renderer.setGreenAttribute('g') renderer.setRedAttribute('r') rc = QgsRenderContext() prc = QgsPointCloudRenderContext(rc, QgsVector3D(), QgsVector3D()) self.assertEqual(renderer.usedAttributes(prc), {'r', 'g', 'b'}) # if context is filtering by z, we also need the z attribute rc.setZRange(QgsDoubleRange(1, 10)) prc = QgsPointCloudRenderContext(rc, QgsVector3D(), QgsVector3D()) self.assertEqual(renderer.usedAttributes(prc), {'r', 'g', 'b', 'Z'})
def testBasic(self): renderer = QgsPointCloudRgbRenderer() renderer.setBlueAttribute('b') self.assertEqual(renderer.blueAttribute(), 'b') renderer.setGreenAttribute('g') self.assertEqual(renderer.greenAttribute(), 'g') renderer.setRedAttribute('r') self.assertEqual(renderer.redAttribute(), 'r') redce = QgsContrastEnhancement() redce.setMinimumValue(100) redce.setMaximumValue(120) redce.setContrastEnhancementAlgorithm( QgsContrastEnhancement.StretchAndClipToMinimumMaximum) renderer.setRedContrastEnhancement(redce) greence = QgsContrastEnhancement() greence.setMinimumValue(130) greence.setMaximumValue(150) greence.setContrastEnhancementAlgorithm( QgsContrastEnhancement.StretchToMinimumMaximum) renderer.setGreenContrastEnhancement(greence) bluece = QgsContrastEnhancement() bluece.setMinimumValue(170) bluece.setMaximumValue(190) bluece.setContrastEnhancementAlgorithm( QgsContrastEnhancement.ClipToMinimumMaximum) renderer.setBlueContrastEnhancement(bluece) renderer.setMaximumScreenError(18) renderer.setMaximumScreenErrorUnit(QgsUnitTypes.RenderInches) renderer.setPointSize(13) renderer.setPointSizeUnit(QgsUnitTypes.RenderPoints) renderer.setPointSizeMapUnitScale(QgsMapUnitScale(1000, 2000)) rr = renderer.clone() self.assertEqual(rr.maximumScreenError(), 18) self.assertEqual(rr.maximumScreenErrorUnit(), QgsUnitTypes.RenderInches) self.assertEqual(rr.pointSize(), 13) self.assertEqual(rr.pointSizeUnit(), QgsUnitTypes.RenderPoints) self.assertEqual(rr.pointSizeMapUnitScale().minScale, 1000) self.assertEqual(rr.pointSizeMapUnitScale().maxScale, 2000) self.assertEqual(rr.blueAttribute(), 'b') self.assertEqual(rr.greenAttribute(), 'g') self.assertEqual(rr.redAttribute(), 'r') self.assertEqual(rr.redContrastEnhancement().minimumValue(), 100) self.assertEqual(rr.redContrastEnhancement().maximumValue(), 120) self.assertEqual( rr.redContrastEnhancement().contrastEnhancementAlgorithm(), QgsContrastEnhancement.StretchAndClipToMinimumMaximum) self.assertEqual(rr.greenContrastEnhancement().minimumValue(), 130) self.assertEqual(rr.greenContrastEnhancement().maximumValue(), 150) self.assertEqual( rr.greenContrastEnhancement().contrastEnhancementAlgorithm(), QgsContrastEnhancement.StretchToMinimumMaximum) self.assertEqual(rr.blueContrastEnhancement().minimumValue(), 170) self.assertEqual(rr.blueContrastEnhancement().maximumValue(), 190) self.assertEqual( rr.blueContrastEnhancement().contrastEnhancementAlgorithm(), QgsContrastEnhancement.ClipToMinimumMaximum) doc = QDomDocument("testdoc") elem = renderer.save(doc, QgsReadWriteContext()) r2 = QgsPointCloudRgbRenderer.create(elem, QgsReadWriteContext()) self.assertEqual(r2.maximumScreenError(), 18) self.assertEqual(r2.maximumScreenErrorUnit(), QgsUnitTypes.RenderInches) self.assertEqual(r2.pointSize(), 13) self.assertEqual(r2.pointSizeUnit(), QgsUnitTypes.RenderPoints) self.assertEqual(r2.pointSizeMapUnitScale().minScale, 1000) self.assertEqual(r2.pointSizeMapUnitScale().maxScale, 2000) self.assertEqual(r2.blueAttribute(), 'b') self.assertEqual(r2.greenAttribute(), 'g') self.assertEqual(r2.redAttribute(), 'r') self.assertEqual(r2.redContrastEnhancement().minimumValue(), 100) self.assertEqual(r2.redContrastEnhancement().maximumValue(), 120) self.assertEqual( r2.redContrastEnhancement().contrastEnhancementAlgorithm(), QgsContrastEnhancement.StretchAndClipToMinimumMaximum) self.assertEqual(r2.greenContrastEnhancement().minimumValue(), 130) self.assertEqual(r2.greenContrastEnhancement().maximumValue(), 150) self.assertEqual( r2.greenContrastEnhancement().contrastEnhancementAlgorithm(), QgsContrastEnhancement.StretchToMinimumMaximum) self.assertEqual(r2.blueContrastEnhancement().minimumValue(), 170) self.assertEqual(r2.blueContrastEnhancement().maximumValue(), 190) self.assertEqual( r2.blueContrastEnhancement().contrastEnhancementAlgorithm(), QgsContrastEnhancement.ClipToMinimumMaximum)