Ejemplo n.º 1
0
    def testGettersSetters(self):
        """
        Basic getter/setter tests
        """
        c = QgsRenderContext()

        c.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysText)
        self.assertEqual(c.textRenderFormat(),
                         QgsRenderContext.TextFormatAlwaysText)
        c.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysOutlines)
        self.assertEqual(c.textRenderFormat(),
                         QgsRenderContext.TextFormatAlwaysOutlines)

        c.setMapExtent(QgsRectangle(1, 2, 3, 4))
        self.assertEqual(c.mapExtent(), QgsRectangle(1, 2, 3, 4))

        self.assertTrue(c.zRange().isInfinite())
        c.setZRange(QgsDoubleRange(1, 10))
        self.assertEqual(c.zRange(), QgsDoubleRange(1, 10))

        self.assertEqual(c.symbologyReferenceScale(), -1)
        c.setSymbologyReferenceScale(1000)
        self.assertEqual(c.symbologyReferenceScale(), 1000)

        self.assertTrue(c.outputSize().isEmpty())
        c.setOutputSize(QSize(100, 200))
        self.assertEqual(c.outputSize(), QSize(100, 200))

        self.assertEqual(c.devicePixelRatio(), 1)
        c.setDevicePixelRatio(2)
        self.assertEqual(c.devicePixelRatio(), 2)
        self.assertEqual(c.deviceOutputSize(), QSize(200, 400))

        c.setImageFormat(QImage.Format_Alpha8)
        self.assertEqual(c.imageFormat(), QImage.Format_Alpha8)

        # should have an invalid mapToPixel by default
        self.assertFalse(c.mapToPixel().isValid())

        self.assertEqual(c.frameRate(), -1)
        c.setFrameRate(30)
        self.assertEqual(c.frameRate(), 30)

        self.assertEqual(c.currentFrame(), -1)
        c.setCurrentFrame(6)
        self.assertEqual(c.currentFrame(), 6)
Ejemplo n.º 2
0
    def testGettersSetters(self):
        """
        Basic getter/setter tests
        """
        c = QgsRenderContext()

        c.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysText)
        self.assertEqual(c.textRenderFormat(), QgsRenderContext.TextFormatAlwaysText)
        c.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysOutlines)
        self.assertEqual(c.textRenderFormat(), QgsRenderContext.TextFormatAlwaysOutlines)

        c.setMapExtent(QgsRectangle(1, 2, 3, 4))
        self.assertEqual(c.mapExtent(), QgsRectangle(1, 2, 3, 4))

        self.assertTrue(c.zRange().isInfinite())
        c.setZRange(QgsDoubleRange(1, 10))
        self.assertEqual(c.zRange(), QgsDoubleRange(1, 10))

        self.assertEqual(c.symbologyReferenceScale(), -1)
        c.setSymbologyReferenceScale(1000)
        self.assertEqual(c.symbologyReferenceScale(), 1000)

        # should have an invalid mapToPixel by default
        self.assertFalse(c.mapToPixel().isValid())