QGIS API Documentation 3.43.0-Master (ac9f54ad1f7)
Static Public Member Functions | List of all members
QgsSymbolLayerUtils Class Reference

Contains utility functions for working with symbols and symbol layers. More...

#include <qgssymbollayerutils.h>

Static Public Member Functions

static void appendPolyline (QPolygonF &target, const QPolygonF &line)
 Appends a polyline line to an existing target polyline.
 
static void applyScaleDependency (QDomDocument &doc, QDomElement &ruleElem, QVariantMap &props)
 Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into the SE Rule element.
 
static void blurImageInPlace (QImage &image, QRect rect, int radius, bool alphaOnly)
 Blurs an image in place, e.g. creating Qt-independent drop shadows.
 
static void clearSymbolLayerIds (QgsSymbol *symbol)
 Remove recursively unique id from all symbol symbol layers and set an empty string instead.
 
static void clearSymbolLayerIds (QgsSymbolLayer *symbolLayer)
 Remove recursively unique id from symbolLayer and its children and set an empty string instead.
 
static void clearSymbolLayerMasks (QgsSymbol *symbol)
 Remove recursively masks from all symbol symbol layers.
 
static void clearSymbolMap (QgsSymbolMap &symbols)
 
static QVector< QgsGeometrycollectSymbolLayerClipGeometries (const QgsRenderContext &context, const QString &symbolLayerId, const QRectF &bounds)
 Returns a list of the symbol layer clip geometries to be used for the symbol layer with the specified ID.
 
static QColor colorFromMimeData (const QMimeData *data, bool &hasAlpha)
 Attempts to parse mime data as a color.
 
static QgsNamedColorList colorListFromMimeData (const QMimeData *data)
 Attempts to parse mime data as a list of named colors.
 
static QMimeData * colorListToMimeData (const QgsNamedColorList &colorList, bool allFormats=true)
 Creates mime data from a list of named colors.
 
static QIcon colorRampPreviewIcon (QgsColorRamp *ramp, QSize size, int padding=0)
 Returns an icon preview for a color ramp.
 
static QPixmap colorRampPreviewPixmap (QgsColorRamp *ramp, QSize size, int padding=0, Qt::Orientation direction=Qt::Horizontal, bool flipDirection=false, bool drawTransparentBackground=true)
 Returns a pixmap preview for a color ramp.
 
static QVariant colorRampToVariant (const QString &name, QgsColorRamp *ramp)
 Saves a color ramp to a QVariantMap, wrapped in a QVariant.
 
static QMimeData * colorToMimeData (const QColor &color)
 Creates mime data from a color.
 
static QString colorToName (const QColor &color)
 Returns a friendly display name for a color.
 
static bool condenseFillAndOutline (QgsFillSymbolLayer *fill, QgsLineSymbolLayer *outline)
 Attempts to condense a fill and outline layer, by moving the outline layer to the fill symbol's stroke.
 
static bool convertPolygonSymbolizerToPointMarker (QDomElement &element, QList< QgsSymbolLayer * > &layerList)
 Converts a polygon symbolizer element to a list of marker symbol layers.
 
static void createAnchorPointElement (QDomDocument &doc, QDomElement &element, QPointF anchor)
 Creates a SE 1.1 anchor point element as a child of the specified element.
 
static void createDisplacementElement (QDomDocument &doc, QDomElement &element, QPointF offset)
 
static Q_DECL_DEPRECATED bool createExpressionElement (QDomDocument &doc, QDomElement &element, const QString &function)
 Creates a OGC Expression element based on the provided function expression.
 
static bool createExpressionElement (QDomDocument &doc, QDomElement &element, const QString &function, QgsSldExportContext &context)
 Creates a OGC Expression element based on the provided function expression.
 
static std::unique_ptr< QgsSymbolLayercreateFillLayerFromSld (QDomElement &element)
 Creates a new fill layer from a SLD DOM element.
 
static Q_DECL_DEPRECATED bool createFunctionElement (QDomDocument &doc, QDomElement &element, const QString &function)
 Creates an OGC function element.
 
static bool createFunctionElement (QDomDocument &doc, QDomElement &element, const QString &function, QgsSldExportContext &context)
 Creates an OGC function element.
 
static Q_DECL_DEPRECATED void createGeometryElement (QDomDocument &doc, QDomElement &element, const QString &geomFunc)
 Creates an SLD geometry element.
 
static void createGeometryElement (QDomDocument &doc, QDomElement &element, const QString &geomFunc, QgsSldExportContext &context)
 Creates an SLD geometry element.
 
static std::unique_ptr< QgsSymbolLayercreateLineLayerFromSld (QDomElement &element)
 Creates a new line layer from a SLD DOM element.
 
static std::unique_ptr< QgsSymbolLayercreateMarkerLayerFromSld (QDomElement &element)
 Creates a new marker layer from a SLD DOM element.
 
static void createOnlineResourceElement (QDomDocument &doc, QDomElement &element, const QString &path, const QString &format)
 
static Q_DECL_DEPRECATED void createOpacityElement (QDomDocument &doc, QDomElement &element, const QString &alphaFunc)
 Creates SLD opacity element.
 
static void createOpacityElement (QDomDocument &doc, QDomElement &element, const QString &alphaFunc, QgsSldExportContext &context)
 Creates SLD opacity element.
 
static Q_DECL_DEPRECATED void createRotationElement (QDomDocument &doc, QDomElement &element, const QString &rotationFunc)
 Creates SLD rotation element.
 
static void createRotationElement (QDomDocument &doc, QDomElement &element, const QString &rotationFunc, QgsSldExportContext &context)
 Creates SLD rotation element.
 
static QDomElement createSvgParameterElement (QDomDocument &doc, const QString &name, const QString &value)
 
static bool createSymbolLayerListFromSld (QDomElement &element, Qgis::GeometryType geomType, QList< QgsSymbolLayer * > &layers)
 Creates a symbol layer list from a DOM element.
 
static QDomElement createVendorOptionElement (QDomDocument &doc, const QString &name, const QString &value)
 
static QgsArrowSymbolLayer::HeadType decodeArrowHeadType (const QVariant &value, bool *ok=nullptr)
 Decodes a value representing an arrow head type.
 
static QgsArrowSymbolLayer::ArrowType decodeArrowType (const QVariant &value, bool *ok=nullptr)
 Decodes a value representing an arrow type.
 
static QPainter::CompositionMode decodeBlendMode (const QString &s)
 
static Qt::BrushStyle decodeBrushStyle (const QString &str)
 
static QColor decodeColor (const QString &str)
 
static Qgis::SymbolCoordinateReference decodeCoordinateReference (const QString &string, bool *ok=nullptr)
 Decodes a string representing a symbol coordinate reference mode.
 
static Qgis::LineClipMode decodeLineClipMode (const QString &string, bool *ok=nullptr)
 Decodes a string representing a line clip mode.
 
static QgsMapUnitScale decodeMapUnitScale (const QString &str)
 
static Qgis::MarkerClipMode decodeMarkerClipMode (const QString &string, bool *ok=nullptr)
 Decodes a string representing a marker clip mode.
 
static Qt::PenCapStyle decodePenCapStyle (const QString &str)
 
static Qt::PenJoinStyle decodePenJoinStyle (const QString &str)
 
static Qt::PenStyle decodePenStyle (const QString &str)
 
static QPointF decodePoint (const QString &string)
 Decodes a QSizeF from a string.
 
static QVector< qreal > decodeRealVector (const QString &s)
 
static Qgis::ScaleMethod decodeScaleMethod (const QString &str)
 Decodes a symbol scale method from a string.
 
static QSizeF decodeSize (const QString &string)
 Decodes a QSizeF from a string.
 
static int decodeSldAlpha (const QString &str)
 
static Qt::BrushStyle decodeSldBrushStyle (const QString &str)
 
static QFont::Style decodeSldFontStyle (const QString &str)
 
static int decodeSldFontWeight (const QString &str)
 
static Qt::PenCapStyle decodeSldLineCapStyle (const QString &str)
 
static Qt::PenJoinStyle decodeSldLineJoinStyle (const QString &str)
 
static QVector< qreal > decodeSldRealVector (const QString &s)
 
static Qgis::RenderUnit decodeSldUom (const QString &str, double *scaleFactor=nullptr)
 Decodes a SLD unit of measure string to a render unit.
 
static bool displacementFromSldElement (QDomElement &element, QPointF &offset)
 
static void drawStippledBackground (QPainter *painter, QRect rect)
 
static void drawVertexMarker (double x, double y, QPainter &p, Qgis::VertexMarkerType type, int markerSize)
 Draws a vertex symbol at (painter) coordinates x, y.
 
static QString encodeBrushStyle (Qt::BrushStyle style)
 
static QString encodeColor (const QColor &color)
 
static QString encodeCoordinateReference (Qgis::SymbolCoordinateReference coordinateReference)
 Encodes a symbol coordinate reference mode to a string.
 
static QString encodeLineClipMode (Qgis::LineClipMode mode)
 Encodes a line clip mode to a string.
 
static QString encodeMapUnitScale (const QgsMapUnitScale &mapUnitScale)
 
static QString encodeMarkerClipMode (Qgis::MarkerClipMode mode)
 Encodes a marker clip mode to a string.
 
static QString encodePenCapStyle (Qt::PenCapStyle style)
 
static QString encodePenJoinStyle (Qt::PenJoinStyle style)
 
static QString encodePenStyle (Qt::PenStyle style)
 
static QString encodePoint (QPointF point)
 Encodes a QPointF to a string.
 
static QString encodeRealVector (const QVector< qreal > &v)
 
static QString encodeScaleMethod (Qgis::ScaleMethod scaleMethod)
 Encodes a symbol scale method to a string.
 
static QString encodeSize (QSizeF size)
 Encodes a QSizeF to a string.
 
static QString encodeSldAlpha (int alpha)
 
static QString encodeSldBrushStyle (Qt::BrushStyle style)
 
static QString encodeSldFontStyle (QFont::Style style)
 
static QString encodeSldFontWeight (int weight)
 
static QString encodeSldLineCapStyle (Qt::PenCapStyle style)
 
static QString encodeSldLineJoinStyle (Qt::PenJoinStyle style)
 
static QString encodeSldRealVector (const QVector< qreal > &v)
 
static QString encodeSldUom (Qgis::RenderUnit unit, double *scaleFactor)
 Encodes a render unit into an SLD unit of measure string.
 
static double estimateMaxSymbolBleed (QgsSymbol *symbol, const QgsRenderContext &context)
 Returns the maximum estimated bleed for the symbol.
 
static QgsStringMap evaluatePropertiesMap (const QMap< QString, QgsProperty > &propertiesMap, const QgsExpressionContext &context)
 Evaluates a map of properties using the given context and returns a variant map with evaluated expressions from the properties.
 
static bool externalGraphicFromSld (QDomElement &element, QString &path, QString &mime, QColor &color, double &size)
 
static void externalGraphicToSld (QDomDocument &doc, QDomElement &element, const QString &path, const QString &mime, const QColor &color, double size=-1)
 
static bool externalMarkerFromSld (QDomElement &element, QString &path, QString &format, int &markIndex, QColor &color, double &size)
 
static Q_DECL_DEPRECATED void externalMarkerToSld (QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
 Exports a marker to an SLD definition.
 
static void externalMarkerToSld (QDomDocument &doc, QDomElement &element, const QString &path, const QString &format, QgsSldExportContext &context, int *markIndex=nullptr, const QColor &color=QColor(), double size=-1)
 Exports a marker to an SLD definition.
 
static QString fieldOrExpressionFromExpression (QgsExpression *expression)
 Returns a field name if the whole expression is just a name of the field .
 
static std::unique_ptr< QgsExpressionfieldOrExpressionToExpression (const QString &fieldOrExpression)
 Returns a new valid expression instance for given field or expression string.
 
static bool fillFromSld (QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
 
static void fillToSld (QDomDocument &doc, QDomElement &element, QgsSldExportContext &context, Qt::BrushStyle brushStyle, const QColor &color=QColor())
 Exports fill details to an SLD element.
 
static Q_DECL_DEPRECATED void fillToSld (QDomDocument &doc, QDomElement &element, Qt::BrushStyle brushStyle, const QColor &color=QColor())
 Exports fill details to an SLD element.
 
static bool functionFromSldElement (QDomElement &element, QString &function)
 
static bool geometryFromSldElement (QDomElement &element, QString &geomFunc)
 
static QgsStringMap getSvgParameterList (QDomElement &element)
 
static QString getSvgParametricPath (const QString &basePath, const QColor &fillColor, const QColor &strokeColor, double strokeWidth)
 Encodes a reference to a parametric SVG into a path with parameters according to the SVG Parameters spec.
 
static QgsStringMap getVendorOptionList (QDomElement &element)
 
static bool hasExternalGraphic (QDomElement &element)
 Checks if element contains an ExternalGraphic element with format "image/svg+xml".
 
static bool hasExternalGraphicV2 (QDomElement &element, const QString format=QString())
 Checks if element contains an ExternalGraphic element, if the optional format is specified it will also be checked.
 
static bool hasSldSymbolizer (const QDomElement &element)
 Returns true if a DOM element contains an SLD Symbolizer element.
 
static bool hasWellKnownMark (QDomElement &element)
 
static QgsNamedColorList importColorsFromGpl (QFile &file, bool &ok, QString &name)
 Imports colors from a gpl GIMP palette file.
 
static bool isSharpCorner (QPointF p1, QPointF p2, QPointF p3)
 Returns true if the angle formed by the line p1 - p2 - p3 forms a "sharp" corner.
 
static Q_DECL_DEPRECATED void labelTextToSld (QDomDocument &doc, QDomElement &element, const QString &label, const QFont &font, const QColor &color=QColor(), double size=-1)
 Exports label text to SLD.
 
static void labelTextToSld (QDomDocument &doc, QDomElement &element, const QString &label, const QFont &font, QgsSldExportContext &context, const QColor &color=QColor(), double size=-1)
 Exports label text to SLD.
 
static bool lineFromSld (QDomElement &element, Qt::PenStyle &penStyle, QColor &color, double &width, Qt::PenJoinStyle *penJoinStyle=nullptr, Qt::PenCapStyle *penCapStyle=nullptr, QVector< qreal > *customDashPattern=nullptr, double *dashOffset=nullptr)
 
static void lineToSld (QDomDocument &doc, QDomElement &element, Qt::PenStyle penStyle, const QColor &color, QgsSldExportContext &context, double width=-1, const Qt::PenJoinStyle *penJoinStyle=nullptr, const Qt::PenCapStyle *penCapStyle=nullptr, const QVector< qreal > *customDashPattern=nullptr, double dashOffset=0.0)
 
static QStringList listSvgFiles ()
 Returns a list of all available svg files.
 
static QStringList listSvgFilesAt (const QString &directory)
 Returns a list of svg files at the specified directory.
 
static std::unique_ptr< QgsColorRamploadColorRamp (const QVariant &value)
 Load a color ramp from a QVariantMap, wrapped in a QVariant.
 
static std::unique_ptr< QgsColorRamploadColorRamp (QDomElement &element)
 Creates a color ramp from the settings encoded in an XML element.
 
static std::unique_ptr< QgsSymbolloadSymbol (const QDomElement &element, const QgsReadWriteContext &context)
 Attempts to load a symbol from a DOM element.
 
template<class SymbolType >
static std::unique_ptr< SymbolType > loadSymbol (const QDomElement &element, const QgsReadWriteContext &context)
 Attempts to load a symbol from a DOM element and cast it to a particular symbol type.
 
static std::unique_ptr< QgsSymbolLayerloadSymbolLayer (QDomElement &element, const QgsReadWriteContext &context)
 Reads and returns symbol layer from XML. Caller is responsible for deleting the returned object.
 
static QgsSymbolMap loadSymbols (QDomElement &element, const QgsReadWriteContext &context)
 Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting returned symbols.
 
static void mergeScaleDependencies (double mScaleMinDenom, double mScaleMaxDenom, QVariantMap &props)
 Merges the local scale limits, if any, with the ones already in the map, if any.
 
static void multiplyImageOpacity (QImage *image, qreal opacity)
 Multiplies opacity of image pixel values with a (global) transparency value.
 
static bool needEllipseMarker (QDomElement &element)
 
static bool needFontMarker (QDomElement &element)
 
static bool needLinePatternFill (QDomElement &element)
 
static bool needMarkerLine (QDomElement &element)
 
static bool needPointPatternFill (QDomElement &element)
 
static bool needRasterImageFill (QDomElement &element)
 Checks if element contains a graphic fill with a raster image of type PNG, JPEG or GIF.
 
static bool needSvgFill (QDomElement &element)
 
static bool needSvgMarker (QDomElement &element)
 
static QString ogrFeatureStyleBrush (const QColor &fillColr)
 Create ogr feature style string for brush.
 
static QString ogrFeatureStylePen (double width, double mmScaleFactor, double mapUnitsScaleFactor, const QColor &c, Qt::PenJoinStyle joinStyle=Qt::MiterJoin, Qt::PenCapStyle capStyle=Qt::FlatCap, double offset=0.0, const QVector< qreal > *dashPattern=nullptr)
 Create ogr feature style string for pen.
 
static bool onlineResourceFromSldElement (QDomElement &element, QString &path, QString &format)
 
static bool opacityFromSldElement (QDomElement &element, QString &alphaFunc)
 
static Q_DECL_DEPRECATED void parametricSvgToSld (QDomDocument &doc, QDomElement &graphicElem, const QString &path, const QColor &fillColor, double size, const QColor &strokeColor, double strokeWidth)
 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.
 
static void parametricSvgToSld (QDomDocument &doc, QDomElement &graphicElem, const QString &path, const QColor &fillColor, double size, const QColor &strokeColor, double strokeWidth, QgsSldExportContext &context)
 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.
 
static QColor parseColor (const QString &colorStr, bool strictEval=false)
 Attempts to parse a string as a color using a variety of common formats, including hex codes, rgb and rgba strings.
 
static QList< QColor > parseColorList (const QString &colorStr)
 Attempts to parse a string as a list of colors using a variety of common formats, including hex codes, rgb and rgba strings.
 
static QColor parseColorWithAlpha (const QString &colorStr, bool &containsAlpha, bool strictEval=false)
 Attempts to parse a string as a color using a variety of common formats, including hex codes, rgb and rgba, hsl and hsla strings.
 
static QVariantMap parseProperties (const QDomElement &element)
 Parses the properties from XML and returns a map.
 
static Qgis::EndCapStyle penCapStyleToEndCapStyle (Qt::PenCapStyle style)
 Converts a Qt pen cap style to a QGIS end cap style.
 
static Qgis::JoinStyle penJoinStyleToJoinStyle (Qt::PenJoinStyle style)
 Converts a Qt pen joinstyle to a QGIS join style.
 
static bool pointInPolygon (const QPolygonF &points, QPointF point)
 Calculate whether a point is within of a QPolygonF.
 
static QPointF pointOnLineWithDistance (QPointF startPoint, QPointF directionPoint, double distance)
 Returns a point on the line from startPoint to directionPoint that is a certain distance away from the starting point.
 
static QPointF polygonCentroid (const QPolygonF &points)
 Calculate the centroid point of a QPolygonF.
 
static QPointF polygonPointOnSurface (const QPolygonF &points, const QVector< QPolygonF > *rings=nullptr)
 Calculate a point on the surface of a QPolygonF.
 
static double polylineLength (const QPolygonF &polyline)
 Returns the total length of a polyline.
 
static QPolygonF polylineSubstring (const QPolygonF &polyline, double startOffset, double endOffset)
 Returns the substring of a polyline which starts at startOffset from the beginning of the line and ends at endOffset from the start of the line.
 
static void premultiplyColor (QColor &rgb, int alpha)
 Converts a QColor into a premultiplied ARGB QColor value using a specified alpha value.
 
static QList< double > prettyBreaks (double minimum, double maximum, int classes)
 Computes a sequence of about 'classes' equally spaced round values which cover the range of values from 'minimum' to 'maximum'.
 
static double rendererFrameRate (const QgsFeatureRenderer *renderer)
 Calculates the frame rate (in frames per second) at which the given renderer must be redrawn.
 
static QVector< qreal > rescaleUom (const QVector< qreal > &array, Qgis::RenderUnit unit, const QVariantMap &props)
 Rescales the given array based on the uomScale found in the props, if any is found, otherwise returns a copy of the original point.
 
static double rescaleUom (double size, Qgis::RenderUnit unit, const QVariantMap &props)
 Rescales the given size based on the uomScale found in the props, if any is found, otherwise returns the value un-modified.
 
static QPointF rescaleUom (QPointF point, Qgis::RenderUnit unit, const QVariantMap &props)
 Rescales the given point based on the uomScale found in the props, if any is found, otherwise returns a copy of the original point.
 
static void resetSymbolLayerIds (QgsSymbol *symbol)
 Regenerate recursively unique id from all symbol symbol layers.
 
static void resetSymbolLayerIds (QgsSymbolLayer *symbolLayer)
 Regenerate recursively unique id from symbolLayer and its children.
 
static QgsSymbolrestrictedSizeSymbol (const QgsSymbol *s, double minSize, double maxSize, QgsRenderContext *context, double &width, double &height, bool *ok=nullptr)
 Creates a new symbol with size restricted to min/max size if original size is out of min/max range.
 
static bool rotationFromSldElement (QDomElement &element, QString &rotationFunc)
 
static QDomElement saveColorRamp (const QString &name, const QgsColorRamp *ramp, QDomDocument &doc)
 Encodes a color ramp's settings to an XML element.
 
static bool saveColorsToGpl (QFile &file, const QString &paletteName, const QgsNamedColorList &colors)
 Exports colors to a gpl GIMP palette file.
 
static void saveProperties (QVariantMap props, QDomDocument &doc, QDomElement &element)
 Saves the map of properties to XML.
 
static QDomElement saveSymbol (const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
 Writes a symbol definition to XML.
 
static QDomElement saveSymbols (QgsSymbolMap &symbols, const QString &tagName, QDomDocument &doc, const QgsReadWriteContext &context)
 Writes a collection of symbols to XML with specified tagName for the top-level element.
 
static double sizeInPixelsFromSldUom (const QString &uom, double size)
 Returns the size scaled in pixels according to the uom attribute.
 
static void sortVariantList (QList< QVariant > &list, Qt::SortOrder order)
 Sorts the passed list in requested order.
 
static QString svgSymbolNameToPath (const QString &name, const QgsPathResolver &pathResolver)
 Determines an SVG symbol's path from its name.
 
static QString svgSymbolPathToName (const QString &path, const QgsPathResolver &pathResolver)
 Determines an SVG symbol's name from its path.
 
static std::unique_ptr< QgsSymbolsymbolFromMimeData (const QMimeData *data)
 Attempts to parse mime data as a symbol.
 
static QIcon symbolLayerPreviewIcon (const QgsSymbolLayer *layer, Qgis::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid, QgsMapLayer *mapLayer=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
 Draws a symbol layer preview to an icon.
 
static QPicture symbolLayerPreviewPicture (const QgsSymbolLayer *layer, Qgis::RenderUnit units, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid)
 Draws a symbol layer preview to a QPicture.
 
static QIcon symbolPreviewIcon (const QgsSymbol *symbol, QSize size, int padding=0, QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
 Returns an icon preview for a color ramp.
 
static QPixmap symbolPreviewPixmap (const QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *shape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
 Returns a pixmap preview for a color ramp.
 
static QString symbolProperties (QgsSymbol *symbol)
 Returns a string representing the symbol.
 
static QMimeData * symbolToMimeData (const QgsSymbol *symbol)
 Creates new mime data from a symbol.
 
static QSize tileSize (int width, int height, double &angleRad)
 Calculate the minimum size in pixels of a symbol tile given the symbol width and height and the symbol layer rotation angleRad in radians (counter clockwise).
 
static QPointF toPoint (const QVariant &value, bool *ok=nullptr)
 Converts a value to a point.
 
static QList< QList< QPolygonF > > toQPolygonF (const QgsAbstractGeometry *geometry, Qgis::SymbolType type)
 Converts a geometry to a set of QPolygonF objects representing how the geometry should be drawn for a symbol of the given type, as a list of geometry parts and rings.
 
static QList< QList< QPolygonF > > toQPolygonF (const QgsGeometry &geometry, Qgis::SymbolType type)
 Converts a geometry to a set of QPolygonF objects representing how the geometry should be drawn for a symbol of the given type, as a list of geometry parts and rings.
 
static QSizeF toSize (const QVariant &value, bool *ok=nullptr)
 Converts a value to a size.
 
static Q_DECL_DEPRECATED QSet< const QgsSymbolLayer * > toSymbolLayerPointers (const QgsFeatureRenderer *renderer, const QSet< QgsSymbolLayerId > &symbolLayerIds)
 Converts a set of symbol layer id to a set of pointers to actual symbol layers carried by the feature renderer.
 
static bool wellKnownMarkerFromSld (QDomElement &element, QString &name, QColor &color, QColor &strokeColor, Qt::PenStyle &strokeStyle, double &strokeWidth, double &size)
 Extracts properties from an SLD marker definition.
 
static Q_DECL_DEPRECATED void wellKnownMarkerToSld (QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth=-1, double size=-1)
 Exports a marker to SLD.
 
static void wellKnownMarkerToSld (QDomDocument &doc, QDomElement &element, const QString &name, const QColor &color, const QColor &strokeColor, Qt::PenStyle strokeStyle, QgsSldExportContext &context, double strokeWidth=-1, double size=-1)
 Exports a marker to SLD.
 

Detailed Description

Contains utility functions for working with symbols and symbol layers.

Definition at line 60 of file qgssymbollayerutils.h.

Member Function Documentation

◆ appendPolyline()

void QgsSymbolLayerUtils::appendPolyline ( QPolygonF &  target,
const QPolygonF &  line 
)
static

Appends a polyline line to an existing target polyline.

Any duplicate points at the start line which match the end point from target will be skipped.

Since
QGIS 3.16

Definition at line 4898 of file qgssymbollayerutils.cpp.

◆ applyScaleDependency()

void QgsSymbolLayerUtils::applyScaleDependency ( QDomDocument &  doc,
QDomElement &  ruleElem,
QVariantMap &  props 
)
static

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

Definition at line 5192 of file qgssymbollayerutils.cpp.

◆ blurImageInPlace()

void QgsSymbolLayerUtils::blurImageInPlace ( QImage &  image,
QRect  rect,
int  radius,
bool  alphaOnly 
)
static

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

Definition at line 4275 of file qgssymbollayerutils.cpp.

◆ clearSymbolLayerIds() [1/2]

void QgsSymbolLayerUtils::clearSymbolLayerIds ( QgsSymbol symbol)
static

Remove recursively unique id from all symbol symbol layers and set an empty string instead.

Since
QGIS 3.30

Definition at line 5723 of file qgssymbollayerutils.cpp.

◆ clearSymbolLayerIds() [2/2]

void QgsSymbolLayerUtils::clearSymbolLayerIds ( QgsSymbolLayer symbolLayer)
static

Remove recursively unique id from symbolLayer and its children and set an empty string instead.

Since
QGIS 3.30

Definition at line 5728 of file qgssymbollayerutils.cpp.

◆ clearSymbolLayerMasks()

void QgsSymbolLayerUtils::clearSymbolLayerMasks ( QgsSymbol symbol)
static

Remove recursively masks from all symbol symbol layers.

Since
QGIS 3.42

Definition at line 5738 of file qgssymbollayerutils.cpp.

◆ clearSymbolMap()

void QgsSymbolLayerUtils::clearSymbolMap ( QgsSymbolMap symbols)
static

Definition at line 3486 of file qgssymbollayerutils.cpp.

◆ collectSymbolLayerClipGeometries()

QVector< QgsGeometry > QgsSymbolLayerUtils::collectSymbolLayerClipGeometries ( const QgsRenderContext context,
const QString &  symbolLayerId,
const QRectF &  bounds 
)
static

Returns a list of the symbol layer clip geometries to be used for the symbol layer with the specified ID.

The bounds argument specifies the target bounds (in painter coordinates) for matching geometries. Only mask geometries which intersect bounds will be returned. If bounds is a null QRectF then all clip geometries for the symbol layer will be returned.

Since
QGIS 3.38

Definition at line 5758 of file qgssymbollayerutils.cpp.

◆ colorFromMimeData()

QColor QgsSymbolLayerUtils::colorFromMimeData ( const QMimeData *  data,
bool &  hasAlpha 
)
static

Attempts to parse mime data as a color.

Parameters
datamime data to parse
hasAlphawill 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

Definition at line 3712 of file qgssymbollayerutils.cpp.

◆ colorListFromMimeData()

QgsNamedColorList QgsSymbolLayerUtils::colorListFromMimeData ( const QMimeData *  data)
static

Attempts to parse mime data as a list of named colors.

Parameters
datamime data to parse
Returns
list of parsed colors

Definition at line 3743 of file qgssymbollayerutils.cpp.

◆ colorListToMimeData()

QMimeData * QgsSymbolLayerUtils::colorListToMimeData ( const QgsNamedColorList colorList,
bool  allFormats = true 
)
static

Creates mime data from a list of named colors.

Parameters
colorListlist of named colors
allFormatsset to true to include additional mime formats, include text/plain and application/x-color
Returns
mime data containing encoded colors

Definition at line 3859 of file qgssymbollayerutils.cpp.

◆ colorRampPreviewIcon()

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

Returns an icon preview for a color ramp.

Parameters
rampcolor ramp
sizetarget icon size
paddingspace between icon edge and color ramp
See also
colorRampPreviewPixmap()

Definition at line 1088 of file qgssymbollayerutils.cpp.

◆ colorRampPreviewPixmap()

QPixmap QgsSymbolLayerUtils::colorRampPreviewPixmap ( QgsColorRamp ramp,
QSize  size,
int  padding = 0,
Qt::Orientation  direction = Qt::Horizontal,
bool  flipDirection = false,
bool  drawTransparentBackground = true 
)
static

Returns a pixmap preview for a color ramp.

Parameters
rampcolor ramp
sizetarget pixmap size
paddingspace between icon edge and color ramp
directiondirection to render pixmap (since QGIS 3.18)
flipDirectionset to true to flip the direction of the ramp. For horizontal directions, ramps will be rendered left to right by default. For vertical directions, ramps will be rendered top to bottom by default. Setting this flag to true will reverse these default directions.
drawTransparentBackgroundset to false to disable the checkerboard effect drawn below transparent colors in the ramp
See also
colorRampPreviewIcon()

Definition at line 1093 of file qgssymbollayerutils.cpp.

◆ colorRampToVariant()

QVariant QgsSymbolLayerUtils::colorRampToVariant ( const QString &  name,
QgsColorRamp ramp 
)
static

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( const QVariant &value )

Definition at line 3570 of file qgssymbollayerutils.cpp.

◆ colorToMimeData()

QMimeData * QgsSymbolLayerUtils::colorToMimeData ( const QColor &  color)
static

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
colorcolor to encode as mime data
See also
colorFromMimeData

Definition at line 3702 of file qgssymbollayerutils.cpp.

◆ colorToName()

QString QgsSymbolLayerUtils::colorToName ( const QColor &  color)
static

Returns a friendly display name for a color.

Parameters
colorsource color
Returns
display name for color

Definition at line 3621 of file qgssymbollayerutils.cpp.

◆ condenseFillAndOutline()

bool QgsSymbolLayerUtils::condenseFillAndOutline ( QgsFillSymbolLayer fill,
QgsLineSymbolLayer outline 
)
static

Attempts to condense a fill and outline layer, by moving the outline layer to the fill symbol's stroke.

This will only be done if the outline can be transformed into a stroke on the fill layer losslessly. If so, fill will be updated in place with the new stroke. Any existing stroke settings in fill will be replaced.

Returns true if the fill and outline were successfully condensed.

Since
QGIS 3.20

Definition at line 4372 of file qgssymbollayerutils.cpp.

◆ convertPolygonSymbolizerToPointMarker()

bool QgsSymbolLayerUtils::convertPolygonSymbolizerToPointMarker ( QDomElement &  element,
QList< QgsSymbolLayer * > &  layerList 
)
static

Converts a polygon symbolizer element to a list of marker symbol layers.

Definition at line 2017 of file qgssymbollayerutils.cpp.

◆ createAnchorPointElement()

void QgsSymbolLayerUtils::createAnchorPointElement ( QDomDocument &  doc,
QDomElement &  element,
QPointF  anchor 
)
static

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

Parameters
docThe document
elementThe parent element
anchorAn anchor specification, with values between 0 and 1

Definition at line 2951 of file qgssymbollayerutils.cpp.

◆ createDisplacementElement()

void QgsSymbolLayerUtils::createDisplacementElement ( QDomDocument &  doc,
QDomElement &  element,
QPointF  offset 
)
static

Definition at line 2933 of file qgssymbollayerutils.cpp.

◆ createExpressionElement() [1/2]

bool QgsSymbolLayerUtils::createExpressionElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  function 
)
static

Creates a OGC Expression element based on the provided function expression.

Parameters
docThe document owning the element
elementThe element parent
functionThe expression to be encoded
Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 3163 of file qgssymbollayerutils.cpp.

◆ createExpressionElement() [2/2]

bool QgsSymbolLayerUtils::createExpressionElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  function,
QgsSldExportContext context 
)
static

Creates a OGC Expression element based on the provided function expression.

Parameters
docThe document owning the element
elementThe element parent
functionThe expression to be encoded
contextexport context
Since
QGIS 3.44

Definition at line 3169 of file qgssymbollayerutils.cpp.

◆ createFillLayerFromSld()

std::unique_ptr< QgsSymbolLayer > QgsSymbolLayerUtils::createFillLayerFromSld ( QDomElement &  element)
static

Creates a new fill layer from a SLD DOM element.

Definition at line 1730 of file qgssymbollayerutils.cpp.

◆ createFunctionElement() [1/2]

bool QgsSymbolLayerUtils::createFunctionElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  function 
)
static

Creates an OGC function element.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 3184 of file qgssymbollayerutils.cpp.

◆ createFunctionElement() [2/2]

bool QgsSymbolLayerUtils::createFunctionElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  function,
QgsSldExportContext context 
)
static

Creates an OGC function element.

Since
QGIS 3.44

Definition at line 3190 of file qgssymbollayerutils.cpp.

◆ createGeometryElement() [1/2]

void QgsSymbolLayerUtils::createGeometryElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  geomFunc 
)
static

Creates an SLD geometry element.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 3114 of file qgssymbollayerutils.cpp.

◆ createGeometryElement() [2/2]

void QgsSymbolLayerUtils::createGeometryElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  geomFunc,
QgsSldExportContext context 
)
static

Creates an SLD geometry element.

Since
QGIS 3.44

Definition at line 3120 of file qgssymbollayerutils.cpp.

◆ createLineLayerFromSld()

std::unique_ptr< QgsSymbolLayer > QgsSymbolLayerUtils::createLineLayerFromSld ( QDomElement &  element)
static

Creates a new line layer from a SLD DOM element.

Definition at line 1755 of file qgssymbollayerutils.cpp.

◆ createMarkerLayerFromSld()

std::unique_ptr< QgsSymbolLayer > QgsSymbolLayerUtils::createMarkerLayerFromSld ( QDomElement &  element)
static

Creates a new marker layer from a SLD DOM element.

Definition at line 1774 of file qgssymbollayerutils.cpp.

◆ createOnlineResourceElement()

void QgsSymbolLayerUtils::createOnlineResourceElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  path,
const QString &  format 
)
static

Definition at line 3252 of file qgssymbollayerutils.cpp.

◆ createOpacityElement() [1/2]

void QgsSymbolLayerUtils::createOpacityElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  alphaFunc 
)
static

Creates SLD opacity element.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 2907 of file qgssymbollayerutils.cpp.

◆ createOpacityElement() [2/2]

void QgsSymbolLayerUtils::createOpacityElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  alphaFunc,
QgsSldExportContext context 
)
static

Creates SLD opacity element.

Since
QGIS 3.44

Definition at line 2913 of file qgssymbollayerutils.cpp.

◆ createRotationElement() [1/2]

void QgsSymbolLayerUtils::createRotationElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  rotationFunc 
)
static

Creates SLD rotation element.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 2881 of file qgssymbollayerutils.cpp.

◆ createRotationElement() [2/2]

void QgsSymbolLayerUtils::createRotationElement ( QDomDocument &  doc,
QDomElement &  element,
const QString &  rotationFunc,
QgsSldExportContext context 
)
static

Creates SLD rotation element.

Since
QGIS 3.44

Definition at line 2887 of file qgssymbollayerutils.cpp.

◆ createSvgParameterElement()

QDomElement QgsSymbolLayerUtils::createSvgParameterElement ( QDomDocument &  doc,
const QString &  name,
const QString &  value 
)
static

Definition at line 3286 of file qgssymbollayerutils.cpp.

◆ createSymbolLayerListFromSld()

bool QgsSymbolLayerUtils::createSymbolLayerListFromSld ( QDomElement &  element,
Qgis::GeometryType  geomType,
QList< QgsSymbolLayer * > &  layers 
)
static

Creates a symbol layer list from a DOM element.

Definition at line 1565 of file qgssymbollayerutils.cpp.

◆ createVendorOptionElement()

QDomElement QgsSymbolLayerUtils::createVendorOptionElement ( QDomDocument &  doc,
const QString &  name,
const QString &  value 
)
static

Definition at line 3333 of file qgssymbollayerutils.cpp.

◆ decodeArrowHeadType()

QgsArrowSymbolLayer::HeadType QgsSymbolLayerUtils::decodeArrowHeadType ( const QVariant &  value,
bool *  ok = nullptr 
)
static

Decodes a value representing an arrow head type.

Since
QGIS 3.2

Definition at line 474 of file qgssymbollayerutils.cpp.

◆ decodeArrowType()

QgsArrowSymbolLayer::ArrowType QgsSymbolLayerUtils::decodeArrowType ( const QVariant &  value,
bool *  ok = nullptr 
)
static

Decodes a value representing an arrow type.

Since
QGIS 3.2

Definition at line 499 of file qgssymbollayerutils.cpp.

◆ decodeBlendMode()

QPainter::CompositionMode QgsSymbolLayerUtils::decodeBlendMode ( const QString &  s)
static

Definition at line 908 of file qgssymbollayerutils.cpp.

◆ decodeBrushStyle()

Qt::BrushStyle QgsSymbolLayerUtils::decodeBrushStyle ( const QString &  str)
static

Definition at line 324 of file qgssymbollayerutils.cpp.

◆ decodeColor()

QColor QgsSymbolLayerUtils::decodeColor ( const QString &  str)
static

Definition at line 73 of file qgssymbollayerutils.cpp.

◆ decodeCoordinateReference()

Qgis::SymbolCoordinateReference QgsSymbolLayerUtils::decodeCoordinateReference ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a string representing a symbol coordinate reference mode.

Parameters
stringstring to decode
okwill be set to true if string was successfully decoded
Returns
decoded marker clip mode
See also
encodeCoordinateReference()
Since
QGIS 3.24

Definition at line 446 of file qgssymbollayerutils.cpp.

◆ decodeLineClipMode()

Qgis::LineClipMode QgsSymbolLayerUtils::decodeLineClipMode ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a string representing a line clip mode.

Parameters
stringstring to decode
okwill be set to true if string was successfully decoded
Returns
decoded line clip mode
See also
encodeLineClipMode()
Since
QGIS 3.24

Definition at line 560 of file qgssymbollayerutils.cpp.

◆ decodeMapUnitScale()

QgsMapUnitScale QgsSymbolLayerUtils::decodeMapUnitScale ( const QString &  str)
static

Definition at line 730 of file qgssymbollayerutils.cpp.

◆ decodeMarkerClipMode()

Qgis::MarkerClipMode QgsSymbolLayerUtils::decodeMarkerClipMode ( const QString &  string,
bool *  ok = nullptr 
)
static

Decodes a string representing a marker clip mode.

Parameters
stringstring to decode
okwill be set to true if string was successfully decoded
Returns
decoded marker clip mode
See also
encodeMarkerClipMode()
Since
QGIS 3.24

Definition at line 524 of file qgssymbollayerutils.cpp.

◆ decodePenCapStyle()

Qt::PenCapStyle QgsSymbolLayerUtils::decodePenCapStyle ( const QString &  str)
static

Definition at line 254 of file qgssymbollayerutils.cpp.

◆ decodePenJoinStyle()

Qt::PenJoinStyle QgsSymbolLayerUtils::decodePenJoinStyle ( const QString &  str)
static

Definition at line 204 of file qgssymbollayerutils.cpp.

◆ decodePenStyle()

Qt::PenStyle QgsSymbolLayerUtils::decodePenStyle ( const QString &  str)
static

Definition at line 178 of file qgssymbollayerutils.cpp.

◆ decodePoint()

QPointF QgsSymbolLayerUtils::decodePoint ( const QString &  string)
static

Decodes a QSizeF from a string.

See also
encodePoint()
decodeSize()

Definition at line 597 of file qgssymbollayerutils.cpp.

◆ decodeRealVector()

QVector< qreal > QgsSymbolLayerUtils::decodeRealVector ( const QString &  s)
static

Definition at line 833 of file qgssymbollayerutils.cpp.

◆ decodeScaleMethod()

Qgis::ScaleMethod QgsSymbolLayerUtils::decodeScaleMethod ( const QString &  str)
static

Decodes a symbol scale method from a string.

See also
encodeScaleMethod()

Definition at line 892 of file qgssymbollayerutils.cpp.

◆ decodeSize()

QSizeF QgsSymbolLayerUtils::decodeSize ( const QString &  string)
static

Decodes a QSizeF from a string.

See also
encodeSize()
decodePoint()

Definition at line 661 of file qgssymbollayerutils.cpp.

◆ decodeSldAlpha()

int QgsSymbolLayerUtils::decodeSldAlpha ( const QString &  str)
static

Definition at line 97 of file qgssymbollayerutils.cpp.

◆ decodeSldBrushStyle()

Qt::BrushStyle QgsSymbolLayerUtils::decodeSldBrushStyle ( const QString &  str)
static

Definition at line 381 of file qgssymbollayerutils.cpp.

◆ decodeSldFontStyle()

QFont::Style QgsSymbolLayerUtils::decodeSldFontStyle ( const QString &  str)
static

Definition at line 123 of file qgssymbollayerutils.cpp.

◆ decodeSldFontWeight()

int QgsSymbolLayerUtils::decodeSldFontWeight ( const QString &  str)
static

Definition at line 143 of file qgssymbollayerutils.cpp.

◆ decodeSldLineCapStyle()

Qt::PenCapStyle QgsSymbolLayerUtils::decodeSldLineCapStyle ( const QString &  str)
static

Definition at line 277 of file qgssymbollayerutils.cpp.

◆ decodeSldLineJoinStyle()

Qt::PenJoinStyle QgsSymbolLayerUtils::decodeSldLineJoinStyle ( const QString &  str)
static

Definition at line 231 of file qgssymbollayerutils.cpp.

◆ decodeSldRealVector()

QVector< qreal > QgsSymbolLayerUtils::decodeSldRealVector ( const QString &  s)
static

Definition at line 862 of file qgssymbollayerutils.cpp.

◆ decodeSldUom()

Qgis::RenderUnit QgsSymbolLayerUtils::decodeSldUom ( const QString &  str,
double *  scaleFactor = nullptr 
)
static

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

Parameters
strstring to decode
scaleFactorif specified, will be set to scale factor for unit of measure
Returns
matching render unit
See also
encodeSldUom()

Definition at line 794 of file qgssymbollayerutils.cpp.

◆ displacementFromSldElement()

bool QgsSymbolLayerUtils::displacementFromSldElement ( QDomElement &  element,
QPointF &  offset 
)
static

Definition at line 2968 of file qgssymbollayerutils.cpp.

◆ drawStippledBackground()

void QgsSymbolLayerUtils::drawStippledBackground ( QPainter *  painter,
QRect  rect 
)
static

Definition at line 1138 of file qgssymbollayerutils.cpp.

◆ drawVertexMarker()

void QgsSymbolLayerUtils::drawVertexMarker ( double  x,
double  y,
QPainter &  p,
Qgis::VertexMarkerType  type,
int  markerSize 
)
static

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

(Useful to assist vertex editing.)

Since
QGIS 3.4.5

Definition at line 1157 of file qgssymbollayerutils.cpp.

◆ encodeBrushStyle()

QString QgsSymbolLayerUtils::encodeBrushStyle ( Qt::BrushStyle  style)
static

Definition at line 285 of file qgssymbollayerutils.cpp.

◆ encodeColor()

QString QgsSymbolLayerUtils::encodeColor ( const QColor &  color)
static

Definition at line 68 of file qgssymbollayerutils.cpp.

◆ encodeCoordinateReference()

QString QgsSymbolLayerUtils::encodeCoordinateReference ( Qgis::SymbolCoordinateReference  coordinateReference)
static

Encodes a symbol coordinate reference mode to a string.

Parameters
coordinateReferencecoordinate reference mode
See also
decodeCoordinateReference()
Since
QGIS 3.24

Definition at line 462 of file qgssymbollayerutils.cpp.

◆ encodeLineClipMode()

QString QgsSymbolLayerUtils::encodeLineClipMode ( Qgis::LineClipMode  mode)
static

Encodes a line clip mode to a string.

See also
decodeLineClipMode()
Since
QGIS 3.24

Definition at line 578 of file qgssymbollayerutils.cpp.

◆ encodeMapUnitScale()

QString QgsSymbolLayerUtils::encodeMapUnitScale ( const QgsMapUnitScale mapUnitScale)
static

Definition at line 720 of file qgssymbollayerutils.cpp.

◆ encodeMarkerClipMode()

QString QgsSymbolLayerUtils::encodeMarkerClipMode ( Qgis::MarkerClipMode  mode)
static

Encodes a marker clip mode to a string.

See also
decodeMarkerClipMode()
Since
QGIS 3.24

Definition at line 544 of file qgssymbollayerutils.cpp.

◆ encodePenCapStyle()

QString QgsSymbolLayerUtils::encodePenCapStyle ( Qt::PenCapStyle  style)
static

Definition at line 239 of file qgssymbollayerutils.cpp.

◆ encodePenJoinStyle()

QString QgsSymbolLayerUtils::encodePenJoinStyle ( Qt::PenJoinStyle  style)
static

Definition at line 189 of file qgssymbollayerutils.cpp.

◆ encodePenStyle()

QString QgsSymbolLayerUtils::encodePenStyle ( Qt::PenStyle  style)
static

Definition at line 157 of file qgssymbollayerutils.cpp.

◆ encodePoint()

QString QgsSymbolLayerUtils::encodePoint ( QPointF  point)
static

Encodes a QPointF to a string.

See also
decodePoint()
encodeSize()

Definition at line 592 of file qgssymbollayerutils.cpp.

◆ encodeRealVector()

QString QgsSymbolLayerUtils::encodeRealVector ( const QVector< qreal > &  v)
static

Definition at line 818 of file qgssymbollayerutils.cpp.

◆ encodeScaleMethod()

QString QgsSymbolLayerUtils::encodeScaleMethod ( Qgis::ScaleMethod  scaleMethod)
static

Encodes a symbol scale method to a string.

See also
decodeScaleMethod()

Definition at line 876 of file qgssymbollayerutils.cpp.

◆ encodeSize()

QString QgsSymbolLayerUtils::encodeSize ( QSizeF  size)
static

Encodes a QSizeF to a string.

See also
decodeSize()
encodePoint()

Definition at line 656 of file qgssymbollayerutils.cpp.

◆ encodeSldAlpha()

QString QgsSymbolLayerUtils::encodeSldAlpha ( int  alpha)
static

Definition at line 92 of file qgssymbollayerutils.cpp.

◆ encodeSldBrushStyle()

QString QgsSymbolLayerUtils::encodeSldBrushStyle ( Qt::BrushStyle  style)
static

Definition at line 344 of file qgssymbollayerutils.cpp.

◆ encodeSldFontStyle()

QString QgsSymbolLayerUtils::encodeSldFontStyle ( QFont::Style  style)
static

Definition at line 108 of file qgssymbollayerutils.cpp.

◆ encodeSldFontWeight()

QString QgsSymbolLayerUtils::encodeSldFontWeight ( int  weight)
static

Definition at line 131 of file qgssymbollayerutils.cpp.

◆ encodeSldLineCapStyle()

QString QgsSymbolLayerUtils::encodeSldLineCapStyle ( Qt::PenCapStyle  style)
static

Definition at line 262 of file qgssymbollayerutils.cpp.

◆ encodeSldLineJoinStyle()

QString QgsSymbolLayerUtils::encodeSldLineJoinStyle ( Qt::PenJoinStyle  style)
static

Definition at line 216 of file qgssymbollayerutils.cpp.

◆ encodeSldRealVector()

QString QgsSymbolLayerUtils::encodeSldRealVector ( const QVector< qreal > &  v)
static

Definition at line 847 of file qgssymbollayerutils.cpp.

◆ encodeSldUom()

QString QgsSymbolLayerUtils::encodeSldUom ( Qgis::RenderUnit  unit,
double *  scaleFactor 
)
static

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

Parameters
unitunit to encode
scaleFactorif specified, will be set to scale factor for unit of measure
Returns
encoded string
See also
decodeSldUom()

Definition at line 768 of file qgssymbollayerutils.cpp.

◆ estimateMaxSymbolBleed()

double QgsSymbolLayerUtils::estimateMaxSymbolBleed ( QgsSymbol symbol,
const QgsRenderContext context 
)
static

Returns the maximum estimated bleed for the symbol.

Definition at line 992 of file qgssymbollayerutils.cpp.

◆ evaluatePropertiesMap()

QgsStringMap QgsSymbolLayerUtils::evaluatePropertiesMap ( const QMap< QString, QgsProperty > &  propertiesMap,
const QgsExpressionContext context 
)
static

Evaluates a map of properties using the given context and returns a variant map with evaluated expressions from the properties.

Since
QGIS 3.18

Definition at line 5458 of file qgssymbollayerutils.cpp.

◆ externalGraphicFromSld()

bool QgsSymbolLayerUtils::externalGraphicFromSld ( QDomElement &  element,
QString &  path,
QString &  mime,
QColor &  color,
double &  size 
)
static

Definition at line 2687 of file qgssymbollayerutils.cpp.

◆ externalGraphicToSld()

void QgsSymbolLayerUtils::externalGraphicToSld ( QDomDocument &  doc,
QDomElement &  element,
const QString &  path,
const QString &  mime,
const QColor &  color,
double  size = -1 
)
static

Definition at line 2599 of file qgssymbollayerutils.cpp.

◆ externalMarkerFromSld()

bool QgsSymbolLayerUtils::externalMarkerFromSld ( QDomElement &  element,
QString &  path,
QString &  format,
int &  markIndex,
QColor &  color,
double &  size 
)
static

Definition at line 2748 of file qgssymbollayerutils.cpp.

◆ externalMarkerToSld() [1/2]

void QgsSymbolLayerUtils::externalMarkerToSld ( QDomDocument &  doc,
QDomElement &  element,
const QString &  path,
const QString &  format,
int *  markIndex = nullptr,
const QColor &  color = QColor(),
double  size = -1 
)
static

Exports a marker to an SLD definition.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 2712 of file qgssymbollayerutils.cpp.

◆ externalMarkerToSld() [2/2]

void QgsSymbolLayerUtils::externalMarkerToSld ( QDomDocument &  doc,
QDomElement &  element,
const QString &  path,
const QString &  format,
QgsSldExportContext context,
int *  markIndex = nullptr,
const QColor &  color = QColor(),
double  size = -1 
)
static

Exports a marker to an SLD definition.

Since
QGIS 3.44

Definition at line 2720 of file qgssymbollayerutils.cpp.

◆ fieldOrExpressionFromExpression()

QString QgsSymbolLayerUtils::fieldOrExpressionFromExpression ( QgsExpression expression)
static

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.

Definition at line 4925 of file qgssymbollayerutils.cpp.

◆ fieldOrExpressionToExpression()

std::unique_ptr< QgsExpression > QgsSymbolLayerUtils::fieldOrExpressionToExpression ( const QString &  fieldOrExpression)
static

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 nullptr. This is useful when accepting input which could be either a non-quoted field name or expression.

Definition at line 4910 of file qgssymbollayerutils.cpp.

◆ fillFromSld()

bool QgsSymbolLayerUtils::fillFromSld ( QDomElement &  element,
Qt::BrushStyle &  brushStyle,
QColor &  color 
)
static

Definition at line 2330 of file qgssymbollayerutils.cpp.

◆ fillToSld() [1/2]

void QgsSymbolLayerUtils::fillToSld ( QDomDocument &  doc,
QDomElement &  element,
QgsSldExportContext context,
Qt::BrushStyle  brushStyle,
const QColor &  color = QColor() 
)
static

Exports fill details to an SLD element.

Since
QGIS 3.44

Definition at line 2279 of file qgssymbollayerutils.cpp.

◆ fillToSld() [2/2]

void QgsSymbolLayerUtils::fillToSld ( QDomDocument &  doc,
QDomElement &  element,
Qt::BrushStyle  brushStyle,
const QColor &  color = QColor() 
)
static

Exports fill details to an SLD element.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 2273 of file qgssymbollayerutils.cpp.

◆ functionFromSldElement()

bool QgsSymbolLayerUtils::functionFromSldElement ( QDomElement &  element,
QString &  function 
)
static

Definition at line 3215 of file qgssymbollayerutils.cpp.

◆ geometryFromSldElement()

bool QgsSymbolLayerUtils::geometryFromSldElement ( QDomElement &  element,
QString &  geomFunc 
)
static

Definition at line 3154 of file qgssymbollayerutils.cpp.

◆ getSvgParameterList()

QgsStringMap QgsSymbolLayerUtils::getSvgParameterList ( QDomElement &  element)
static

Definition at line 3294 of file qgssymbollayerutils.cpp.

◆ getSvgParametricPath()

QString QgsSymbolLayerUtils::getSvgParametricPath ( const QString &  basePath,
const QColor &  fillColor,
const QColor &  strokeColor,
double  strokeWidth 
)
static

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

Definition at line 2652 of file qgssymbollayerutils.cpp.

◆ getVendorOptionList()

QgsStringMap QgsSymbolLayerUtils::getVendorOptionList ( QDomElement &  element)
static

Definition at line 3341 of file qgssymbollayerutils.cpp.

◆ hasExternalGraphic()

bool QgsSymbolLayerUtils::hasExternalGraphic ( QDomElement &  element)
static

Checks if element contains an ExternalGraphic element with format "image/svg+xml".

Returns
true if the ExternalGraphic with format "image/svg+xml" is found .

Definition at line 1797 of file qgssymbollayerutils.cpp.

◆ hasExternalGraphicV2()

bool QgsSymbolLayerUtils::hasExternalGraphicV2 ( QDomElement &  element,
const QString  format = QString() 
)
static

Checks if element contains an ExternalGraphic element, if the optional format is specified it will also be checked.

Returns
true if the ExternalGraphic element is found and the optionally specified format matches.
Since
QGIS 3.30

Definition at line 1802 of file qgssymbollayerutils.cpp.

◆ hasSldSymbolizer()

bool QgsSymbolLayerUtils::hasSldSymbolizer ( const QDomElement &  element)
static

Returns true if a DOM element contains an SLD Symbolizer element.

Since
QGIS 3.42

Definition at line 432 of file qgssymbollayerutils.cpp.

◆ hasWellKnownMark()

bool QgsSymbolLayerUtils::hasWellKnownMark ( QDomElement &  element)
static

Definition at line 1843 of file qgssymbollayerutils.cpp.

◆ importColorsFromGpl()

QgsNamedColorList QgsSymbolLayerUtils::importColorsFromGpl ( QFile &  file,
bool &  ok,
QString &  name 
)
static

Imports colors from a gpl GIMP palette file.

Parameters
filesource gpl file
okwill be true if file was successfully read
namewill be set to palette name from gpl file, if present
Returns
list of imported colors
See also
saveColorsToGpl

Definition at line 3939 of file qgssymbollayerutils.cpp.

◆ isSharpCorner()

bool QgsSymbolLayerUtils::isSharpCorner ( QPointF  p1,
QPointF  p2,
QPointF  p3 
)
static

Returns true if the angle formed by the line p1 - p2 - p3 forms a "sharp" corner.

Sharp corners form an angle which exceeds a 45 degree threshold.

Since
QGIS 3.16

Definition at line 4889 of file qgssymbollayerutils.cpp.

◆ labelTextToSld() [1/2]

void QgsSymbolLayerUtils::labelTextToSld ( QDomDocument &  doc,
QDomElement &  element,
const QString &  label,
const QFont &  font,
const QColor &  color = QColor(),
double  size = -1 
)
static

Exports label text to SLD.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 2997 of file qgssymbollayerutils.cpp.

◆ labelTextToSld() [2/2]

void QgsSymbolLayerUtils::labelTextToSld ( QDomDocument &  doc,
QDomElement &  element,
const QString &  label,
const QFont &  font,
QgsSldExportContext context,
const QColor &  color = QColor(),
double  size = -1 
)
static

Exports label text to SLD.

Since
QGIS 3.44

Definition at line 3005 of file qgssymbollayerutils.cpp.

◆ lineFromSld()

bool QgsSymbolLayerUtils::lineFromSld ( QDomElement &  element,
Qt::PenStyle &  penStyle,
QColor &  color,
double &  width,
Qt::PenJoinStyle *  penJoinStyle = nullptr,
Qt::PenCapStyle *  penCapStyle = nullptr,
QVector< qreal > *  customDashPattern = nullptr,
double *  dashOffset = nullptr 
)
static

Definition at line 2468 of file qgssymbollayerutils.cpp.

◆ lineToSld()

void QgsSymbolLayerUtils::lineToSld ( QDomDocument &  doc,
QDomElement &  element,
Qt::PenStyle  penStyle,
const QColor &  color,
QgsSldExportContext context,
double  width = -1,
const Qt::PenJoinStyle *  penJoinStyle = nullptr,
const Qt::PenCapStyle *  penCapStyle = nullptr,
const QVector< qreal > *  customDashPattern = nullptr,
double  dashOffset = 0.0 
)
static
Note
not available in Python bindings

Definition at line 2384 of file qgssymbollayerutils.cpp.

◆ listSvgFiles()

QStringList QgsSymbolLayerUtils::listSvgFiles ( )
static

Returns a list of all available svg files.

Definition at line 4441 of file qgssymbollayerutils.cpp.

◆ listSvgFilesAt()

QStringList QgsSymbolLayerUtils::listSvgFilesAt ( const QString &  directory)
static

Returns a list of svg files at the specified directory.

Definition at line 4467 of file qgssymbollayerutils.cpp.

◆ loadColorRamp() [1/2]

std::unique_ptr< QgsColorRamp > QgsSymbolLayerUtils::loadColorRamp ( const QVariant &  value)
static

Load a color ramp from a QVariantMap, wrapped in a QVariant.

You can use QgsXmlUtils::readVariant to load it from an XML document.

See also
colorRampToVariant()

Definition at line 3589 of file qgssymbollayerutils.cpp.

◆ loadColorRamp() [2/2]

std::unique_ptr< QgsColorRamp > QgsSymbolLayerUtils::loadColorRamp ( QDomElement &  element)
static

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

Parameters
elementDOM element
Returns
new color ramp. Caller takes responsibility for deleting the returned value.
See also
saveColorRamp()

Definition at line 3535 of file qgssymbollayerutils.cpp.

◆ loadSymbol() [1/2]

std::unique_ptr< QgsSymbol > QgsSymbolLayerUtils::loadSymbol ( const QDomElement &  element,
const QgsReadWriteContext context 
)
static

Attempts to load a symbol from a DOM element.

Parameters
elementDOM element representing symbol
contextobject to transform relative to absolute paths
Returns
decoded symbol, if possible

Definition at line 1281 of file qgssymbollayerutils.cpp.

◆ loadSymbol() [2/2]

template<class SymbolType >
static std::unique_ptr< SymbolType > QgsSymbolLayerUtils::loadSymbol ( const QDomElement &  element,
const QgsReadWriteContext context 
)
inlinestatic

Attempts to load a symbol from a DOM element and cast it to a particular symbol type.

Parameters
elementDOM element representing symbol
contextobject to transform relative to absolute paths
Returns
decoded symbol cast to specified type, if possible
Note
not available in Python bindings

Definition at line 403 of file qgssymbollayerutils.h.

◆ loadSymbolLayer()

std::unique_ptr< QgsSymbolLayer > QgsSymbolLayerUtils::loadSymbolLayer ( QDomElement &  element,
const QgsReadWriteContext context 
)
static

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

Definition at line 1408 of file qgssymbollayerutils.cpp.

◆ loadSymbols()

QgsSymbolMap QgsSymbolLayerUtils::loadSymbols ( QDomElement &  element,
const QgsReadWriteContext context 
)
static

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

Definition at line 3394 of file qgssymbollayerutils.cpp.

◆ mergeScaleDependencies()

void QgsSymbolLayerUtils::mergeScaleDependencies ( double  mScaleMinDenom,
double  mScaleMaxDenom,
QVariantMap &  props 
)
static

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

Definition at line 5209 of file qgssymbollayerutils.cpp.

◆ multiplyImageOpacity()

void QgsSymbolLayerUtils::multiplyImageOpacity ( QImage *  image,
qreal  opacity 
)
static

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

Definition at line 4245 of file qgssymbollayerutils.cpp.

◆ needEllipseMarker()

bool QgsSymbolLayerUtils::needEllipseMarker ( QDomElement &  element)
static

Definition at line 1903 of file qgssymbollayerutils.cpp.

◆ needFontMarker()

bool QgsSymbolLayerUtils::needFontMarker ( QDomElement &  element)
static

Definition at line 1858 of file qgssymbollayerutils.cpp.

◆ needLinePatternFill()

bool QgsSymbolLayerUtils::needLinePatternFill ( QDomElement &  element)
static

Definition at line 1934 of file qgssymbollayerutils.cpp.

◆ needMarkerLine()

bool QgsSymbolLayerUtils::needMarkerLine ( QDomElement &  element)
static

Definition at line 1921 of file qgssymbollayerutils.cpp.

◆ needPointPatternFill()

bool QgsSymbolLayerUtils::needPointPatternFill ( QDomElement &  element)
static

Definition at line 1969 of file qgssymbollayerutils.cpp.

◆ needRasterImageFill()

bool QgsSymbolLayerUtils::needRasterImageFill ( QDomElement &  element)
static

Checks if element contains a graphic fill with a raster image of type PNG, JPEG or GIF.

Returns
true if element contains a graphic fill with a raster image.
Since
QGIS 3.30

Definition at line 2003 of file qgssymbollayerutils.cpp.

◆ needSvgFill()

bool QgsSymbolLayerUtils::needSvgFill ( QDomElement &  element)
static

Definition at line 1990 of file qgssymbollayerutils.cpp.

◆ needSvgMarker()

bool QgsSymbolLayerUtils::needSvgMarker ( QDomElement &  element)
static

Definition at line 1898 of file qgssymbollayerutils.cpp.

◆ ogrFeatureStyleBrush()

QString QgsSymbolLayerUtils::ogrFeatureStyleBrush ( const QColor &  fillColr)
static

Create ogr feature style string for brush.

Parameters
fillColrfill color

Definition at line 3104 of file qgssymbollayerutils.cpp.

◆ ogrFeatureStylePen()

QString QgsSymbolLayerUtils::ogrFeatureStylePen ( double  width,
double  mmScaleFactor,
double  mapUnitsScaleFactor,
const QColor &  c,
Qt::PenJoinStyle  joinStyle = Qt::MiterJoin,
Qt::PenCapStyle  capStyle = Qt::FlatCap,
double  offset = 0.0,
const QVector< qreal > *  dashPattern = nullptr 
)
static

Create ogr feature style string for pen.

Definition at line 3030 of file qgssymbollayerutils.cpp.

◆ onlineResourceFromSldElement()

bool QgsSymbolLayerUtils::onlineResourceFromSldElement ( QDomElement &  element,
QString &  path,
QString &  format 
)
static

Definition at line 3267 of file qgssymbollayerutils.cpp.

◆ opacityFromSldElement()

bool QgsSymbolLayerUtils::opacityFromSldElement ( QDomElement &  element,
QString &  alphaFunc 
)
static

Definition at line 2923 of file qgssymbollayerutils.cpp.

◆ parametricSvgToSld() [1/2]

void QgsSymbolLayerUtils::parametricSvgToSld ( QDomDocument &  doc,
QDomElement &  graphicElem,
const QString &  path,
const QColor &  fillColor,
double  size,
const QColor &  strokeColor,
double  strokeWidth 
)
static

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.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 2619 of file qgssymbollayerutils.cpp.

◆ parametricSvgToSld() [2/2]

void QgsSymbolLayerUtils::parametricSvgToSld ( QDomDocument &  doc,
QDomElement &  graphicElem,
const QString &  path,
const QColor &  fillColor,
double  size,
const QColor &  strokeColor,
double  strokeWidth,
QgsSldExportContext context 
)
static

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.

Since
QGIS 3.44

Definition at line 2626 of file qgssymbollayerutils.cpp.

◆ parseColor()

QColor QgsSymbolLayerUtils::parseColor ( const QString &  colorStr,
bool  strictEval = false 
)
static

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

Parameters
colorStrstring representing the color
strictEvalset to true for stricter color parsing rules
Returns
parsed color

Definition at line 4025 of file qgssymbollayerutils.cpp.

◆ parseColorList()

QList< QColor > QgsSymbolLayerUtils::parseColorList ( const QString &  colorStr)
static

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

Parameters
colorStrstring representing the color list
Returns
list of parsed colors

Definition at line 3633 of file qgssymbollayerutils.cpp.

◆ parseColorWithAlpha()

QColor QgsSymbolLayerUtils::parseColorWithAlpha ( const QString &  colorStr,
bool &  containsAlpha,
bool  strictEval = false 
)
static

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

Parameters
colorStrstring representing the color
containsAlphaif colorStr contains an explicit alpha value then containsAlpha will be set to true
strictEvalset to true for stricter color parsing rules
Returns
parsed color

Definition at line 4031 of file qgssymbollayerutils.cpp.

◆ parseProperties()

QVariantMap QgsSymbolLayerUtils::parseProperties ( const QDomElement &  element)
static

Parses the properties from XML and returns a map.

Definition at line 3361 of file qgssymbollayerutils.cpp.

◆ penCapStyleToEndCapStyle()

Qgis::EndCapStyle QgsSymbolLayerUtils::penCapStyleToEndCapStyle ( Qt::PenCapStyle  style)
static

Converts a Qt pen cap style to a QGIS end cap style.

Since
QGIS 3.42

Definition at line 396 of file qgssymbollayerutils.cpp.

◆ penJoinStyleToJoinStyle()

Qgis::JoinStyle QgsSymbolLayerUtils::penJoinStyleToJoinStyle ( Qt::PenJoinStyle  style)
static

Converts a Qt pen joinstyle to a QGIS join style.

Since
QGIS 3.42

Definition at line 414 of file qgssymbollayerutils.cpp.

◆ pointInPolygon()

bool QgsSymbolLayerUtils::pointInPolygon ( const QPolygonF &  points,
QPointF  point 
)
static

Calculate whether a point is within of a QPolygonF.

Definition at line 4762 of file qgssymbollayerutils.cpp.

◆ pointOnLineWithDistance()

QPointF QgsSymbolLayerUtils::pointOnLineWithDistance ( QPointF  startPoint,
QPointF  directionPoint,
double  distance 
)
static

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

Definition at line 4431 of file qgssymbollayerutils.cpp.

◆ polygonCentroid()

QPointF QgsSymbolLayerUtils::polygonCentroid ( const QPolygonF &  points)
static

Calculate the centroid point of a QPolygonF.

Definition at line 4694 of file qgssymbollayerutils.cpp.

◆ polygonPointOnSurface()

QPointF QgsSymbolLayerUtils::polygonPointOnSurface ( const QPolygonF &  points,
const QVector< QPolygonF > *  rings = nullptr 
)
static

Calculate a point on the surface of a QPolygonF.

Definition at line 4726 of file qgssymbollayerutils.cpp.

◆ polylineLength()

double QgsSymbolLayerUtils::polylineLength ( const QPolygonF &  polyline)
static

Returns the total length of a polyline.

Since
QGIS 3.20

Definition at line 4788 of file qgssymbollayerutils.cpp.

◆ polylineSubstring()

QPolygonF QgsSymbolLayerUtils::polylineSubstring ( const QPolygonF &  polyline,
double  startOffset,
double  endOffset 
)
static

Returns the substring of a polyline which starts at startOffset from the beginning of the line and ends at endOffset from the start of the line.

If startOffset is less than 0, then the start point will be calculated by subtracting that distance from the end of the line. Similarly, if endOffset is less than zero then the end point will be subtracted from the end of the line.

May return an empty linestring if the substring is zero length.

Since
QGIS 3.16

Definition at line 4806 of file qgssymbollayerutils.cpp.

◆ premultiplyColor()

void QgsSymbolLayerUtils::premultiplyColor ( QColor &  rgb,
int  alpha 
)
static

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

Definition at line 4351 of file qgssymbollayerutils.cpp.

◆ prettyBreaks()

QList< double > QgsSymbolLayerUtils::prettyBreaks ( double  minimum,
double  maximum,
int  classes 
)
static

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.

Definition at line 4935 of file qgssymbollayerutils.cpp.

◆ rendererFrameRate()

double QgsSymbolLayerUtils::rendererFrameRate ( const QgsFeatureRenderer renderer)
static

Calculates the frame rate (in frames per second) at which the given renderer must be redrawn.

Returns -1 if the renderer is not animated.

Since
QGIS 3.26

Definition at line 5316 of file qgssymbollayerutils.cpp.

◆ rescaleUom() [1/3]

QVector< qreal > QgsSymbolLayerUtils::rescaleUom ( const QVector< qreal > &  array,
Qgis::RenderUnit  unit,
const QVariantMap &  props 
)
static

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

Definition at line 5181 of file qgssymbollayerutils.cpp.

◆ rescaleUom() [2/3]

double QgsSymbolLayerUtils::rescaleUom ( double  size,
Qgis::RenderUnit  unit,
const QVariantMap &  props 
)
static

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

Definition at line 5097 of file qgssymbollayerutils.cpp.

◆ rescaleUom() [3/3]

QPointF QgsSymbolLayerUtils::rescaleUom ( QPointF  point,
Qgis::RenderUnit  unit,
const QVariantMap &  props 
)
static

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

Definition at line 5174 of file qgssymbollayerutils.cpp.

◆ resetSymbolLayerIds() [1/2]

void QgsSymbolLayerUtils::resetSymbolLayerIds ( QgsSymbol symbol)
static

Regenerate recursively unique id from all symbol symbol layers.

Since
QGIS 3.30

Definition at line 5778 of file qgssymbollayerutils.cpp.

◆ resetSymbolLayerIds() [2/2]

void QgsSymbolLayerUtils::resetSymbolLayerIds ( QgsSymbolLayer symbolLayer)
static

Regenerate recursively unique id from symbolLayer and its children.

Since
QGIS 3.30

Definition at line 5733 of file qgssymbollayerutils.cpp.

◆ restrictedSizeSymbol()

QgsSymbol * QgsSymbolLayerUtils::restrictedSizeSymbol ( const QgsSymbol s,
double  minSize,
double  maxSize,
QgsRenderContext context,
double &  width,
double &  height,
bool *  ok = nullptr 
)
static

Creates a new symbol with size restricted to min/max size if original size is out of min/max range.

Parameters
sthe original symbol
minSizethe minimum size in mm
maxSizethe maximum size in mm
contextthe render context
widthexpected width, can be changed by the function
heightexpected height, can be changed by the function
okif not nullptr, ok is set to false if it's not possible to compute a restricted symbol (if geometry generators are involved for instance)
Returns
nullptr if size is within minSize/maxSize range or if it's not possible to compute a restricted size symbol. New symbol if size was out of min/max range. Caller takes ownership

Definition at line 5379 of file qgssymbollayerutils.cpp.

◆ rotationFromSldElement()

bool QgsSymbolLayerUtils::rotationFromSldElement ( QDomElement &  element,
QString &  rotationFunc 
)
static

Definition at line 2897 of file qgssymbollayerutils.cpp.

◆ saveColorRamp()

QDomElement QgsSymbolLayerUtils::saveColorRamp ( const QString &  name,
const QgsColorRamp ramp,
QDomDocument &  doc 
)
static

Encodes a color ramp's settings to an XML element.

Parameters
namename of ramp
rampcolor ramp to save
docXML document
Returns
DOM element representing state of color ramp
See also
loadColorRamp()

Definition at line 3560 of file qgssymbollayerutils.cpp.

◆ saveColorsToGpl()

bool QgsSymbolLayerUtils::saveColorsToGpl ( QFile &  file,
const QString &  paletteName,
const QgsNamedColorList colors 
)
static

Exports colors to a gpl GIMP palette file.

Parameters
filedestination file
paletteNamename of palette, which is stored in gpl file
colorscolors to export
Returns
true if export was successful
See also
importColorsFromGpl

Definition at line 3900 of file qgssymbollayerutils.cpp.

◆ saveProperties()

void QgsSymbolLayerUtils::saveProperties ( QVariantMap  props,
QDomDocument &  doc,
QDomElement &  element 
)
static

Saves the map of properties to XML.

Definition at line 3389 of file qgssymbollayerutils.cpp.

◆ saveSymbol()

QDomElement QgsSymbolLayerUtils::saveSymbol ( const QString &  symbolName,
const QgsSymbol symbol,
QDomDocument &  doc,
const QgsReadWriteContext context 
)
static

Writes a symbol definition to XML.

Definition at line 1487 of file qgssymbollayerutils.cpp.

◆ saveSymbols()

QDomElement QgsSymbolLayerUtils::saveSymbols ( QgsSymbolMap symbols,
const QString &  tagName,
QDomDocument &  doc,
const QgsReadWriteContext context 
)
static

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

Definition at line 3472 of file qgssymbollayerutils.cpp.

◆ sizeInPixelsFromSldUom()

double QgsSymbolLayerUtils::sizeInPixelsFromSldUom ( const QString &  uom,
double  size 
)
static

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

Parameters
uomThe uom attribute from SLD 1.1 version
sizeThe original size
Returns
the size in pixels

Definition at line 5232 of file qgssymbollayerutils.cpp.

◆ sortVariantList()

void QgsSymbolLayerUtils::sortVariantList ( QList< QVariant > &  list,
Qt::SortOrder  order 
)
static

Sorts the passed list in requested order.

Definition at line 4417 of file qgssymbollayerutils.cpp.

◆ svgSymbolNameToPath()

QString QgsSymbolLayerUtils::svgSymbolNameToPath ( const QString &  name,
const QgsPathResolver pathResolver 
)
static

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.

See also
svgSymbolPathToName()

Definition at line 4494 of file qgssymbollayerutils.cpp.

◆ svgSymbolPathToName()

QString QgsSymbolLayerUtils::svgSymbolPathToName ( const QString &  path,
const QgsPathResolver pathResolver 
)
static

Determines an SVG symbol's name from its path.

See also
svgSymbolNameToPath()

Definition at line 4560 of file qgssymbollayerutils.cpp.

◆ symbolFromMimeData()

std::unique_ptr< QgsSymbol > QgsSymbolLayerUtils::symbolFromMimeData ( const QMimeData *  data)
static

Attempts to parse mime data as a symbol.

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

See also
symbolToMimeData()

Definition at line 3510 of file qgssymbollayerutils.cpp.

◆ symbolLayerPreviewIcon()

QIcon QgsSymbolLayerUtils::symbolLayerPreviewIcon ( const QgsSymbolLayer layer,
Qgis::RenderUnit  u,
QSize  size,
const QgsMapUnitScale scale = QgsMapUnitScale(),
Qgis::SymbolType  parentSymbolType = Qgis::SymbolType::Hybrid,
QgsMapLayer mapLayer = nullptr,
const QgsScreenProperties screen = QgsScreenProperties() 
)
static

Draws a symbol layer preview to an icon.

Parameters
layersymbol layer to draw
usize units
sizetarget size of preview icon
scalemap unit scale for preview
parentSymbolTypesince QGIS 3.22, can be used to specify the parent symbol type so that geometry generator preview icons are correctly calculated
mapLayersince QGIS 3.28, can be used to specify the associated map layer so that layer related expressions are correctly calculated
screensince QGIS 3.32, can be used to specify the destination screen properties for the icon. This allows the icon to be generated using the correct DPI and device pixel ratio for the target screen.
Returns
icon containing symbol layer preview
See also
symbolLayerPreviewPicture()

Definition at line 1041 of file qgssymbollayerutils.cpp.

◆ symbolLayerPreviewPicture()

QPicture QgsSymbolLayerUtils::symbolLayerPreviewPicture ( const QgsSymbolLayer layer,
Qgis::RenderUnit  units,
QSize  size,
const QgsMapUnitScale scale = QgsMapUnitScale(),
Qgis::SymbolType  parentSymbolType = Qgis::SymbolType::Hybrid 
)
static

Draws a symbol layer preview to a QPicture.

Parameters
layersymbol layer to draw
unitssize units
sizetarget size of preview picture
scalemap unit scale for preview
parentSymbolTypesince QGIS 3.22, can be used to specify the parent symbol type so that geometry generator preview icons are correctly calculated
Returns
QPicture containing symbol layer preview
See also
symbolLayerPreviewIcon()

Definition at line 1005 of file qgssymbollayerutils.cpp.

◆ symbolPreviewIcon()

QIcon QgsSymbolLayerUtils::symbolPreviewIcon ( const QgsSymbol symbol,
QSize  size,
int  padding = 0,
QgsLegendPatchShape shape = nullptr,
const QgsScreenProperties screen = QgsScreenProperties() 
)
static

Returns an icon preview for a color ramp.

Parameters
symbolsymbol
sizetarget pixmap size
paddingspace between icon edge and symbol
shapeoptional legend patch shape to use for rendering the preview icon
screencan be used to specify the destination screen properties for the icon. This allows the icon to be generated using the correct DPI and device pixel ratio for the target screen (since QGIS 3.32)
See also
symbolPreviewPixmap()

Definition at line 925 of file qgssymbollayerutils.cpp.

◆ symbolPreviewPixmap()

QPixmap QgsSymbolLayerUtils::symbolPreviewPixmap ( const QgsSymbol symbol,
QSize  size,
int  padding = 0,
QgsRenderContext customContext = nullptr,
bool  selected = false,
const QgsExpressionContext expressionContext = nullptr,
const QgsLegendPatchShape shape = nullptr,
const QgsScreenProperties screen = QgsScreenProperties() 
)
static

Returns a pixmap preview for a color ramp.

Parameters
symbolsymbol
sizetarget pixmap size
paddingspace between icon edge and symbol
customContextcustom rendering context
selectedset to true to render the symbol in a selected state (since QGIS 3.10)
expressionContextoptional custom expression context (since QGIS 3.10)
shapeoptional legend patch shape to use for rendering the preview icon (since QGIS 3.14)
screencan be used to specify the destination screen properties for the icon. This allows the icon to be generated using the correct DPI and device pixel ratio for the target screen (since QGIS 3.32)
See also
symbolPreviewIcon()

Definition at line 930 of file qgssymbollayerutils.cpp.

◆ symbolProperties()

QString QgsSymbolLayerUtils::symbolProperties ( QgsSymbol symbol)
static

Returns a string representing the symbol.

Can be used to test for equality between symbols.

Definition at line 1555 of file qgssymbollayerutils.cpp.

◆ symbolToMimeData()

QMimeData * QgsSymbolLayerUtils::symbolToMimeData ( const QgsSymbol symbol)
static

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.

See also
symbolFromMimeData()

Definition at line 3492 of file qgssymbollayerutils.cpp.

◆ tileSize()

QSize QgsSymbolLayerUtils::tileSize ( int  width,
int  height,
double &  angleRad 
)
static

Calculate the minimum size in pixels of a symbol tile given the symbol width and height and the symbol layer rotation angleRad in radians (counter clockwise).

The method makes approximations and can modify angle in order to generate the smallest possible tile.

Parameters
widthmarker width, including margins
heightmarker height, including margins
angleRadsymbol layer rotation angle in radians (counter clockwise), it may be approximated by the method to minimize the tile size.
Returns
the size of the tile
Since
QGIS 3.30

Definition at line 5469 of file qgssymbollayerutils.cpp.

◆ toPoint()

QPointF QgsSymbolLayerUtils::toPoint ( const QVariant &  value,
bool *  ok = nullptr 
)
static

Converts a value to a point.

Parameters
valuevalue to convert
okif specified, will be set to true if value was successfully converted
Returns
converted point
See also
decodePoint()
toSize()
Since
QGIS 3.10

Definition at line 605 of file qgssymbollayerutils.cpp.

◆ toQPolygonF() [1/2]

QList< QList< QPolygonF > > QgsSymbolLayerUtils::toQPolygonF ( const QgsAbstractGeometry geometry,
Qgis::SymbolType  type 
)
static

Converts a geometry to a set of QPolygonF objects representing how the geometry should be drawn for a symbol of the given type, as a list of geometry parts and rings.

Since
QGIS 3.42

Definition at line 4626 of file qgssymbollayerutils.cpp.

◆ toQPolygonF() [2/2]

QList< QList< QPolygonF > > QgsSymbolLayerUtils::toQPolygonF ( const QgsGeometry geometry,
Qgis::SymbolType  type 
)
static

Converts a geometry to a set of QPolygonF objects representing how the geometry should be drawn for a symbol of the given type, as a list of geometry parts and rings.

Since
QGIS 3.40

Definition at line 4621 of file qgssymbollayerutils.cpp.

◆ toSize()

QSizeF QgsSymbolLayerUtils::toSize ( const QVariant &  value,
bool *  ok = nullptr 
)
static

Converts a value to a size.

Parameters
valuevalue to convert
okif specified, will be set to true if value was successfully converted
Returns
converted size
See also
decodeSize()
toPoint()
Since
QGIS 3.10

Definition at line 669 of file qgssymbollayerutils.cpp.

◆ toSymbolLayerPointers()

QSet< const QgsSymbolLayer * > QgsSymbolLayerUtils::toSymbolLayerPointers ( const QgsFeatureRenderer renderer,
const QSet< QgsSymbolLayerId > &  symbolLayerIds 
)
static

Converts a set of symbol layer id to a set of pointers to actual symbol layers carried by the feature renderer.

Since
QGIS 3.12
Deprecated:
QGIS 3.30. Because it was related to old QgsSymbolLayerReference system.

Definition at line 5252 of file qgssymbollayerutils.cpp.

◆ wellKnownMarkerFromSld()

bool QgsSymbolLayerUtils::wellKnownMarkerFromSld ( QDomElement &  element,
QString &  name,
QColor &  color,
QColor &  strokeColor,
Qt::PenStyle &  strokeStyle,
double &  strokeWidth,
double &  size 
)
static

Extracts properties from an SLD marker definition.

Definition at line 2834 of file qgssymbollayerutils.cpp.

◆ wellKnownMarkerToSld() [1/2]

void QgsSymbolLayerUtils::wellKnownMarkerToSld ( QDomDocument &  doc,
QDomElement &  element,
const QString &  name,
const QColor &  color,
const QColor &  strokeColor,
Qt::PenStyle  strokeStyle,
double  strokeWidth = -1,
double  size = -1 
)
static

Exports a marker to SLD.

Deprecated:
QGIS 3.44. Use the version with QgsSldExportContext instead.

Definition at line 2792 of file qgssymbollayerutils.cpp.

◆ wellKnownMarkerToSld() [2/2]

void QgsSymbolLayerUtils::wellKnownMarkerToSld ( QDomDocument &  doc,
QDomElement &  element,
const QString &  name,
const QColor &  color,
const QColor &  strokeColor,
Qt::PenStyle  strokeStyle,
QgsSldExportContext context,
double  strokeWidth = -1,
double  size = -1 
)
static

Exports a marker to SLD.

Since
QGIS 3.44

Definition at line 2800 of file qgssymbollayerutils.cpp.


The documentation for this class was generated from the following files: