Example #1
0
    def renderAnnotationInLayout(self, test_name, annotation):
        pr = QgsProject()
        l = QgsLayout(pr)
        l.initializeDefaults()
        map = QgsLayoutItemMap(l)
        map.attemptSetSceneRect(QRectF(20, 20, 200, 100))
        map.setFrameEnabled(True)
        rectangle = QgsRectangle(0, 0, 18, 8)
        map.setExtent(rectangle)
        l.addLayoutItem(map)

        annotation.setMapPosition(QgsPointXY(1, 7))
        annotation.setHasFixedMapPosition(True)
        pr.annotationManager().addAnnotation(annotation)

        checker = QgsLayoutChecker(test_name, l)
        checker.dots_per_meter = 2 * 96 / 25.4 * 1000
        checker.size = QSize(1122 * 2, 794 * 2)
        checker.setControlPathPrefix("annotations")
        result, message = checker.testLayout()
        self.report += checker.report()
        return result
Example #2
0
    def renderAnnotationInLayout(self, test_name, annotation):
        pr = QgsProject()
        l = QgsLayout(pr)
        l.initializeDefaults()
        map = QgsLayoutItemMap(l)
        map.attemptSetSceneRect(QRectF(20, 20, 200, 100))
        map.setFrameEnabled(True)
        rectangle = QgsRectangle(0, 0, 18, 8)
        map.setExtent(rectangle)
        l.addLayoutItem(map)

        annotation.setMapPosition(QgsPointXY(1, 7))
        annotation.setHasFixedMapPosition(True)
        pr.annotationManager().addAnnotation(annotation)

        checker = QgsLayoutChecker(
            test_name, l)
        checker.dots_per_meter = 2 * 96 / 25.4 * 1000
        checker.size = QSize(1122 * 2, 794 * 2)
        checker.setControlPathPrefix("annotations")
        result, message = checker.testLayout()
        self.report += checker.report()
        return result