Exemplo n.º 1
0
    def testCopyConstructor(self):
        """
        Test the copy constructor
        """
        c1 = QgsRenderContext()

        c1.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysText)
        c1.setMapExtent(QgsRectangle(1, 2, 3, 4))

        c2 = QgsRenderContext(c1)
        self.assertEqual(c2.textRenderFormat(),
                         QgsRenderContext.TextFormatAlwaysText)
        self.assertEqual(c2.mapExtent(), QgsRectangle(1, 2, 3, 4))

        c1.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysOutlines)
        c2 = QgsRenderContext(c1)
        self.assertEqual(c2.textRenderFormat(),
                         QgsRenderContext.TextFormatAlwaysOutlines)

        c1.setIsTemporal(True)
        c1.setTemporalRange(
            QgsDateTimeRange(QDateTime(2020, 1, 1, 0, 0),
                             QDateTime(2010, 12, 31, 23, 59)))
        c2 = QgsRenderContext(c1)

        self.assertEqual(c2.isTemporal(), True)
        self.assertEqual(
            c2.temporalRange(),
            QgsDateTimeRange(QDateTime(2020, 1, 1, 0, 0),
                             QDateTime(2010, 12, 31, 23, 59)))
Exemplo n.º 2
0
    def testCopyConstructor(self):
        """
        Test the copy constructor
        """
        c1 = QgsRenderContext()

        c1.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysText)
        c1.setMapExtent(QgsRectangle(1, 2, 3, 4))
        c1.setZRange(QgsDoubleRange(1, 10))
        c1.setSymbologyReferenceScale(1000)
        c1.setOutputSize(QSize(100, 200))
        c1.setImageFormat(QImage.Format_Alpha8)
        c1.setDevicePixelRatio(2)
        c1.setFrameRate(30)
        c1.setCurrentFrame(6)

        c2 = QgsRenderContext(c1)
        self.assertEqual(c2.textRenderFormat(),
                         QgsRenderContext.TextFormatAlwaysText)
        self.assertEqual(c2.mapExtent(), QgsRectangle(1, 2, 3, 4))
        self.assertEqual(c2.zRange(), QgsDoubleRange(1, 10))
        self.assertEqual(c2.symbologyReferenceScale(), 1000)
        self.assertEqual(c2.outputSize(), QSize(100, 200))
        self.assertEqual(c2.imageFormat(), QImage.Format_Alpha8)
        self.assertEqual(c2.devicePixelRatio(), 2)
        self.assertEqual(c2.deviceOutputSize(), QSize(200, 400))
        self.assertEqual(c2.frameRate(), 30)
        self.assertEqual(c2.currentFrame(), 6)

        c1.setTextRenderFormat(QgsRenderContext.TextFormatAlwaysOutlines)
        c2 = QgsRenderContext(c1)
        self.assertEqual(c2.textRenderFormat(),
                         QgsRenderContext.TextFormatAlwaysOutlines)

        c1.setIsTemporal(True)
        c1.setTemporalRange(
            QgsDateTimeRange(QDateTime(2020, 1, 1, 0, 0),
                             QDateTime(2010, 12, 31, 23, 59)))
        c2 = QgsRenderContext(c1)

        self.assertEqual(c2.isTemporal(), True)
        self.assertEqual(
            c2.temporalRange(),
            QgsDateTimeRange(QDateTime(2020, 1, 1, 0, 0),
                             QDateTime(2010, 12, 31, 23, 59)))
Exemplo n.º 3
0
 def testTemporalState(self):
     rc = QgsRenderContext()
     self.assertEqual(rc.isTemporal(), False)
     self.assertIsNotNone(rc.temporalRange())