def subRenderer(self, color):
        lineSymbol = QgsLineSymbolV2()
        arrowSymbol = QgsArrowSymbolLayer().create()
        arrowSymbol.setArrowWidth(0.0)
        arrowSymbol.setArrowStartWidth(0.0)
        arrowSymbol.setColor(color)
        arrowSymbol.setIsCurved(False)
        arrowSymbol.setIsRepeated(False)
        renderSetting = QgsRenderContext()
        renderSetting.setFlag(QgsRenderContext.Antialiasing, False)
        renderSetting.setFlag(QgsRenderContext.DrawSymbolBounds, False)
        renderSetting.setFlag(QgsRenderContext.ForceVectorOutput, False)
        renderSetting.setFlag(QgsRenderContext.UseAdvancedEffects, False)
        renderSetting.setFlag(QgsRenderContext.UseRenderingOptimization, False)

        arrEffectStack = arrowSymbol.paintEffect()
        effList = arrEffectStack.effectList()
        for i in range(0, len(effList)):
            if type(effList[i]) == QgsDrawSourceEffect:
                effList[i].setDrawMode(1)
        arrEffectStack.setEnabled(True)

        lineSymbol.appendSymbolLayer(arrowSymbol)

        return lineSymbol
Exemple #2
0
    def testSetPainterFlags(self):
        rc = QgsRenderContext()
        p = QPainter()
        im = QImage(1000, 600, QImage.Format_RGB32)
        p.begin(im)
        rc.setPainterFlagsUsingContext(p)
        self.assertFalse(p.testRenderHint(QPainter.Antialiasing))
        try:
            self.assertFalse(p.testRenderHint(QPainter.LosslessImageRendering))
        except AttributeError:
            pass

        rc.setPainter(p)
        rc.setFlag(QgsRenderContext.Antialiasing, True)
        rc.setFlag(QgsRenderContext.LosslessImageRendering, True)
        rc.setPainterFlagsUsingContext(p)
        self.assertTrue(p.testRenderHint(QPainter.Antialiasing))
        try:
            self.assertTrue(p.testRenderHint(QPainter.LosslessImageRendering))
        except AttributeError:
            pass

        p.end()