Ejemplo n.º 1
0
 def testRelativePosition(self):
     """ test rendering an annotation without map point"""
     a = QgsHtmlAnnotation()
     a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.setFrameSize(QSizeF(400, 250))
     a.setHasFixedMapPosition(False)
     html = TEST_DATA_DIR + "/test_html.html"
     a.setSourceFile(html)
     im = self.renderAnnotation(a, QPointF(20, 30))
     self.assertTrue(self.imageCheck('relative_style', 'relative_style', im))
Ejemplo n.º 2
0
 def testMargins(self):
     """ test rendering an annotation with margins"""
     a = QgsHtmlAnnotation()
     a.setFrameSize(QSizeF(400, 250))
     a.setHasFixedMapPosition(False)
     a.setContentsMargin(QgsMargins(15, 10, 30, 20))
     html = TEST_DATA_DIR + "/test_html.html"
     a.setSourceFile(html)
     im = self.renderAnnotation(a, QPointF(20, 30))
     self.assertTrue(self.imageCheck('annotation_margins', 'annotation_margins', im))
Ejemplo n.º 3
0
 def testHtmlAnnotation(self):
     """ test rendering a html annotation"""
     a = QgsHtmlAnnotation()
     a.setFrameSize(QSizeF(400, 250))
     a.setFrameOffsetFromReferencePoint(QPointF(70, 90))
     html = TEST_DATA_DIR + "/test_html.html"
     a.setSourceFile(html)
     im = self.renderAnnotation(a, QPointF(20, 30))
     self.assertTrue(self.imageCheck('html_annotation', 'html_annotation', im))
Ejemplo n.º 4
0
    def testHtmlAnnotation(self):
        """ test rendering a html annotation"""
        a = QgsHtmlAnnotation()
        a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.markerSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.setFrameSize(QSizeF(400, 250))
        a.setFrameOffsetFromReferencePoint(QPointF(70, 90))
        html = TEST_DATA_DIR + "/test_html.html"
        a.setSourceFile(html)
        im = self.renderAnnotation(a, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_annotation', 'html_annotation', im))

        # check clone
        clone = a.clone()
        im = self.renderAnnotation(a, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_annotation', 'html_annotation', im))
Ejemplo n.º 5
0
    def testHtmlAnnotationWithFeature(self):
        """ test rendering a html annotation with a feature"""
        layer = QgsVectorLayer("Point?crs=EPSG:3111&field=station:string&field=suburb:string",
                               'test', "memory")

        a = QgsHtmlAnnotation()
        a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.markerSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.setFrameSize(QSizeF(400, 250))
        a.setFrameOffsetFromReferencePoint(QPointF(70, 90))
        a.setMapLayer(layer)
        html = TEST_DATA_DIR + "/test_html_feature.html"
        a.setSourceFile(html)
        im = self.renderAnnotation(a, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_nofeature', 'html_nofeature', im))
        f = QgsFeature(layer.fields())
        f.setValid(True)
        f.setAttributes(['hurstbridge', 'somewhere'])
        a.setAssociatedFeature(f)
        im = self.renderAnnotation(a, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_feature', 'html_feature', im))
Ejemplo n.º 6
0
 def testMargins(self):
     """ test rendering an annotation with margins"""
     a = QgsHtmlAnnotation()
     a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.setFrameSizeMm(QSizeF(400 / 3.7795275, 250 / 3.7795275))
     a.setHasFixedMapPosition(False)
     a.setContentsMargin(QgsMargins(15, 10, 30, 20))
     html = TEST_DATA_DIR + "/test_html.html"
     a.setSourceFile(html)
     im = self.renderAnnotation(a, QPointF(20, 30))
     self.assertTrue(self.imageCheck('annotation_margins', 'annotation_margins', im))
Ejemplo n.º 7
0
 def testHtmlAnnotationInLayout(self):
     """ test rendering a svg annotation"""
     a = QgsHtmlAnnotation()
     a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.markerSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.setFrameSizeMm(QSizeF(400 / 3.7795275, 200 / 3.7795275))
     a.setFrameOffsetFromReferencePointMm(QPointF(70 / 3.7795275, 90 / 3.7795275))
     html = TEST_DATA_DIR + "/test_html.html"
     a.setSourceFile(html)
     self.assertTrue(self.renderAnnotationInLayout('html_annotation_in_layout', a))
Ejemplo n.º 8
0
 def testMargins(self):
     """ test rendering an annotation with margins"""
     a = QgsHtmlAnnotation()
     a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.setFrameSizeMm(QSizeF(400 / 3.7795275, 250 / 3.7795275))
     a.setHasFixedMapPosition(False)
     a.setContentsMargin(QgsMargins(15, 10, 30, 20))
     html = TEST_DATA_DIR + "/test_html.html"
     a.setSourceFile(html)
     im = self.renderAnnotation(a, QPointF(20, 30))
     self.assertTrue(self.imageCheck('annotation_margins', 'annotation_margins', im))
Ejemplo n.º 9
0
    def testHtmlAnnotationWithFeature(self):
        """ test rendering a html annotation with a feature"""
        layer = QgsVectorLayer("Point?crs=EPSG:3111&field=station:string&field=suburb:string",
                               'test', "memory")

        a = QgsHtmlAnnotation()
        a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.markerSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.setFrameSizeMm(QSizeF(400 / 3.7795275, 250 / 3.7795275))
        a.setFrameOffsetFromReferencePointMm(QPointF(70 / 3.7795275, 90 / 3.7795275))
        a.setMapLayer(layer)
        html = TEST_DATA_DIR + "/test_html_feature.html"
        a.setSourceFile(html)
        im = self.renderAnnotation(a, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_nofeature', 'html_nofeature', im))
        f = QgsFeature(layer.fields())
        f.setValid(True)
        f.setAttributes(['hurstbridge', 'somewhere'])
        a.setAssociatedFeature(f)
        im = self.renderAnnotation(a, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_feature', 'html_feature', im))
Ejemplo n.º 10
0
 def testHtmlAnnotationInLayout(self):
     """ test rendering a svg annotation"""
     a = QgsHtmlAnnotation()
     a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.markerSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.setFrameSizeMm(QSizeF(400 / 3.7795275, 200 / 3.7795275))
     a.setFrameOffsetFromReferencePointMm(QPointF(70 / 3.7795275, 90 / 3.7795275))
     html = TEST_DATA_DIR + "/test_html.html"
     a.setSourceFile(html)
     self.assertTrue(self.renderAnnotationInLayout('html_annotation_in_layout', a))
Ejemplo n.º 11
0
    def testHtmlAnnotation(self):
        """ test rendering a html annotation"""
        a = QgsHtmlAnnotation()
        a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.markerSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
        a.setFrameSizeMm(QSizeF(400 / 3.7795275, 250 / 3.7795275))
        a.setFrameOffsetFromReferencePointMm(QPointF(70 / 3.7795275, 90 / 3.7795275))
        html = TEST_DATA_DIR + "/test_html.html"
        a.setSourceFile(html)
        im = self.renderAnnotation(a, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_annotation', 'html_annotation', im))

        # check clone
        clone = a.clone()
        im = self.renderAnnotation(clone, QPointF(20, 30))
        self.assertTrue(self.imageCheck('html_annotation', 'html_annotation', im))