def testQgsEllipseSymbolLayer(self): """ Create a new style from a .sld file and match test """ mTestName = 'QgsEllipseSymbolLayer' mFilePath = QDir.toNativeSeparators('%s/symbol_layer/%s.sld' % (unitTestDataPath(), mTestName)) mDoc = QDomDocument(mTestName) mFile = QFile(mFilePath) mFile.open(QIODevice.ReadOnly) mDoc.setContent(mFile, True) mFile.close() mSymbolLayer = QgsEllipseSymbolLayer.createFromSld( mDoc.elementsByTagName('PointSymbolizer').item(0).toElement()) mExpectedValue = type(QgsEllipseSymbolLayer()) mValue = type(mSymbolLayer) mMessage = 'Expected "%s" got "%s"' % (mExpectedValue, mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 'circle' mValue = mSymbolLayer.symbolName() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue, mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = '#ffff7f' mValue = mSymbolLayer.fillColor().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue, mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = '#aaaaff' mValue = mSymbolLayer.strokeColor().name() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue, mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 7 mValue = mSymbolLayer.symbolWidth() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue, mValue) assert mExpectedValue == mValue, mMessage mExpectedValue = 5 mValue = mSymbolLayer.symbolHeight() mMessage = 'Expected "%s" got "%s"' % (mExpectedValue, mValue) assert mExpectedValue == mValue, mMessage
def append_ArrowMarkerSymbolLayer(symbol, layer: ArrowMarkerSymbolLayer, context: Context): """ Appends a ArrowMarkerSymbolLayer to a symbol """ out = QgsEllipseSymbolLayer() out.setSymbolName('triangle') out.setStrokeStyle(Qt.NoPen) out.setSymbolHeight(context.convert_size(layer.size)) out.setSymbolHeightUnit(context.units) out.setSymbolWidth(context.convert_size(layer.width)) out.setSymbolWidthUnit(context.units) color = symbol_color_to_qcolor(layer.color) out.setColor(color) out.setStrokeColor( color) # why not, makes the symbol a bit easier to modify in qgis out.setOffset( adjust_offset_for_rotation( QPointF(context.convert_size(layer.x_offset), -context.convert_size(layer.y_offset)), layer.angle)) out.setOffsetUnit(context.units) angle = 90 - layer.angle if angle <= -180: angle += 360 if angle > 180: angle -= 360 out.setAngle(angle) out.setEnabled(layer.enabled) out.setLocked(layer.locked) symbol.appendSymbolLayer(out)