def testClone(self): item = QgsAnnotationMarkerItem(QgsPoint(12, 13)) item.setSymbol(QgsMarkerSymbol.createSimple({'color': '100,200,200', 'size': '3', 'outline_color': 'black'})) item.setZIndex(11) item.setUseSymbologyReferenceScale(True) item.setSymbologyReferenceScale(5000) item2 = item.clone() self.assertEqual(item2.geometry().x(), 12.0) self.assertEqual(item2.geometry().y(), 13.0) self.assertEqual(item2.symbol()[0].color(), QColor(100, 200, 200)) self.assertEqual(item2.zIndex(), 11) self.assertTrue(item2.useSymbologyReferenceScale()) self.assertEqual(item2.symbologyReferenceScale(), 5000)
def testReadWriteXml(self): doc = QDomDocument("testdoc") elem = doc.createElement('test') item = QgsAnnotationMarkerItem(QgsPoint(12, 13)) item.setSymbol(QgsMarkerSymbol.createSimple({'color': '100,200,200', 'size': '3', 'outline_color': 'black'})) item.setZIndex(11) item.setUseSymbologyReferenceScale(True) item.setSymbologyReferenceScale(5000) self.assertTrue(item.writeXml(elem, doc, QgsReadWriteContext())) s2 = QgsAnnotationMarkerItem.create() self.assertTrue(s2.readXml(elem, QgsReadWriteContext())) self.assertEqual(s2.geometry().x(), 12.0) self.assertEqual(s2.geometry().y(), 13.0) self.assertEqual(s2.symbol()[0].color(), QColor(100, 200, 200)) self.assertEqual(s2.zIndex(), 11) self.assertTrue(s2.useSymbologyReferenceScale()) self.assertEqual(s2.symbologyReferenceScale(), 5000)