Class: QgsSymbolLayerUtils

class qgis.core.QgsSymbolLayerUtils

Bases: sip.wrapper

QgsSymbolLayerUtils(QgsSymbolLayerUtils)

Enums

Methods

applyScaleDependency

Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into the SE Rule element

blurImageInPlace

Blurs an image in place, e.g.

clearSymbolMap

colorFromMimeData

Attempts to parse mime data as a color

colorListFromMimeData

Attempts to parse mime data as a list of named colors

colorListToMimeData

Creates mime data from a list of named colors

colorRampPreviewIcon

Returns an icon preview for a color ramp.

colorRampPreviewPixmap

Returns a pixmap preview for a color ramp.

colorRampToVariant

Saves a color ramp to a QVariantMap, wrapped in a QVariant.

colorToMimeData

Creates mime data from a color.

colorToName

Returns a friendly display name for a color

convertPolygonSymbolizerToPointMarker

createAnchorPointElement

Creates a SE 1.1 anchor point element as a child of the specified element

createDisplacementElement

createExpressionElement

Creates a OGC Expression element based on the provided function expression

createFillLayerFromSld

createFunctionElement

createGeometryElement

createLineLayerFromSld

createMarkerLayerFromSld

createOnlineResourceElement

createOpacityElement

createRotationElement

createSvgParameterElement

createSymbolLayerListFromSld

createVendorOptionElement

decodeArrowHeadType

Decodes a value representing an arrow head type.

decodeArrowType

Decodes a value representing an arrow type.

decodeBlendMode

decodeBrushStyle

decodeColor

decodeMapUnitScale

decodePenCapStyle

decodePenJoinStyle

decodePenStyle

decodePoint

Decodes a QSizeF from a string.

decodeRealVector

decodeScaleMethod

decodeSize

Decodes a QSizeF from a string.

decodeSldAlpha

decodeSldBrushStyle

decodeSldFontStyle

decodeSldFontWeight

decodeSldLineCapStyle

decodeSldLineJoinStyle

decodeSldRealVector

decodeSldUom

Decodes a SLD unit of measure string to a render unit.

displacementFromSldElement

drawStippledBackground

drawVertexMarker

Draws a vertex symbol at (painter) coordinates x, y.

encodeBrushStyle

encodeColor

encodeMapUnitScale

encodePenCapStyle

encodePenJoinStyle

encodePenStyle

encodePoint

Encodes a QPointF to a string.

encodeRealVector

encodeScaleMethod

encodeSize

Encodes a QSizeF to a string.

encodeSldAlpha

encodeSldBrushStyle

encodeSldFontStyle

encodeSldFontWeight

encodeSldLineCapStyle

encodeSldLineJoinStyle

encodeSldRealVector

encodeSldUom

Encodes a render unit into an SLD unit of measure string.

estimateMaxSymbolBleed

Returns the maximum estimated bleed for the symbol

externalGraphicFromSld

externalGraphicToSld

externalMarkerFromSld

externalMarkerToSld

fieldOrExpressionFromExpression

Returns a field name if the whole expression is just a name of the field .

fieldOrExpressionToExpression

Returns a new valid expression instance for given field or expression string.

fillFromSld

fillToSld

functionFromSldElement

geometryFromSldElement

getSvgParameterList

getSvgParametricPath

Encodes a reference to a parametric SVG into a path with parameters according to the SVG Parameters spec

getVendorOptionList

hasExternalGraphic

hasWellKnownMark

importColorsFromGpl

Imports colors from a gpl GIMP palette file

labelTextToSld

lineFromSld

listSvgFiles

Returns a list of all available svg files

listSvgFilesAt

Returns a list of svg files at the specified directory

loadColorRamp

Creates a color ramp from the settings encoded in an XML element

loadSymbol

Attempts to load a symbol from a DOM element

loadSymbolLayer

Reads and returns symbol layer from XML.

loadSymbols

Reads a collection of symbols from XML and returns them in a map.

mergeScaleDependencies

Merges the local scale limits, if any, with the ones already in the map, if any

multiplyImageOpacity

Multiplies opacity of image pixel values with a (global) transparency value.

needEllipseMarker

needFontMarker

needLinePatternFill

needMarkerLine

needPointPatternFill

needSvgFill

needSvgMarker

ogrFeatureStyleBrush

Create ogr feature style string for brush

ogrFeatureStylePen

Create ogr feature style string for pen

onlineResourceFromSldElement

opacityFromSldElement

parametricSvgToSld

Encodes a reference to a parametric SVG into SLD, as a succession of parametric SVG using URL parameters, a fallback SVG without parameters, and a final fallback as a mark with the right colors and stroke for systems that cannot do SVG at all

parseColor

Attempts to parse a string as a color using a variety of common formats, including hex codes, rgb and rgba strings.

parseColorList

Attempts to parse a string as a list of colors using a variety of common formats, including hex codes, rgb and rgba strings.

parseColorWithAlpha

Attempts to parse a string as a color using a variety of common formats, including hex codes, rgb and rgba strings.

parseProperties

pointInPolygon

Calculate whether a point is within of a QPolygonF

pointOnLineWithDistance

Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point

polygonCentroid

Calculate the centroid point of a QPolygonF

polygonPointOnSurface

Calculate a point on the surface of a QPolygonF

premultiplyColor

Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value

prettyBreaks

Computes a sequence of about ‘classes’ equally spaced round values which cover the range of values from ‘minimum’ to ‘maximum’.

rescaleArrayUom

Rescales the given array based on the uomScale found in the props, if any is found, otherwise returns a copy of the original point

rescalePointUom

Rescales the given point based on the uomScale found in the props, if any is found, otherwise returns a copy of the original point

rescaleUom

Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified

rotationFromSldElement

saveColorRamp

Encodes a color ramp’s settings to an XML element

saveColorsToGpl

Exports colors to a gpl GIMP palette file

saveProperties

saveSymbol

Writes a symbol definition to XML

saveSymbols

Writes a collection of symbols to XML with specified tagName for the top-level element

sizeInPixelsFromSldUom

Returns the size scaled in pixels according to the uom attribute.

sortVariantList

Sorts the passed list in requested order

svgSymbolNameToPath

Determines an SVG symbol’s path from its name.

svgSymbolPathToName

Determines an SVG symbol’s name from its path.

symbolFromMimeData

Attempts to parse mime data as a symbol.

symbolLayerPreviewIcon

Draws a symbol layer preview to an icon.

symbolLayerPreviewPicture

Draws a symbol layer preview to a QPicture

symbolPreviewIcon

Returns an icon preview for a color ramp.

symbolPreviewPixmap

Returns a pixmap preview for a color ramp.

symbolProperties

Returns a string representing the symbol.

symbolToMimeData

Creates new mime data from a symbol.

wellKnownMarkerFromSld2

wellKnownMarkerToSld

Signals

Attributes

Cross

NoMarker

SemiTransparentCircle

Cross = 1
NoMarker = 2
SemiTransparentCircle = 0
class VertexMarkerType

Bases: int

applyScaleDependency(doc: QDomDocument, ruleElem: QDomElement, props: Dict[str, str])

Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into the SE Rule element

New in version 3.0.

blurImageInPlace(image: QImage, rect: QRect, radius: int, alphaOnly: bool)

Blurs an image in place, e.g. creating Qt-independent drop shadows

clearSymbolMap(symbols: object)
colorFromMimeData(data: QMimeData) → Tuple[QColor, bool]

Attempts to parse mime data as a color

Parameters
  • data – mime data to parse

  • hasAlpha – will be set to true if mime data was interpreted as a color containing an explicit alpha value

Returns

valid color if mimedata could be interpreted as a color, otherwise an invalid color

New in version 2.5.

colorListFromMimeData(data: QMimeData) → object

Attempts to parse mime data as a list of named colors

Parameters

data – mime data to parse

Returns

list of parsed colors

New in version 2.5.

colorListToMimeData(colorList: object, allFormats: bool = True) → QMimeData

Creates mime data from a list of named colors

Parameters
  • colorList – list of named colors

  • allFormats – set to true to include additional mime formats, include text/plain and application/x-color

Returns

mime data containing encoded colors

New in version 2.5.

colorRampPreviewIcon(ramp: QgsColorRamp, size: QSize, padding: int = 0) → QIcon

Returns an icon preview for a color ramp.

Parameters
  • ramp – color ramp

  • size – target icon size

  • padding – space between icon edge and color ramp

colorRampPreviewPixmap(ramp: QgsColorRamp, size: QSize, padding: int = 0) → QPixmap

Returns a pixmap preview for a color ramp.

Parameters
  • ramp – color ramp

  • size – target pixmap size

  • padding – space between icon edge and color ramp

colorRampToVariant(name: str, ramp: QgsColorRamp) → Any

Saves a color ramp to a QVariantMap, wrapped in a QVariant. You can use QgsXmlUtils.writeVariant to save it to an XML document.

See also

loadColorRamp()

colorToMimeData(color: Union[QColor, Qt.GlobalColor]) → QMimeData

Creates mime data from a color. Sets both the mime data’s color data, and the mime data’s text with the color’s hex code.

Parameters

color – color to encode as mime data

New in version 2.5.

colorToName(color: Union[QColor, Qt.GlobalColor]) → str

Returns a friendly display name for a color

Parameters

color – source color

Returns

display name for color

New in version 2.5.

convertPolygonSymbolizerToPointMarker(element: QDomElement, layerList: object) → bool
createAnchorPointElement(doc: QDomDocument, element: QDomElement, anchor: Union[QPointF, QPoint])

Creates a SE 1.1 anchor point element as a child of the specified element

Parameters
  • doc – The document

  • element – The parent element

  • anchor – An anchor specification, with values between 0 and 1

createDisplacementElement(doc: QDomDocument, element: QDomElement, offset: Union[QPointF, QPoint])
createExpressionElement(doc: QDomDocument, element: QDomElement, function: str) → bool

Creates a OGC Expression element based on the provided function expression

Parameters
  • doc – The document owning the element

  • element – The element parent

  • function – The expression to be encoded

createFillLayerFromSld(element: QDomElement) → QgsSymbolLayer
createFunctionElement(doc: QDomDocument, element: QDomElement, function: str) → bool
createGeometryElement(doc: QDomDocument, element: QDomElement, geomFunc: str)
createLineLayerFromSld(element: QDomElement) → QgsSymbolLayer
createMarkerLayerFromSld(element: QDomElement) → QgsSymbolLayer
createOnlineResourceElement(doc: QDomDocument, element: QDomElement, path: str, format: str)
createOpacityElement(doc: QDomDocument, element: QDomElement, alphaFunc: str)
createRotationElement(doc: QDomDocument, element: QDomElement, rotationFunc: str)
createSvgParameterElement(doc: QDomDocument, name: str, value: str) → QDomElement
createSymbolLayerListFromSld(element: QDomElement, geomType: QgsWkbTypes.GeometryType, layers: object) → bool
createVendorOptionElement(doc: QDomDocument, name: str, value: str) → QDomElement
decodeArrowHeadType(value: Any) → Tuple[QgsArrowSymbolLayer.HeadType, bool]

Decodes a value representing an arrow head type.

New in version 3.2.

decodeArrowType(value: Any) → Tuple[QgsArrowSymbolLayer.ArrowType, bool]

Decodes a value representing an arrow type.

New in version 3.2.

decodeBlendMode(s: str) → QPainter.CompositionMode
decodeBrushStyle(str: str) → Qt.BrushStyle
decodeColor(str: str) → QColor
decodeMapUnitScale(str: str) → QgsMapUnitScale
decodePenCapStyle(str: str) → Qt.PenCapStyle
decodePenJoinStyle(str: str) → Qt.PenJoinStyle
decodePenStyle(str: str) → Qt.PenStyle
decodePoint(string: str) → QPointF

Decodes a QSizeF from a string.

See also

encodePoint()

See also

decodeSize()

decodeRealVector(s: str) → List[float]
decodeScaleMethod(str: str) → QgsSymbol.ScaleMethod
decodeSize(string: str) → QSizeF

Decodes a QSizeF from a string.

See also

encodeSize()

See also

decodePoint()

New in version 3.0.

decodeSldAlpha(str: str) → int
decodeSldBrushStyle(str: str) → Qt.BrushStyle
decodeSldFontStyle(str: str) → QFont.Style
decodeSldFontWeight(str: str) → int
decodeSldLineCapStyle(str: str) → Qt.PenCapStyle
decodeSldLineJoinStyle(str: str) → Qt.PenJoinStyle
decodeSldRealVector(s: str) → List[float]
decodeSldUom(str: str) → Tuple[QgsUnitTypes.RenderUnit, float]

Decodes a SLD unit of measure string to a render unit.

Parameters
  • str – string to decode

  • scaleFactor – if specified, will be set to scale factor for unit of measure

Returns

matching render unit

See also

encodeSldUom()

displacementFromSldElement(element: QDomElement, offset: Union[QPointF, QPoint]) → bool
drawStippledBackground(painter: QPainter, rect: QRect)
drawVertexMarker(x: float, y: float, p: QPainter, type: QgsSymbolLayerUtils.VertexMarkerType, markerSize: int)

Draws a vertex symbol at (painter) coordinates x, y. (Useful to assist vertex editing.)

New in version 3.4.5.

encodeBrushStyle(style: Qt.BrushStyle) → str
encodeColor(color: Union[QColor, Qt.GlobalColor]) → str
encodeMapUnitScale(mapUnitScale: QgsMapUnitScale) → str
encodePenCapStyle(style: Qt.PenCapStyle) → str
encodePenJoinStyle(style: Qt.PenJoinStyle) → str
encodePenStyle(style: Qt.PenStyle) → str
encodePoint(point: Union[QPointF, QPoint]) → str

Encodes a QPointF to a string.

See also

decodePoint()

See also

encodeSize()

encodeRealVector(v: Iterable[float]) → str
encodeScaleMethod(scaleMethod: QgsSymbol.ScaleMethod) → str
encodeSize(size: QSizeF) → str

Encodes a QSizeF to a string.

See also

decodeSize()

See also

encodePoint()

New in version 3.0.

encodeSldAlpha(alpha: int) → str
encodeSldBrushStyle(style: Qt.BrushStyle) → str
encodeSldFontStyle(style: QFont.Style) → str
encodeSldFontWeight(weight: int) → str
encodeSldLineCapStyle(style: Qt.PenCapStyle) → str
encodeSldLineJoinStyle(style: Qt.PenJoinStyle) → str
encodeSldRealVector(v: Iterable[float]) → str
encodeSldUom(unit: QgsUnitTypes.RenderUnit) → Tuple[str, float]

Encodes a render unit into an SLD unit of measure string.

Parameters
  • unit – unit to encode

  • scaleFactor – if specified, will be set to scale factor for unit of measure

Returns

encoded string

See also

decodeSldUom()

estimateMaxSymbolBleed(symbol: QgsSymbol, context: QgsRenderContext) → float

Returns the maximum estimated bleed for the symbol

externalGraphicFromSld(element: QDomElement, path: str, mime: str, color: Union[QColor, Qt.GlobalColor]) → Tuple[bool, float]
externalGraphicToSld(doc: QDomDocument, element: QDomElement, path: str, mime: str, color: Union[QColor, Qt.GlobalColor], size: float = -1)
externalMarkerFromSld(element: QDomElement, path: str, format: str, color: Union[QColor, Qt.GlobalColor]) → Tuple[bool, int, float]
externalMarkerToSld(doc: QDomDocument, element: QDomElement, path: str, format: str, color: Union[QColor, Qt.GlobalColor] = QColor(), size: float = -1) → int
fieldOrExpressionFromExpression(expression: QgsExpression) → str

Returns a field name if the whole expression is just a name of the field . Returns full expression string if the expression is more complex than just one field. Using just expression->expression() method may return quoted field name, but that is not wanted for saving (due to backward compatibility) or display in GUI.

New in version 2.2.

fieldOrExpressionToExpression(fieldOrExpression: str) → QgsExpression

Returns a new valid expression instance for given field or expression string. If the input is not a valid expression, it is assumed that it is a field name and gets properly quoted. If the string is empty, returns null pointer. This is useful when accepting input which could be either a non-quoted field name or expression.

New in version 2.2.

fillFromSld(element: QDomElement, color: Union[QColor, Qt.GlobalColor]) → Tuple[bool, Qt.BrushStyle]
fillToSld(doc: QDomDocument, element: QDomElement, brushStyle: Qt.BrushStyle, color: Union[QColor, Qt.GlobalColor] = QColor())
functionFromSldElement(element: QDomElement, function: str) → bool
geometryFromSldElement(element: QDomElement, geomFunc: str) → bool
getSvgParameterList(element: QDomElement) → Dict[str, str]
getSvgParametricPath(basePath: str, fillColor: Union[QColor, Qt.GlobalColor], strokeColor: Union[QColor, Qt.GlobalColor], strokeWidth: float) → str

Encodes a reference to a parametric SVG into a path with parameters according to the SVG Parameters spec

New in version 3.0.

getVendorOptionList(element: QDomElement) → Dict[str, str]
hasExternalGraphic(element: QDomElement) → bool
hasWellKnownMark(element: QDomElement) → bool
importColorsFromGpl(file: QFile, name: str) → Tuple[object, bool]

Imports colors from a gpl GIMP palette file

Parameters
  • file – source gpl file

  • ok – will be true if file was successfully read

  • name – will be set to palette name from gpl file, if present

Returns

list of imported colors

labelTextToSld(doc: QDomDocument, element: QDomElement, label: str, font: QFont, color: Union[QColor, Qt.GlobalColor] = QColor(), size: float = -1)
lineFromSld(element: QDomElement, color: Union[QColor, Qt.GlobalColor], customDashPattern: Iterable[float] = []) → Tuple[bool, Qt.PenStyle, float, Qt.PenJoinStyle, Qt.PenCapStyle, float]
listSvgFiles() → List[str]

Returns a list of all available svg files

listSvgFilesAt(directory: str) → List[str]

Returns a list of svg files at the specified directory

loadColorRamp(element: QDomElement) → QgsColorRamp

Creates a color ramp from the settings encoded in an XML element

Parameters

element – DOM element

Returns

new color ramp. Caller takes responsibility for deleting the returned value.

See also

saveColorRamp()

loadColorRamp(value: Any) -> QgsColorRamp Load a color ramp from a QVariantMap, wrapped in a QVariant. You can use QgsXmlUtils.readVariant to load it from an XML document.

loadSymbol(element: QDomElement, context: QgsReadWriteContext) → QgsSymbol

Attempts to load a symbol from a DOM element

Parameters
  • element – DOM element representing symbol

  • context – object to transform relative to absolute paths

Returns

decoded symbol, if possible

loadSymbolLayer(element: QDomElement, context: QgsReadWriteContext) → QgsSymbolLayer

Reads and returns symbol layer from XML. Caller is responsible for deleting the returned object

loadSymbols(element: QDomElement, context: QgsReadWriteContext) → object

Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting returned symbols.

mergeScaleDependencies(mScaleMinDenom: float, mScaleMaxDenom: float, props: Dict[str, str])

Merges the local scale limits, if any, with the ones already in the map, if any

New in version 3.0.

multiplyImageOpacity(image: QImage, opacity: float)

Multiplies opacity of image pixel values with a (global) transparency value.

needEllipseMarker(element: QDomElement) → bool
needFontMarker(element: QDomElement) → bool
needLinePatternFill(element: QDomElement) → bool
needMarkerLine(element: QDomElement) → bool
needPointPatternFill(element: QDomElement) → bool
needSvgFill(element: QDomElement) → bool
needSvgMarker(element: QDomElement) → bool
ogrFeatureStyleBrush(fillColr: Union[QColor, Qt.GlobalColor]) → str

Create ogr feature style string for brush

Parameters

fillColr – fill color*

ogrFeatureStylePen(width: float, mmScaleFactor: float, mapUnitsScaleFactor: float, c: Union[QColor, Qt.GlobalColor], joinStyle: Qt.PenJoinStyle = Qt.MiterJoin, capStyle: Qt.PenCapStyle = Qt.FlatCap, offset: float = 0, dashPattern: Iterable[float] = []) → str

Create ogr feature style string for pen

onlineResourceFromSldElement(element: QDomElement, path: str, format: str) → bool
opacityFromSldElement(element: QDomElement, alphaFunc: str) → bool
parametricSvgToSld(doc: QDomDocument, graphicElem: QDomElement, path: str, fillColor: Union[QColor, Qt.GlobalColor], size: float, strokeColor: Union[QColor, Qt.GlobalColor], strokeWidth: float)

Encodes a reference to a parametric SVG into SLD, as a succession of parametric SVG using URL parameters, a fallback SVG without parameters, and a final fallback as a mark with the right colors and stroke for systems that cannot do SVG at all

New in version 3.0.

parseColor(colorStr: str, strictEval: bool = False) → QColor

Attempts to parse a string as a color using a variety of common formats, including hex codes, rgb and rgba strings.

Parameters
  • colorStr – string representing the color

  • strictEval – set to true for stricter color parsing rules

Returns

parsed color

New in version 2.3.

parseColorList(colorStr: str) → List[QColor]

Attempts to parse a string as a list of colors using a variety of common formats, including hex codes, rgb and rgba strings.

Parameters

colorStr – string representing the color list

Returns

list of parsed colors

New in version 2.5.

parseColorWithAlpha(colorStr: str, strictEval: bool = False) → Tuple[QColor, bool]

Attempts to parse a string as a color using a variety of common formats, including hex codes, rgb and rgba strings.

Parameters
  • colorStr – string representing the color

  • containsAlpha – if colorStr contains an explicit alpha value then containsAlpha will be set to true

  • strictEval – set to true for stricter color parsing rules

Returns

parsed color

New in version 2.3.

parseProperties(element: QDomElement) → Dict[str, str]
pointInPolygon(points: QPolygonF, point: Union[QPointF, QPoint]) → bool

Calculate whether a point is within of a QPolygonF

pointOnLineWithDistance(startPoint: Union[QPointF, QPoint], directionPoint: Union[QPointF, QPoint], distance: float) → QPointF

Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point

polygonCentroid(points: QPolygonF) → QPointF

Calculate the centroid point of a QPolygonF

polygonPointOnSurface(points: QPolygonF, rings: Iterable[QPolygonF] = []) → QPointF

Calculate a point on the surface of a QPolygonF

premultiplyColor(rgb: Union[QColor, Qt.GlobalColor], alpha: int)

Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value

New in version 2.3.

prettyBreaks(minimum: float, maximum: float, classes: int) → List[float]

Computes a sequence of about ‘classes’ equally spaced round values which cover the range of values from ‘minimum’ to ‘maximum’. The values are chosen so that they are 1, 2 or 5 times a power of 10.

New in version 2.10.

rescaleArrayUom(array: Iterable[float], unit: QgsUnitTypes.RenderUnit, props: Dict[str, str]) → List[float]

Rescales the given array based on the uomScale found in the props, if any is found, otherwise returns a copy of the original point

New in version 3.0.

rescalePointUom(point: Union[QPointF, QPoint], unit: QgsUnitTypes.RenderUnit, props: Dict[str, str]) → QPointF

Rescales the given point based on the uomScale found in the props, if any is found, otherwise returns a copy of the original point

New in version 3.0.

rescaleUom(size: float, unit: QgsUnitTypes.RenderUnit, props: Dict[str, str]) → float

Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified

New in version 3.0.

rotationFromSldElement(element: QDomElement, rotationFunc: str) → bool
saveColorRamp(name: str, ramp: QgsColorRamp, doc: QDomDocument) → QDomElement

Encodes a color ramp’s settings to an XML element

Parameters
  • name – name of ramp

  • ramp – color ramp to save

  • doc – XML document

Returns

DOM element representing state of color ramp

See also

loadColorRamp()

saveColorsToGpl(file: QFile, paletteName: str, colors: object) → bool

Exports colors to a gpl GIMP palette file

Parameters
  • file – destination file

  • paletteName – name of palette, which is stored in gpl file

  • colors – colors to export

Returns

true if export was successful

saveProperties(props: Dict[str, str], doc: QDomDocument, element: QDomElement)
saveSymbol(symbolName: str, symbol: QgsSymbol, doc: QDomDocument, context: QgsReadWriteContext) → QDomElement

Writes a symbol definition to XML

saveSymbols(symbols: object, tagName: str, doc: QDomDocument, context: QgsReadWriteContext) → QDomElement

Writes a collection of symbols to XML with specified tagName for the top-level element

sizeInPixelsFromSldUom(uom: str, size: float) → float

Returns the size scaled in pixels according to the uom attribute.

Parameters
  • uom – The uom attribute from SLD 1.1 version

  • size – The original size

Returns

the size in pixels

New in version 3.0.

sortVariantList(list: Iterable[Any], order: Qt.SortOrder)

Sorts the passed list in requested order

svgSymbolNameToPath(name: str, pathResolver: QgsPathResolver) → str

Determines an SVG symbol’s path from its name. If name is not an absolute path the file is scanned for in the SVG paths specified in settings svg/searchPathsForSVG.

svgSymbolPathToName(path: str, pathResolver: QgsPathResolver) → str

Determines an SVG symbol’s name from its path.

symbolFromMimeData(data: QMimeData) → QgsSymbol

Attempts to parse mime data as a symbol. A new symbol instance will be returned if the data was successfully converted to a symbol.

New in version 3.0.

symbolLayerPreviewIcon(layer: QgsSymbolLayer, u: QgsUnitTypes.RenderUnit, size: QSize, scale: QgsMapUnitScale = QgsMapUnitScale()) → QIcon

Draws a symbol layer preview to an icon.

Parameters
  • layer – symbol layer to draw

  • u – size units

  • size – target size of preview icon

  • scale – map unit scale for preview

Returns

icon containing symbol layer preview

symbolLayerPreviewPicture(layer: QgsSymbolLayer, units: QgsUnitTypes.RenderUnit, size: QSize, scale: QgsMapUnitScale = QgsMapUnitScale()) → QPicture

Draws a symbol layer preview to a QPicture

Parameters
  • layer – symbol layer to draw

  • units – size units

  • size – target size of preview picture

  • scale – map unit scale for preview

Returns

QPicture containing symbol layer preview

New in version 2.9.

symbolPreviewIcon(symbol: QgsSymbol, size: QSize, padding: int = 0) → QIcon

Returns an icon preview for a color ramp.

Parameters
  • symbol – symbol

  • size – target pixmap size

  • padding – space between icon edge and symbol

symbolPreviewPixmap(symbol: QgsSymbol, size: QSize, padding: int = 0, customContext: QgsRenderContext = None) → QPixmap

Returns a pixmap preview for a color ramp.

Parameters
  • symbol – symbol

  • size – target pixmap size

  • padding – space between icon edge and symbol

  • customContext – render context to use when rendering symbol

Note

Parameter customContext added in QGIS 2.6

symbolProperties(symbol: QgsSymbol) → str

Returns a string representing the symbol. Can be used to test for equality between symbols.

New in version 2.12.

symbolToMimeData(symbol: QgsSymbol) → QMimeData

Creates new mime data from a symbol. This also sets the mime color data to match the symbol’s color, so that copied symbols can be paste in places where a color is expected.

New in version 3.0.

wellKnownMarkerFromSld2(element: QDomElement, name: str, color: Union[QColor, Qt.GlobalColor], strokeColor: Union[QColor, Qt.GlobalColor]) → Tuple[bool, Qt.PenStyle, float, float]

Note

available in Python as wellKnownMarkerFromSld2

wellKnownMarkerToSld(doc: QDomDocument, element: QDomElement, name: str, color: Union[QColor, Qt.GlobalColor], strokeColor: Union[QColor, Qt.GlobalColor], strokeStyle: Qt.PenStyle, strokeWidth: float = -1, size: float = -1)