def testLineFillDefault(self): symbol = QgsLinePatternFillSymbolLayer() symbol.setLineAngle(45) symbol.setLineWidth(1) symbol.setOffset(5) dom, root = self.symbolToSld(symbol) # print ("Line fill mm: \n" + dom.toString()) self.assertStaticRotation(root, '45') self.assertStrokeWidth(root, 1, 4) self.assertStaticSize(root, '18') self.assertStaticDisplacement(root, 15, 9)
def testLineFillPixels(self): symbol = QgsLinePatternFillSymbolLayer() symbol.setLineAngle(45) symbol.setLineWidth(1) symbol.setOffset(5) symbol.setOutputUnit(QgsUnitTypes.RenderPixels) dom, root = self.symbolToSld(symbol) # print ("Line fill px: \n" + dom.toString()) self.assertStaticRotation(root, '45') self.assertStrokeWidth(root, 1, 1) self.assertStaticSize(root, '5') self.assertStaticDisplacement(root, 4.25, 2.63)
def append_LineFillSymbolLayer(symbol, layer: LineFillSymbolLayer): """ Appends a LineFillSymbolLayer to a symbol """ line = Symbol_to_QgsSymbol(layer.line) out = QgsLinePatternFillSymbolLayer() out.setSubSymbol(line) out.setLineAngle(convert_angle(layer.angle)) out.setDistance(layer.separation) out.setDistanceUnit(QgsUnitTypes.RenderPoints) out.setOffset(layer.offset) out.setOffsetUnit(QgsUnitTypes.RenderPoints) symbol.appendSymbolLayer(out) if layer.outline_layer: append_SymbolLayer_to_QgsSymbolLayer(symbol, layer.outline_layer) elif layer.outline_symbol: # get all layers from outline append_SymbolLayer_to_QgsSymbolLayer(symbol, layer.outline_symbol)
def append_LineFillSymbolLayer(symbol, layer: LineFillSymbolLayer, context: Context): """ Appends a LineFillSymbolLayer to a symbol """ line = Symbol_to_QgsSymbol(layer.line, context) out = QgsLinePatternFillSymbolLayer() out.setSubSymbol(line) out.setLineAngle(layer.angle) out.setDistance(context.convert_size(layer.separation)) out.setDistanceUnit(context.units) out.setOffset(context.convert_size(layer.offset)) out.setOffsetUnit(context.units) symbol.appendSymbolLayer(out) if layer.outline_layer: append_SymbolLayer_to_QgsSymbolLayer(symbol, layer.outline_layer, context) elif layer.outline_symbol: # get all layers from outline append_SymbolLayer_to_QgsSymbolLayer(symbol, layer.outline_symbol, context)