QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Member Functions | Static Public Member Functions | List of all members
QgsLineSymbol Class Reference

A line symbol type, for rendering LineString and MultiLineString geometries. More...

#include <qgslinesymbol.h>

Inheritance diagram for QgsLineSymbol:
Inheritance graph
[legend]

Public Member Functions

 QgsLineSymbol (const QgsSymbolLayerList &layers=QgsSymbolLayerList())
 Constructor for QgsLineSymbol, with the specified list of initial symbol layers. More...
 
QgsLineSymbolclone () const override
 Returns a deep copy of this symbol. More...
 
QgsProperty dataDefinedWidth () const
 Returns data defined width for whole symbol (including all symbol layers). More...
 
void renderPolyline (const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
 Renders the symbol along the line joining points, using the given render context. More...
 
void setDataDefinedWidth (const QgsProperty &property)
 Set data defined width for whole symbol (including all symbol layers). More...
 
void setWidth (double width)
 Sets the width for the whole line symbol. More...
 
void setWidthUnit (QgsUnitTypes::RenderUnit unit)
 Sets the width units for the whole symbol (including all symbol layers). More...
 
double width () const
 Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol layers in the symbol. More...
 
double width (const QgsRenderContext &context) const
 Returns the symbol width, in painter units. More...
 
- Public Member Functions inherited from QgsSymbol
virtual ~QgsSymbol ()
 
bool appendSymbolLayer (QgsSymbolLayer *layer)
 Appends a symbol layer at the end of the current symbol layer list. More...
 
QImage asImage (QSize size, QgsRenderContext *customContext=nullptr)
 Returns an image of the symbol at the specified size. More...
 
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)
 Returns a large (roughly 100x100 pixel) preview image for the symbol. More...
 
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. More...
 
bool changeSymbolLayer (int index, QgsSymbolLayer *layer)
 Deletes the current layer at the specified index and replaces it with layer. More...
 
bool clipFeaturesToExtent () const
 Returns whether features drawn by the symbol will be clipped to the render context's extent. More...
 
QColor color () const
 Returns the symbol's color. More...
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the symbol's property collection, used for data defined overrides. More...
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the symbol's property collection, used for data defined overrides. More...
 
bool deleteSymbolLayer (int index)
 Removes and deletes the symbol layer at the specified index. More...
 
void drawPreviewIcon (QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *patchShape=nullptr)
 Draws an icon of the symbol that occupies an area given by size using the specified painter. More...
 
QString dump () const
 Returns a string dump of the symbol's properties. More...
 
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. More...
 
Qgis::SymbolFlags flags () const
 Returns flags for the symbol. More...
 
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. More...
 
bool hasDataDefinedProperties () const
 Returns whether the symbol utilizes any data defined properties. More...
 
bool insertSymbolLayer (int index, QgsSymbolLayer *layer)
 Inserts a symbol layer to specified index. More...
 
Q_DECL_DEPRECATED const QgsVectorLayerlayer () const
 
QgsMapUnitScale mapUnitScale () const
 Returns the map unit scale for the symbol. More...
 
qreal opacity () const
 Returns the opacity for the symbol. More...
 
QgsUnitTypes::RenderUnit outputUnit () const
 Returns the units to use for sizes and widths within the symbol. More...
 
void renderFeature (const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, int currentVertexMarkerType=0, double currentVertexMarkerSize=0.0) SIP_THROW(QgsCsException)
 Render a feature. More...
 
Qgis::SymbolRenderHints renderHints () const
 Returns the rendering hint flags for the symbol. More...
 
void setClipFeaturesToExtent (bool clipFeaturesToExtent)
 Sets whether features drawn by the symbol should be clipped to the render context's extent. More...
 
void setColor (const QColor &color)
 Sets the color for the symbol. More...
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the symbol's property collection, used for data defined overrides. More...
 
void setDataDefinedProperty (Property key, const QgsProperty &property)
 Sets a data defined property for the symbol. More...
 
void setFlags (Qgis::SymbolFlags flags)
 Sets flags for the symbol. More...
 
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. More...
 
Q_DECL_DEPRECATED void setLayer (const QgsVectorLayer *layer)
 
void setMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale for the symbol. More...
 
void setOpacity (qreal opacity)
 Sets the opacity for the symbol. More...
 
void setOutputUnit (QgsUnitTypes::RenderUnit unit)
 Sets the units to use for sizes and widths within the symbol. More...
 
void setRenderHints (Qgis::SymbolRenderHints hints)
 Sets rendering hint flags for the symbol. More...
 
void startFeatureRender (const QgsFeature &feature, QgsRenderContext &context, int layer=-1)
 Called before symbol layers will be rendered for a particular feature. More...
 
void startRender (QgsRenderContext &context, const QgsFields &fields=QgsFields())
 Begins the rendering process for the symbol. More...
 
void stopFeatureRender (const QgsFeature &feature, QgsRenderContext &context, int layer=-1)
 Called after symbol layers have been rendered for a particular feature. More...
 
void stopRender (QgsRenderContext &context)
 Ends the rendering process. More...
 
QgsSymbolLayersymbolLayer (int layer)
 Returns the symbol layer at the specified index. More...
 
const QgsSymbolLayersymbolLayer (int layer) const
 Returns the symbol layer at the specified index, const variant. More...
 
int symbolLayerCount () const
 Returns the total number of symbol layers contained in the symbol. More...
 
QgsSymbolLayerList symbolLayers ()
 Returns the list of symbol layers contained in the symbol. More...
 
QgsSymbolRenderContextsymbolRenderContext ()
 Returns the symbol render context. More...
 
QgsSymbolLayertakeSymbolLayer (int index)
 Removes a symbol layer from the list and returns a pointer to it. More...
 
void toSld (QDomDocument &doc, QDomElement &element, QVariantMap props) const
 Converts the symbol to a SLD representation. More...
 
Qgis::SymbolType type () const
 Returns the symbol's type. More...
 
QSet< QString > usedAttributes (const QgsRenderContext &context) const
 Returns a list of attributes required to render this feature. More...
 
bool usesMapUnits () const
 Returns true if the symbol has any components which use map unit based sizes. More...
 

Static Public Member Functions

static QgsLineSymbolcreateSimple (const QVariantMap &properties)
 Create a line symbol with one symbol layer: SimpleLine with specified properties. More...
 
- Static Public Member Functions inherited from QgsSymbol
static QgsSymboldefaultSymbol (QgsWkbTypes::GeometryType geomType)
 Returns a new default symbol for the specified geometry type. More...
 
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the symbol property definitions. More...
 
static Qgis::SymbolType symbolTypeForGeometryType (QgsWkbTypes::GeometryType type)
 Returns the default symbol type required for the specified geometry type. More...
 
static QString symbolTypeToString (Qgis::SymbolType type)
 Returns a translated string version of the specified symbol type. More...
 

Additional Inherited Members

- Public Types inherited from QgsSymbol
enum  Property { PropertyOpacity }
 Data definable properties. More...
 
- Protected Member Functions inherited from QgsSymbol
 QgsSymbol (Qgis::SymbolType type, const QgsSymbolLayerList &layers)
 Constructor for a QgsSymbol of the specified type. More...
 
QgsSymbolLayerList cloneLayers () const
 Retrieve a cloned list of all layers that make up this symbol. More...
 
void renderUsingLayer (QgsSymbolLayer *layer, QgsSymbolRenderContext &context)
 Renders a context using a particular symbol layer without passing in a geometry. More...
 
void renderVertexMarker (QPointF pt, QgsRenderContext &context, int currentVertexMarkerType, double currentVertexMarkerSize)
 Render editing vertex marker at specified point. More...
 
- Static Protected Member Functions inherited from QgsSymbol
static QPolygonF _getLineString (QgsRenderContext &context, const QgsCurve &curve, bool clipToExtent=true)
 Creates a line string in screen coordinates from a QgsCurve in map coordinates. More...
 
static QPointF _getPoint (QgsRenderContext &context, const QgsPoint &point)
 Creates a point in screen coordinates from a QgsPoint in map coordinates. More...
 
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. More...
 
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. More...
 
- Protected Attributes inherited from QgsSymbol
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) More...
 
Qgis::SymbolRenderHints mRenderHints
 
Qgis::SymbolFlags mSymbolFlags = Qgis::SymbolFlags()
 Symbol flags. More...
 
Qgis::SymbolType mType
 

Detailed Description

A line symbol type, for rendering LineString and MultiLineString geometries.

Definition at line 29 of file qgslinesymbol.h.

Constructor & Destructor Documentation

◆ QgsLineSymbol()

QgsLineSymbol::QgsLineSymbol ( const QgsSymbolLayerList layers = QgsSymbolLayerList())

Constructor for QgsLineSymbol, with the specified list of initial symbol layers.

Ownership of the layers are transferred to the symbol.

Definition at line 32 of file qgslinesymbol.cpp.

Member Function Documentation

◆ clone()

QgsLineSymbol * QgsLineSymbol::clone ( ) const
overridevirtual

Returns a deep copy of this symbol.

Ownership is transferred to the caller.

Implements QgsSymbol.

Definition at line 274 of file qgslinesymbol.cpp.

◆ createSimple()

QgsLineSymbol * QgsLineSymbol::createSimple ( const QVariantMap &  properties)
static

Create a line symbol with one symbol layer: SimpleLine with specified properties.

This is a convenience method for easier creation of line symbols.

Definition at line 21 of file qgslinesymbol.cpp.

◆ dataDefinedWidth()

QgsProperty QgsLineSymbol::dataDefinedWidth ( ) const

Returns data defined width for whole symbol (including all symbol layers).

Returns
data defined width, or invalid property if size is not set at the line level. Caller takes responsibility for deleting the returned object.
See also
setDataDefinedWidth
Since
QGIS 3.0

Definition at line 150 of file qgslinesymbol.cpp.

◆ renderPolyline()

void QgsLineSymbol::renderPolyline ( const QPolygonF &  points,
const QgsFeature f,
QgsRenderContext context,
int  layer = -1,
bool  selected = false 
)

Renders the symbol along the line joining points, using the given render context.

The f argument is used to pass the feature currently being rendered (when available).

If only a single symbol layer from the symbol should be rendered, it should be specified in the layer argument. A layer of -1 indicates that all symbol layers should be rendered.

If selected is true then the symbol will be drawn using the "selected feature" style and colors instead of the symbol's normal style.

Definition at line 204 of file qgslinesymbol.cpp.

◆ setDataDefinedWidth()

void QgsLineSymbol::setDataDefinedWidth ( const QgsProperty property)

Set data defined width for whole symbol (including all symbol layers).

See also
dataDefinedWidth()
Since
QGIS 3.0

Definition at line 114 of file qgslinesymbol.cpp.

◆ setWidth()

void QgsLineSymbol::setWidth ( double  width)

Sets the width for the whole line symbol.

Individual symbol layer sizes will be scaled to maintain their current relative size to the whole symbol size.

See also
width()

Definition at line 39 of file qgslinesymbol.cpp.

◆ setWidthUnit()

void QgsLineSymbol::setWidthUnit ( QgsUnitTypes::RenderUnit  unit)

Sets the width units for the whole symbol (including all symbol layers).

Parameters
unitsize units
Since
QGIS 3.16

Definition at line 66 of file qgslinesymbol.cpp.

◆ width() [1/2]

double QgsLineSymbol::width ( ) const

Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol layers in the symbol.

Warning
This returned value is inaccurate if the symbol consists of multiple symbol layers with different width units. Use the overload accepting a QgsRenderContext argument instead for accurate sizes in this case.
See also
setWidth()

Definition at line 79 of file qgslinesymbol.cpp.

◆ width() [2/2]

double QgsLineSymbol::width ( const QgsRenderContext context) const

Returns the symbol width, in painter units.

This is the maximum width of all marker symbol layers in the symbol.

This method returns an accurate width by calculating the actual rendered width of each symbol layer using the provided render context.

See also
setWidth()
Since
QGIS 3.4.5

Definition at line 99 of file qgslinesymbol.cpp.


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