Exemple #1
0
 def testNull(self):
     shape = QgsLegendPatchShape()
     self.assertTrue(shape.isNull())
     shape.setGeometry(QgsGeometry.fromWkt('Multipoint( 1 1, 2 2)'))
     self.assertFalse(shape.isNull())
     shape.setGeometry(QgsGeometry())
     self.assertTrue(shape.isNull())
Exemple #2
0
    def testReadWriteXml(self):
        doc = QDomDocument("testdoc")
        elem = doc.createElement('test')
        shape = QgsLegendPatchShape(QgsSymbol.Line, QgsGeometry.fromWkt('MultiLineString((5 5, 3 4, 1 2), ( 6 6, 6 0))'), False)

        shape.writeXml(elem, doc, QgsReadWriteContext())

        s2 = QgsLegendPatchShape()
        s2.readXml(elem, QgsReadWriteContext())

        self.assertFalse(s2.isNull())
        self.assertEqual(s2.geometry().asWkt(), 'MultiLineString ((5 5, 3 4, 1 2),(6 6, 6 0))')
        self.assertFalse(s2.preserveAspectRatio())
        self.assertEqual(s2.symbolType(), QgsSymbol.Line)
Exemple #3
0
    def testBasic(self):
        shape = QgsLegendPatchShape(QgsSymbol.Line, QgsGeometry.fromWkt('LineString( 0 0, 1 1)'), False)
        self.assertFalse(shape.isNull())
        self.assertEqual(shape.symbolType(), QgsSymbol.Line)
        self.assertEqual(shape.geometry().asWkt(), 'LineString (0 0, 1 1)')
        self.assertFalse(shape.preserveAspectRatio())

        shape.setSymbolType(QgsSymbol.Marker)
        self.assertEqual(shape.symbolType(), QgsSymbol.Marker)

        shape.setGeometry(QgsGeometry.fromWkt('Multipoint( 1 1, 2 2)'))
        self.assertEqual(shape.geometry().asWkt(), 'MultiPoint ((1 1),(2 2))')

        shape.setPreserveAspectRatio(True)
        self.assertTrue(shape.preserveAspectRatio())