Example #1
0
    def testBasic(self):
        item = QgsAnnotationPointTextItem('my text', QgsPointXY(12, 13))

        self.assertEqual(item.text(), 'my text')
        self.assertEqual(item.point().x(), 12.0)
        self.assertEqual(item.point().y(), 13.0)

        item.setText('tttttt')
        item.setPoint(QgsPointXY(1000, 2000))
        item.setAngle(55)
        item.setAlignment(Qt.AlignRight)
        item.setZIndex(11)

        format = QgsTextFormat()
        format.setSize(37)
        item.setFormat(format)

        self.assertEqual(item.text(), 'tttttt')
        self.assertEqual(item.point().x(), 1000.0)
        self.assertEqual(item.point().y(), 2000.0)
        self.assertEqual(item.angle(), 55.0)
        self.assertEqual(item.alignment(), Qt.AlignRight)
        self.assertEqual(item.zIndex(), 11)
        self.assertEqual(item.format().size(), 37)
Example #2
0
    def test_transform(self):
        item = QgsAnnotationPointTextItem('my text', QgsPointXY(12, 13))
        self.assertEqual(item.point().asWkt(), 'POINT(12 13)')

        self.assertEqual(item.applyEdit(QgsAnnotationItemEditOperationTranslateItem('', 100, 200)), Qgis.AnnotationItemEditOperationResult.Success)
        self.assertEqual(item.point().asWkt(), 'POINT(112 213)')
Example #3
0
    def test_apply_delete_node_edit(self):
        item = QgsAnnotationPointTextItem('my text', QgsPointXY(12, 13))
        self.assertEqual(item.point().asWkt(), 'POINT(12 13)')

        self.assertEqual(item.applyEdit(QgsAnnotationItemEditOperationDeleteNode('', QgsVertexId(0, 0, 0), QgsPoint(12, 13))), Qgis.AnnotationItemEditOperationResult.ItemCleared)
Example #4
0
    def test_transient_translate_operation(self):
        item = QgsAnnotationPointTextItem('my text', QgsPointXY(12, 13))
        self.assertEqual(item.point().asWkt(), 'POINT(12 13)')

        res = item.transientEditResults(QgsAnnotationItemEditOperationTranslateItem('', 100, 200))
        self.assertEqual(res.representativeGeometry().asWkt(), 'Point (112 213)')
Example #5
0
    def test_transient_move_operation(self):
        item = QgsAnnotationPointTextItem('my text', QgsPointXY(12, 13))
        self.assertEqual(item.point().asWkt(), 'POINT(12 13)')

        res = item.transientEditResults(QgsAnnotationItemEditOperationMoveNode('', QgsVertexId(0, 0, 0), QgsPoint(12, 13), QgsPoint(17, 18)))
        self.assertEqual(res.representativeGeometry().asWkt(), 'Point (17 18)')
Example #6
0
    def test_apply_move_node_edit(self):
        item = QgsAnnotationPointTextItem('my text', QgsPointXY(12, 13))
        self.assertEqual(item.point().asWkt(), 'POINT(12 13)')

        self.assertEqual(item.applyEdit(QgsAnnotationItemEditOperationMoveNode('', QgsVertexId(0, 0, 0), QgsPoint(14, 13), QgsPoint(17, 18))), Qgis.AnnotationItemEditOperationResult.Success)
        self.assertEqual(item.point().asWkt(), 'POINT(17 18)')