QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
QgsSymbol Class Referenceabstract

Abstract base class for all rendered symbols. More...

#include <qgssymbol.h>

Inheritance diagram for QgsSymbol:
Inheritance graph
[legend]

Public Types

enum class  Property : int { Opacity }
 Data definable properties. More...
 

Public Member Functions

virtual ~QgsSymbol ()
 
QgsSymbolAnimationSettingsanimationSettings ()
 Returns a reference to the symbol animation settings.
 
const QgsSymbolAnimationSettingsanimationSettings () const
 Returns a reference to the symbol animation settings.
 
bool appendSymbolLayer (QgsSymbolLayer *layer)
 Appends a symbol layer at the end of the current symbol layer list.
 
QImage asImage (QSize size, QgsRenderContext *customContext=nullptr)
 Returns an image of the symbol at the specified size.
 
Q_DECL_DEPRECATED QImage bigSymbolPreviewImage (QgsExpressionContext *expressionContext=nullptr, int flags=static_cast< int >(Qgis::SymbolPreviewFlag::FlagIncludeCrosshairsForMarkerSymbols))
 
QImage bigSymbolPreviewImage (QgsExpressionContext *expressionContext=nullptr, Qgis::SymbolPreviewFlags flags=Qgis::SymbolPreviewFlag::FlagIncludeCrosshairsForMarkerSymbols, const QgsScreenProperties &screen=QgsScreenProperties())
 Returns a large (roughly 100x100 pixel) preview image for the symbol.
 
bool canCauseArtifactsBetweenAdjacentTiles () const
 Returns true if the symbol rendering can cause visible artifacts across a single feature when the feature is rendered as a series of adjacent map tiles each containing a portion of the feature's geometry.
 
bool changeSymbolLayer (int index, QgsSymbolLayer *layer)
 Deletes the current layer at the specified index and replaces it with layer.
 
bool clipFeaturesToExtent () const
 Returns whether features drawn by the symbol will be clipped to the render context's extent.
 
virtual QgsSymbolclone () const =0
 Returns a deep copy of this symbol.
 
QColor color () const
 Returns the symbol's color.
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the symbol's property collection, used for data defined overrides.
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the symbol's property collection, used for data defined overrides.
 
bool deleteSymbolLayer (int index)
 Removes and deletes the symbol layer at the specified index.
 
void drawPreviewIcon (QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *patchShape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
 Draws an icon of the symbol that occupies an area given by size using the specified painter.
 
QString dump () const
 Returns a string dump of the symbol's properties.
 
void exportImage (const QString &path, const QString &format, QSize size)
 Export the symbol as an image format, to the specified path and with the given size.
 
Qgis::SymbolFlags flags () const
 Returns flags for the symbol.
 
bool forceRHR () const
 Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary.
 
bool hasDataDefinedProperties () const
 Returns whether the symbol utilizes any data defined properties.
 
bool insertSymbolLayer (int index, QgsSymbolLayer *layer)
 Inserts a symbol layer to specified index.
 
Q_DECL_DEPRECATED const QgsVectorLayerlayer () const
 
QgsMapUnitScale mapUnitScale () const
 Returns the map unit scale for the symbol.
 
qreal opacity () const
 Returns the opacity for the symbol.
 
Qgis::RenderUnit outputUnit () const
 Returns the units to use for sizes and widths within the symbol.
 
void renderFeature (const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, Qgis::VertexMarkerType currentVertexMarkerType=Qgis::VertexMarkerType::SemiTransparentCircle, double currentVertexMarkerSize=0.0)
 Render a feature.
 
Qgis::SymbolRenderHints renderHints () const
 Returns the rendering hint flags for the symbol.
 
void setAnimationSettings (const QgsSymbolAnimationSettings &settings)
 Sets a the symbol animation settings.
 
void setClipFeaturesToExtent (bool clipFeaturesToExtent)
 Sets whether features drawn by the symbol should be clipped to the render context's extent.
 
void setColor (const QColor &color) const
 Sets the color for the symbol.
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the symbol's property collection, used for data defined overrides.
 
void setDataDefinedProperty (Property key, const QgsProperty &property)
 Sets a data defined property for the symbol.
 
void setFlags (Qgis::SymbolFlags flags)
 Sets flags for the symbol.
 
void setForceRHR (bool force)
 Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary.
 
Q_DECL_DEPRECATED void setLayer (const QgsVectorLayer *layer)
 
void setMapUnitScale (const QgsMapUnitScale &scale) const
 Sets the map unit scale for the symbol.
 
void setOpacity (qreal opacity)
 Sets the opacity for the symbol.
 
void setOutputUnit (Qgis::RenderUnit unit) const
 Sets the units to use for sizes and widths within the symbol.
 
void setRenderHints (Qgis::SymbolRenderHints hints)
 Sets rendering hint flags for the symbol.
 
void startFeatureRender (const QgsFeature &feature, QgsRenderContext &context, int layer=-1)
 Called before symbol layers will be rendered for a particular feature.
 
void startRender (QgsRenderContext &context, const QgsFields &fields=QgsFields())
 Begins the rendering process for the symbol.
 
void stopFeatureRender (const QgsFeature &feature, QgsRenderContext &context, int layer=-1)
 Called after symbol layers have been rendered for a particular feature.
 
void stopRender (QgsRenderContext &context)
 Ends the rendering process.
 
QgsSymbolLayersymbolLayer (int layer)
 Returns the symbol layer at the specified index.
 
const QgsSymbolLayersymbolLayer (int layer) const
 Returns the symbol layer at the specified index, const variant.
 
int symbolLayerCount () const
 Returns the total number of symbol layers contained in the symbol.
 
QgsSymbolLayerList symbolLayers () const
 Returns the list of symbol layers contained in the symbol.
 
QgsSymbolRenderContextsymbolRenderContext ()
 Returns the symbol render context.
 
QgsSymbolLayertakeSymbolLayer (int index)
 Removes a symbol layer from the list and returns a pointer to it.
 
void toSld (QDomDocument &doc, QDomElement &element, QVariantMap props) const
 Converts the symbol to a SLD representation.
 
Qgis::SymbolType type () const
 Returns the symbol's type.
 
QSet< QString > usedAttributes (const QgsRenderContext &context) const
 Returns a list of attributes required to render this feature.
 
bool usesMapUnits () const
 Returns true if the symbol has any components which use map unit based sizes.
 

Static Public Member Functions

static QgsSymboldefaultSymbol (Qgis::GeometryType geomType)
 Returns a new default symbol for the specified geometry type.
 
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the symbol property definitions.
 
static Qgis::SymbolType symbolTypeForGeometryType (Qgis::GeometryType type)
 Returns the default symbol type required for the specified geometry type.
 
static QString symbolTypeToString (Qgis::SymbolType type)
 Returns a translated string version of the specified symbol type.
 

Protected Member Functions

 QgsSymbol (Qgis::SymbolType type, const QgsSymbolLayerList &layers)
 Constructor for a QgsSymbol of the specified type.
 
QgsSymbolLayerList cloneLayers () const
 Retrieve a cloned list of all layers that make up this symbol.
 
void renderUsingLayer (QgsSymbolLayer *layer, QgsSymbolRenderContext &context, Qgis::GeometryType geometryType=Qgis::GeometryType::Unknown, const QPolygonF *points=nullptr, const QVector< QPolygonF > *rings=nullptr)
 Renders a context using a particular symbol layer without passing in a geometry.
 
void renderVertexMarker (QPointF pt, QgsRenderContext &context, Qgis::VertexMarkerType currentVertexMarkerType, double currentVertexMarkerSize)
 Render editing vertex marker at specified point.
 

Static Protected Member Functions

static QPolygonF _getLineString (QgsRenderContext &context, const QgsCurve &curve, bool clipToExtent=true)
 Creates a line string in screen coordinates from a QgsCurve in map coordinates.
 
static QPointF _getPoint (QgsRenderContext &context, const QgsPoint &point)
 Creates a point in screen coordinates from a QgsPoint in map coordinates.
 
static void _getPolygon (QPolygonF &pts, QVector< QPolygonF > &holes, QgsRenderContext &context, const QgsPolygon &polygon, bool clipToExtent=true, bool correctRingOrientation=false)
 Creates a polygon in screen coordinates from a QgsPolygonXYin map coordinates.
 
static QPolygonF _getPolygonRing (QgsRenderContext &context, const QgsCurve &curve, bool clipToExtent, bool isExteriorRing=false, bool correctRingOrientation=false)
 Creates a polygon ring in screen coordinates from a QgsCurve in map coordinates.
 

Protected Attributes

QgsSymbolAnimationSettings mAnimationSettings
 
bool mClipFeaturesToExtent = true
 
bool mForceRHR = false
 
Q_DECL_DEPRECATED const QgsVectorLayermLayer = nullptr
 
QgsSymbolLayerList mLayers
 
qreal mOpacity = 1.0
 Symbol opacity (in the range 0 - 1)
 
Qgis::SymbolRenderHints mRenderHints
 
Qgis::SymbolFlags mSymbolFlags = Qgis::SymbolFlags()
 Symbol flags.
 
Qgis::SymbolType mType
 

Friends

class QgsFeatureRenderer
 

Detailed Description

Abstract base class for all rendered symbols.

Definition at line 93 of file qgssymbol.h.

Member Enumeration Documentation

◆ Property

enum class QgsSymbol::Property : int
strong

Data definable properties.

Since
QGIS 3.18
Enumerator
Opacity 

Opacity.

Definition at line 132 of file qgssymbol.h.

Constructor & Destructor Documentation

◆ ~QgsSymbol()

QgsSymbol::~QgsSymbol ( )
virtual

Definition at line 604 of file qgssymbol.cpp.

◆ QgsSymbol()

Q_NOWARN_DEPRECATED_PUSH QgsSymbol::QgsSymbol ( Qgis::SymbolType  type,
const QgsSymbolLayerList layers 
)
protected

Constructor for a QgsSymbol of the specified type.

Ownership of layers will be transferred to the symbol.

Definition at line 60 of file qgssymbol.cpp.

Member Function Documentation

◆ _getLineString()

Q_NOWARN_DEPRECATED_POP QPolygonF QgsSymbol::_getLineString ( QgsRenderContext context,
const QgsCurve curve,
bool  clipToExtent = true 
)
staticprotected

Creates a line string in screen coordinates from a QgsCurve in map coordinates.

Definition at line 81 of file qgssymbol.cpp.

◆ _getPoint()

static QPointF QgsSymbol::_getPoint ( QgsRenderContext context,
const QgsPoint point 
)
inlinestaticprotected

Creates a point in screen coordinates from a QgsPoint in map coordinates.

Definition at line 715 of file qgssymbol.h.

◆ _getPolygon()

void QgsSymbol::_getPolygon ( QPolygonF &  pts,
QVector< QPolygonF > &  holes,
QgsRenderContext context,
const QgsPolygon polygon,
bool  clipToExtent = true,
bool  correctRingOrientation = false 
)
staticprotected

Creates a polygon in screen coordinates from a QgsPolygonXYin map coordinates.

If correctRingOrientation is true then the ring will be oriented to match standard ring orientation, e.g. clockwise for exterior rings and counter-clockwise for interior rings.

Definition at line 550 of file qgssymbol.cpp.

◆ _getPolygonRing()

QPolygonF QgsSymbol::_getPolygonRing ( QgsRenderContext context,
const QgsCurve curve,
bool  clipToExtent,
bool  isExteriorRing = false,
bool  correctRingOrientation = false 
)
staticprotected

Creates a polygon ring in screen coordinates from a QgsCurve in map coordinates.

If correctRingOrientation is true then the ring will be oriented to match standard ring orientation, e.g. clockwise for exterior rings and counter-clockwise for interior rings.

Definition at line 302 of file qgssymbol.cpp.

◆ animationSettings() [1/2]

QgsSymbolAnimationSettings & QgsSymbol::animationSettings ( )

Returns a reference to the symbol animation settings.

See also
setAnimationSettings()
Since
QGIS 3.26

Definition at line 690 of file qgssymbol.cpp.

◆ animationSettings() [2/2]

const QgsSymbolAnimationSettings & QgsSymbol::animationSettings ( ) const

Returns a reference to the symbol animation settings.

See also
setAnimationSettings()
Since
QGIS 3.26

Definition at line 695 of file qgssymbol.cpp.

◆ appendSymbolLayer()

bool QgsSymbol::appendSymbolLayer ( QgsSymbolLayer layer)

Appends a symbol layer at the end of the current symbol layer list.

Ownership of layer is transferred to the symbol.

Returns
true if the layer was successfully added, false if the layer is not compatible with the symbol's type().

Definition at line 783 of file qgssymbol.cpp.

◆ asImage()

QImage QgsSymbol::asImage ( QSize  size,
QgsRenderContext customContext = nullptr 
)

Returns an image of the symbol at the specified size.

Optionally a custom render context may be given in order to ensure that the preview icon exactly matches the settings from that context.

See also
exportImage()
drawPreviewIcon()

Definition at line 1048 of file qgssymbol.cpp.

◆ bigSymbolPreviewImage() [1/2]

QImage QgsSymbol::bigSymbolPreviewImage ( QgsExpressionContext expressionContext = nullptr,
int  flags = static_cast< int >( Qgis::SymbolPreviewFlag::FlagIncludeCrosshairsForMarkerSymbols ) 
)
Deprecated:
use bigSymbolPreviewImageV2 instead.

Definition at line 1119 of file qgssymbol.cpp.

◆ bigSymbolPreviewImage() [2/2]

QImage QgsSymbol::bigSymbolPreviewImage ( QgsExpressionContext expressionContext = nullptr,
Qgis::SymbolPreviewFlags  flags = Qgis::SymbolPreviewFlag::FlagIncludeCrosshairsForMarkerSymbols,
const QgsScreenProperties screen = QgsScreenProperties() 
)

Returns a large (roughly 100x100 pixel) preview image for the symbol.

Parameters
expressionContextoptional expression context, for evaluation of data defined symbol properties
flagsoptional flags to control how preview image is generated
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 a target screen (since QGIS 3.32)
See also
asImage()
drawPreviewIcon()

Definition at line 1063 of file qgssymbol.cpp.

◆ canCauseArtifactsBetweenAdjacentTiles()

bool QgsSymbol::canCauseArtifactsBetweenAdjacentTiles ( ) const

Returns true if the symbol rendering can cause visible artifacts across a single feature when the feature is rendered as a series of adjacent map tiles each containing a portion of the feature's geometry.

Internally this calls QgsSymbolLayer::canCauseArtifactsBetweenAdjacentTiles() for all symbol layers in the symbol and returns true if any of the layers returned TRUE.

Since
QGIS 3.18

Definition at line 1235 of file qgssymbol.cpp.

◆ changeSymbolLayer()

bool QgsSymbol::changeSymbolLayer ( int  index,
QgsSymbolLayer layer 
)

Deletes the current layer at the specified index and replaces it with layer.

Ownership of layer is transferred to the symbol.

Returns false if layer is not compatible with the symbol's type(), or true if the layer was successfully replaced.

Definition at line 813 of file qgssymbol.cpp.

◆ clipFeaturesToExtent()

bool QgsSymbol::clipFeaturesToExtent ( ) const
inline

Returns whether features drawn by the symbol will be clipped to the render context's extent.

If this option is enabled then features which are partially outside the extent will be clipped. This speeds up rendering of the feature, but may have undesirable side effects for certain symbol types.

Returns
true if features will be clipped
See also
setClipFeaturesToExtent

Definition at line 550 of file qgssymbol.h.

◆ clone()

virtual QgsSymbol * QgsSymbol::clone ( ) const
pure virtual

Returns a deep copy of this symbol.

Ownership is transferred to the caller.

Implemented in QgsFillSymbol, QgsLineSymbol, and QgsMarkerSymbol.

◆ cloneLayers()

QgsSymbolLayerList QgsSymbol::cloneLayers ( ) const
protected

Retrieve a cloned list of all layers that make up this symbol.

Ownership is transferred to the caller.

Definition at line 1163 of file qgssymbol.cpp.

◆ color()

QColor QgsSymbol::color ( ) const

Returns the symbol's color.

For multi-layer symbols, this method returns the color of the first unlocked symbol layer.

See also
setColor()

Definition at line 911 of file qgssymbol.cpp.

◆ dataDefinedProperties() [1/2]

QgsPropertyCollection & QgsSymbol::dataDefinedProperties ( )
inline

Returns a reference to the symbol's property collection, used for data defined overrides.

See also
setDataDefinedProperties()
Property
Since
QGIS 3.18

Definition at line 620 of file qgssymbol.h.

◆ dataDefinedProperties() [2/2]

const QgsPropertyCollection & QgsSymbol::dataDefinedProperties ( ) const
inline

Returns a reference to the symbol's property collection, used for data defined overrides.

See also
setDataDefinedProperties()
Since
QGIS 3.18

Definition at line 627 of file qgssymbol.h.

◆ defaultSymbol()

QgsSymbol * QgsSymbol::defaultSymbol ( Qgis::GeometryType  geomType)
static

Returns a new default symbol for the specified geometry type.

The caller takes ownership of the returned object.

Definition at line 705 of file qgssymbol.cpp.

◆ deleteSymbolLayer()

bool QgsSymbol::deleteSymbolLayer ( int  index)

Removes and deletes the symbol layer at the specified index.

Definition at line 793 of file qgssymbol.cpp.

◆ drawPreviewIcon()

void QgsSymbol::drawPreviewIcon ( QPainter *  painter,
QSize  size,
QgsRenderContext customContext = nullptr,
bool  selected = false,
const QgsExpressionContext expressionContext = nullptr,
const QgsLegendPatchShape patchShape = nullptr,
const QgsScreenProperties screen = QgsScreenProperties() 
)

Draws an icon of the symbol that occupies an area given by size using the specified painter.

Optionally a custom render context may be given in order to ensure that the preview icon exactly matches the settings from that context.

Parameters
painterdestination painter
sizesize of the icon
customContextthe context in which the rendering happens
selectedset to true to render the symbol in a selected state (since QGIS 3.10)
expressionContextoptional custom expression context
patchShapeoptional patch shape to use for symbol preview. If not specified a default shape will be used instead.
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
exportImage()
asImage()

Definition at line 926 of file qgssymbol.cpp.

◆ dump()

QString QgsSymbol::dump ( ) const

Returns a string dump of the symbol's properties.

Definition at line 1124 of file qgssymbol.cpp.

◆ exportImage()

void QgsSymbol::exportImage ( const QString &  path,
const QString &  format,
QSize  size 
)

Export the symbol as an image format, to the specified path and with the given size.

If format is "SVG" then an SVG file will be created, otherwise a raster image of the specified format will be created.

See also
asImage()
drawPreviewIcon()

Definition at line 1028 of file qgssymbol.cpp.

◆ flags()

Qgis::SymbolFlags QgsSymbol::flags ( ) const
inline

Returns flags for the symbol.

See also
setFlags()
Since
QGIS 3.20

Definition at line 530 of file qgssymbol.h.

◆ forceRHR()

bool QgsSymbol::forceRHR ( ) const
inline

Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary.

In particular, the exterior ring is oriented in a clockwise direction and the interior rings in a counter-clockwise direction.

See also
setForceRHR()
Since
QGIS 3.6

Definition at line 572 of file qgssymbol.h.

◆ hasDataDefinedProperties()

bool QgsSymbol::hasDataDefinedProperties ( ) const

Returns whether the symbol utilizes any data defined properties.

Definition at line 1222 of file qgssymbol.cpp.

◆ insertSymbolLayer()

bool QgsSymbol::insertSymbolLayer ( int  index,
QgsSymbolLayer layer 
)

Inserts a symbol layer to specified index.

Ownership of layer is transferred to the symbol.

Parameters
indexThe index at which the layer should be added
layerThe symbol layer to add
Returns
true if the layer is added, false if the index or the layer is bad

Definition at line 770 of file qgssymbol.cpp.

◆ layer()

const QgsVectorLayer * QgsSymbol::layer ( ) const
Deprecated:
Will be removed in QGIS 4.0

Definition at line 1252 of file qgssymbol.cpp.

◆ mapUnitScale()

QgsMapUnitScale QgsSymbol::mapUnitScale ( ) const

Returns the map unit scale for the symbol.

If the symbol consists of multiple layers, the map unit scale is only returned if all layers have the same scale settings. If the settings differ, a default constructed map unit scale is returned.

See also
setMapUnitScale()

Definition at line 648 of file qgssymbol.cpp.

◆ opacity()

qreal QgsSymbol::opacity ( ) const
inline

Returns the opacity for the symbol.

Returns
opacity value between 0 (fully transparent) and 1 (fully opaque)
See also
setOpacity()

Definition at line 495 of file qgssymbol.h.

◆ outputUnit()

Qgis::RenderUnit QgsSymbol::outputUnit ( ) const

Returns the units to use for sizes and widths within the symbol.

Individual symbol layer definitions will interpret this in different ways, e.g., a marker symbol may use it to specify the units for the marker size, while a line symbol may use it to specify the units for the line width.

Returns
output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol contains mixed units
See also
setOutputUnit()

Definition at line 610 of file qgssymbol.cpp.

◆ propertyDefinitions()

const QgsPropertiesDefinition & QgsSymbol::propertyDefinitions ( )
static

Returns the symbol property definitions.

Since
QGIS 3.18

Definition at line 598 of file qgssymbol.cpp.

◆ renderFeature()

PRIVATE void QgsSymbol::renderFeature ( const QgsFeature feature,
QgsRenderContext context,
int  layer = -1,
bool  selected = false,
bool  drawVertexMarker = false,
Qgis::VertexMarkerType  currentVertexMarkerType = Qgis::VertexMarkerType::SemiTransparentCircle,
double  currentVertexMarkerSize = 0.0 
)

Render a feature.

Before calling this the startRender() method should be called to initialize the rendering process. After rendering all features stopRender() must be called.

Definition at line 1301 of file qgssymbol.cpp.

◆ renderHints()

Qgis::SymbolRenderHints QgsSymbol::renderHints ( ) const
inline

Returns the rendering hint flags for the symbol.

See also
setRenderHints()

Definition at line 514 of file qgssymbol.h.

◆ renderUsingLayer()

void QgsSymbol::renderUsingLayer ( QgsSymbolLayer layer,
QgsSymbolRenderContext context,
Qgis::GeometryType  geometryType = Qgis::GeometryType::Unknown,
const QPolygonF *  points = nullptr,
const QVector< QPolygonF > *  rings = nullptr 
)
protected

Renders a context using a particular symbol layer without passing in a geometry.

This is used as fallback, if the symbol being rendered is not compatible with the specified layer. In such a case, this method can be called and will call the layer's rendering method anyway but the geometry passed to the layer will be empty. This is required for layers that generate their own geometry from other information in the rendering context.

Since QGIS 3.22, the optional geometryType, points and rings arguments can specify the original geometry type, points and rings in which are being rendered by the parent symbol.

Definition at line 1179 of file qgssymbol.cpp.

◆ renderVertexMarker()

void QgsSymbol::renderVertexMarker ( QPointF  pt,
QgsRenderContext context,
Qgis::VertexMarkerType  currentVertexMarkerType,
double  currentVertexMarkerSize 
)
protected

Render editing vertex marker at specified point.

Definition at line 1845 of file qgssymbol.cpp.

◆ setAnimationSettings()

void QgsSymbol::setAnimationSettings ( const QgsSymbolAnimationSettings settings)

Sets a the symbol animation settings.

See also
animationSettings()
Since
QGIS 3.26

Definition at line 700 of file qgssymbol.cpp.

◆ setClipFeaturesToExtent()

void QgsSymbol::setClipFeaturesToExtent ( bool  clipFeaturesToExtent)
inline

Sets whether features drawn by the symbol should be clipped to the render context's extent.

If this option is enabled then features which are partially outside the extent will be clipped. This speeds up rendering of the feature, but may have undesirable side effects for certain symbol types.

Parameters
clipFeaturesToExtentset to true to enable clipping (defaults to TRUE)
See also
clipFeaturesToExtent

Definition at line 540 of file qgssymbol.h.

◆ setColor()

void QgsSymbol::setColor ( const QColor &  color) const

Sets the color for the symbol.

Calling this method sets the color for each individual symbol layer contained within the symbol to color.

Locked symbol layers are skipped and are left unchanged.

See also
color()

Definition at line 901 of file qgssymbol.cpp.

◆ setDataDefinedProperties()

void QgsSymbol::setDataDefinedProperties ( const QgsPropertyCollection collection)
inline

Sets the symbol's property collection, used for data defined overrides.

Parameters
collectionproperty collection. Existing properties will be replaced.
See also
dataDefinedProperties()
Since
QGIS 3.18

Definition at line 635 of file qgssymbol.h.

◆ setDataDefinedProperty()

void QgsSymbol::setDataDefinedProperty ( QgsSymbol::Property  key,
const QgsProperty property 
)

Sets a data defined property for the symbol.

Any existing property with the same key will be overwritten.

See also
dataDefinedProperties()
Property
Since
QGIS 3.18

Definition at line 1217 of file qgssymbol.cpp.

◆ setFlags()

void QgsSymbol::setFlags ( Qgis::SymbolFlags  flags)
inline

Sets flags for the symbol.

See also
flags()
Since
QGIS 3.320

Definition at line 522 of file qgssymbol.h.

◆ setForceRHR()

void QgsSymbol::setForceRHR ( bool  force)
inline

Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-hand-rule orientation, in which the area that is bounded by the polygon is to the right of the boundary.

In particular, the exterior ring is oriented in a clockwise direction and the interior rings in a counter-clockwise direction.

See also
forceRHR()
Since
QGIS 3.6

Definition at line 561 of file qgssymbol.h.

◆ setLayer()

void QgsSymbol::setLayer ( const QgsVectorLayer layer)
Note
the layer will be nullptr after stopRender
Deprecated:
Will be removed in QGIS 4.0

Definition at line 1245 of file qgssymbol.cpp.

◆ setMapUnitScale()

void QgsSymbol::setMapUnitScale ( const QgsMapUnitScale scale) const

Sets the map unit scale for the symbol.

Calling this method sets the scale for all symbol layers contained within the symbol.

See also
mapUnitScale()

Definition at line 681 of file qgssymbol.cpp.

◆ setOpacity()

void QgsSymbol::setOpacity ( qreal  opacity)
inline

Sets the opacity for the symbol.

Parameters
opacityopacity value between 0 (fully transparent) and 1 (fully opaque)
See also
opacity()

Definition at line 502 of file qgssymbol.h.

◆ setOutputUnit()

void QgsSymbol::setOutputUnit ( Qgis::RenderUnit  unit) const

Sets the units to use for sizes and widths within the symbol.

Individual symbol definitions will interpret this in different ways, e.g., a marker symbol may use it to specify the units for the marker size, while a line symbol may use it to specify the units for the line width.

Parameters
unitoutput units
See also
outputUnit()

Definition at line 672 of file qgssymbol.cpp.

◆ setRenderHints()

void QgsSymbol::setRenderHints ( Qgis::SymbolRenderHints  hints)
inline

Sets rendering hint flags for the symbol.

See also
renderHints()

Definition at line 508 of file qgssymbol.h.

◆ startFeatureRender()

void QgsSymbol::startFeatureRender ( const QgsFeature feature,
QgsRenderContext context,
int  layer = -1 
)

Called before symbol layers will be rendered for a particular feature.

This is always followed by a call to stopFeatureRender() after the feature has been completely rendered (i.e. all parts have been rendered).

Internally, this notifies all symbol layers which will be used via a call to QgsSymbolLayer::startFeatureRender().

Since
QGIS 3.20

Definition at line 1864 of file qgssymbol.cpp.

◆ startRender()

void QgsSymbol::startRender ( QgsRenderContext context,
const QgsFields fields = QgsFields() 
)

Begins the rendering process for the symbol.

This must be called before renderFeature(), and should be followed by a call to stopRender().

Parameters
contextrender context which symbol will be drawn using
fieldsfields for features to be rendered (usually the associated vector layer's fields). Required for correct calculation of data defined overrides.
See also
stopRender()

Definition at line 829 of file qgssymbol.cpp.

◆ stopFeatureRender()

void QgsSymbol::stopFeatureRender ( const QgsFeature feature,
QgsRenderContext context,
int  layer = -1 
)

Called after symbol layers have been rendered for a particular feature.

This is always preceded by a call to startFeatureRender() just before the feature will be rendered.

Internally, this notifies all symbol layers which were used via a call to QgsSymbolLayer::stopFeatureRender().

Since
QGIS 3.20

Definition at line 1888 of file qgssymbol.cpp.

◆ stopRender()

void QgsSymbol::stopRender ( QgsRenderContext context)

Ends the rendering process.

This should be called after rendering all desired features.

Parameters
contextrender context, must match the context specified when startRender() was called.
See also
startRender()

Definition at line 876 of file qgssymbol.cpp.

◆ symbolLayer() [1/2]

QgsSymbolLayer * QgsSymbol::symbolLayer ( int  layer)

Returns the symbol layer at the specified index.

See also
symbolLayers
symbolLayerCount

Definition at line 760 of file qgssymbol.cpp.

◆ symbolLayer() [2/2]

const QgsSymbolLayer * QgsSymbol::symbolLayer ( int  layer) const

Returns the symbol layer at the specified index, const variant.

See also
symbolLayers
symbolLayerCount
Since
QGIS 3.12

Definition at line 765 of file qgssymbol.cpp.

◆ symbolLayerCount()

int QgsSymbol::symbolLayerCount ( ) const
inline

Returns the total number of symbol layers contained in the symbol.

Returns
count of symbol layers
See also
symbolLayers
symbolLayer

Definition at line 215 of file qgssymbol.h.

◆ symbolLayers()

QgsSymbolLayerList QgsSymbol::symbolLayers ( ) const
inline

Returns the list of symbol layers contained in the symbol.

Returns
symbol layers list
See also
symbolLayer
symbolLayerCount

Definition at line 166 of file qgssymbol.h.

◆ symbolRenderContext()

QgsSymbolRenderContext * QgsSymbol::symbolRenderContext ( )

Returns the symbol render context.

Only valid between startRender and stopRender calls.

Returns
The symbol render context

Definition at line 1840 of file qgssymbol.cpp.

◆ symbolTypeForGeometryType()

Qgis::SymbolType QgsSymbol::symbolTypeForGeometryType ( Qgis::GeometryType  type)
static

Returns the default symbol type required for the specified geometry type.

Since
QGIS 3.20

Definition at line 581 of file qgssymbol.cpp.

◆ symbolTypeToString()

QString QgsSymbol::symbolTypeToString ( Qgis::SymbolType  type)
static

Returns a translated string version of the specified symbol type.

Since
QGIS 3.20

Definition at line 565 of file qgssymbol.cpp.

◆ takeSymbolLayer()

QgsSymbolLayer * QgsSymbol::takeSymbolLayer ( int  index)

Removes a symbol layer from the list and returns a pointer to it.

Ownership of the layer is handed to the caller.

Parameters
indexThe index of the layer to remove
Returns
A pointer to the removed layer

Definition at line 804 of file qgssymbol.cpp.

◆ toSld()

void QgsSymbol::toSld ( QDomDocument &  doc,
QDomElement &  element,
QVariantMap  props 
) const

Converts the symbol to a SLD representation.

Definition at line 1150 of file qgssymbol.cpp.

◆ type()

Qgis::SymbolType QgsSymbol::type ( ) const
inline

Returns the symbol's type.

Definition at line 156 of file qgssymbol.h.

◆ usedAttributes()

QSet< QString > QgsSymbol::usedAttributes ( const QgsRenderContext context) const

Returns a list of attributes required to render this feature.

This should include any attributes required by the symbology including the ones required by expressions.

Definition at line 1200 of file qgssymbol.cpp.

◆ usesMapUnits()

bool QgsSymbol::usesMapUnits ( ) const

Returns true if the symbol has any components which use map unit based sizes.

Since
QGIS 3.18

Definition at line 631 of file qgssymbol.cpp.

Friends And Related Symbol Documentation

◆ QgsFeatureRenderer

friend class QgsFeatureRenderer
friend

Definition at line 108 of file qgssymbol.h.

Member Data Documentation

◆ mAnimationSettings

QgsSymbolAnimationSettings QgsSymbol::mAnimationSettings
protected

Definition at line 799 of file qgssymbol.h.

◆ mClipFeaturesToExtent

bool QgsSymbol::mClipFeaturesToExtent = true
protected

Definition at line 796 of file qgssymbol.h.

◆ mForceRHR

bool QgsSymbol::mForceRHR = false
protected

Definition at line 797 of file qgssymbol.h.

◆ mLayer

Q_DECL_DEPRECATED const QgsVectorLayer* QgsSymbol::mLayer = nullptr
protected

Definition at line 801 of file qgssymbol.h.

◆ mLayers

QgsSymbolLayerList QgsSymbol::mLayers
protected

Definition at line 782 of file qgssymbol.h.

◆ mOpacity

qreal QgsSymbol::mOpacity = 1.0
protected

Symbol opacity (in the range 0 - 1)

Definition at line 785 of file qgssymbol.h.

◆ mRenderHints

Qgis::SymbolRenderHints QgsSymbol::mRenderHints
protected

Definition at line 787 of file qgssymbol.h.

◆ mSymbolFlags

Qgis::SymbolFlags QgsSymbol::mSymbolFlags = Qgis::SymbolFlags()
protected

Symbol flags.

Since
QGIS 3.20

Definition at line 794 of file qgssymbol.h.

◆ mType

Qgis::SymbolType QgsSymbol::mType
protected

Definition at line 781 of file qgssymbol.h.


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