Esempio 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.setFrameSizeMm(QSizeF(400 / 3.7795275, 250 / 3.7795275))
     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))
Esempio n. 2
0
 def testRelativePosition(self):
     """ test rendering an annotation without map point"""
     a = QgsHtmlAnnotation()
     a.fillSymbol().symbolLayer(0).setStrokeColor(QColor(0, 0, 0))
     a.setFrameSizeMm(QSizeF(400 / 3.7795275, 250 / 3.7795275))
     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))
Esempio n. 3
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))
Esempio n. 4
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))
Esempio n. 5
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))
Esempio 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))
Esempio n. 7
0
 def testHtmlAnnotationSetHtmlSource(self):
     """ test rendering html annotation where the html is set directly (not from file)"""
     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))
     htmlFile = open(TEST_DATA_DIR + "/test_html.html")
     htmlText = htmlFile.read()
     a.setHtmlSource(htmlText)
     im = self.renderAnnotation(a, QPointF(20, 30))
     self.assertTrue(
         self.imageCheck('html_annotation_html_source', 'html_annotation',
                         im))
Esempio n. 8
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))
Esempio n. 9
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))
Esempio n. 10
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))
Esempio n. 11
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))