QgsMarkerSymbolLayer class

Abstract base class for marker symbol layers.

Derived classes

class QgsEllipseSymbolLayer
A symbol layer for rendering objects with major and minor axis (e.g.
class QgsRasterMarkerSymbolLayer
Raster marker symbol layer class.
class QgsSimpleMarkerSymbolLayerBase
Abstract base class for simple marker symbol layers.
class QgsVectorFieldSymbolLayer
A symbol layer class for displaying displacement arrows based on point layer attributes.

Public types

enum HorizontalAnchorPoint { Left, HCenter, Right }
Symbol horizontal anchor points.
enum VerticalAnchorPoint { Top, VCenter, Bottom }
Symbol vertical anchor points.

Constructors, destructors, conversion operators

QgsMarkerSymbolLayer(bool locked = false) protected
Constructor for QgsMarkerSymbolLayer.

Public functions

auto angle() const -> double
Returns the rotation angle for the marker, in degrees clockwise from north.
auto bounds(QPointF point, QgsSymbolRenderContext& context) -> QRectF pure virtual
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.
auto horizontalAnchorPoint() const -> HorizontalAnchorPoint
Returns the horizontal anchor point for positioning the symbol.
auto offset() const -> QPointF
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered marker will have from the original feature's geometry.
auto offsetMapUnitScale() const -> const QgsMapUnitScale&
Returns the map unit scale for the symbol's offset.
auto offsetUnit() const -> QgsUnitTypes::RenderUnit
Returns the units for the symbol's offset.
auto outputUnit() const -> QgsUnitTypes::RenderUnit override
Returns the units to use for sizes and widths within the symbol layer.
void renderPoint(QPointF point, QgsSymbolRenderContext& context) pure virtual
Renders a marker at the specified point.
auto scaleMethod() const -> QgsSymbol::ScaleMethod
Returns the method to use for scaling the marker's size.
void setAngle(double angle)
Sets the rotation angle for the marker.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker should have from the original feature's geometry.
void setOffsetMapUnitScale(const QgsMapUnitScale& scale)
Sets the map unit scale for the symbol's offset.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
void setOutputUnit(QgsUnitTypes::RenderUnit unit) override
Sets the units to use for sizes and widths within the symbol layer.
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
void setSize(double size)
Sets the symbol size.
void setSizeMapUnitScale(const QgsMapUnitScale& scale)
Sets the map unit scale for the symbol's size.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
auto size() const -> double
Returns the symbol size.
auto sizeMapUnitScale() const -> const QgsMapUnitScale&
Returns the map unit scale for the symbol's size.
auto sizeUnit() const -> QgsUnitTypes::RenderUnit
Returns the units for the symbol's size.
auto verticalAnchorPoint() const -> VerticalAnchorPoint
Returns the vertical anchor point for positioning the symbol.
void writeSldMarker(QDomDocument& doc, QDomElement& element, const QgsStringMap& props) const virtual
Writes the symbol layer definition as a SLD XML element.

Protected static functions

static auto _rotatedOffset(QPointF offset, double angle) -> QPointF
Adjusts a marker offset to account for rotation.

Protected functions

void markerOffset(QgsSymbolRenderContext& context, double& offsetX, double& offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.
void markerOffset(QgsSymbolRenderContext& context, double width, double height, double& offsetX, double& offsetY) const
Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.
void markerOffset(QgsSymbolRenderContext& context, double width, double height, QgsUnitTypes::RenderUnit widthUnit, QgsUnitTypes::RenderUnit heightUnit, double& offsetX, double& offsetY, const QgsMapUnitScale& widthMapUnitScale, const QgsMapUnitScale& heightMapUnitScale) const

Protected variables

double mAngle
Marker rotation angle, in degrees clockwise from north.
HorizontalAnchorPoint mHorizontalAnchorPoint
Horizontal anchor point.
double mLineAngle
Line rotation angle (see setLineAngle() for details)
QPointF mOffset
Marker offset.
QgsMapUnitScale mOffsetMapUnitScale
Offset map unit scale.
QgsUnitTypes::RenderUnit mOffsetUnit
Offset units.
QgsSymbol::ScaleMethod mScaleMethod
Marker size scaling method.
double mSize
Marker size.
QgsMapUnitScale mSizeMapUnitScale
Marker size map unit scale.
QgsUnitTypes::RenderUnit mSizeUnit
Marker size unit.
VerticalAnchorPoint mVerticalAnchorPoint
Vertical anchor point.

Enum documentation

enum QgsMarkerSymbolLayer::HorizontalAnchorPoint

Symbol horizontal anchor points.

Enumerators
Left

Align to left side of symbol.

HCenter

Align to horizontal center of symbol.

Right

Align to right side of symbol.

enum QgsMarkerSymbolLayer::VerticalAnchorPoint

Symbol vertical anchor points.

Enumerators
Top

Align to top of symbol.

VCenter

Align to vertical center of symbol.

Bottom

Align to bottom of symbol.

Function documentation

QgsMarkerSymbolLayer::QgsMarkerSymbolLayer(bool locked = false) protected

Constructor for QgsMarkerSymbolLayer.

Parameters
locked set to true to lock symbol color

double QgsMarkerSymbolLayer::angle() const

Returns the rotation angle for the marker, in degrees clockwise from north.

QRectF QgsMarkerSymbolLayer::bounds(QPointF point, QgsSymbolRenderContext& context) pure virtual

Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.

Returns approximate symbol bounds, in painter units

HorizontalAnchorPoint QgsMarkerSymbolLayer::horizontalAnchorPoint() const

Returns the horizontal anchor point for positioning the symbol.

The symbol will be drawn so that the horizontal anchor point is aligned with the marker's desired location.

QPointF QgsMarkerSymbolLayer::offset() const

Returns the marker's offset, which is the horizontal and vertical displacement which the rendered marker will have from the original feature's geometry.

Units are specified by offsetUnit().

const QgsMapUnitScale& QgsMarkerSymbolLayer::offsetMapUnitScale() const

Returns the map unit scale for the symbol's offset.

QgsUnitTypes::RenderUnit QgsMarkerSymbolLayer::offsetUnit() const

Returns the units for the symbol's offset.

QgsUnitTypes::RenderUnit QgsMarkerSymbolLayer::outputUnit() const override

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

Returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol layer contains mixed units

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

void QgsMarkerSymbolLayer::renderPoint(QPointF point, QgsSymbolRenderContext& context) pure virtual

Renders a marker at the specified point.

Parameters
point position at which to render point, in painter units
context symbol render context

Derived classes must implement this to handle drawing the point.

QgsSymbol::ScaleMethod QgsMarkerSymbolLayer::scaleMethod() const

Returns the method to use for scaling the marker's size.

void QgsMarkerSymbolLayer::setAngle(double angle)

Sets the rotation angle for the marker.

Parameters
angle angle in degrees clockwise from north.

void QgsMarkerSymbolLayer::setHorizontalAnchorPoint(HorizontalAnchorPoint h)

Sets the horizontal anchor point for positioning the symbol.

Parameters
h anchor point. Symbol will be drawn so that the horizontal anchor point is aligned with the marker's desired location.

void QgsMarkerSymbolLayer::setLineAngle(double lineAngle)

Sets the line angle modification for the symbol's angle.

Parameters
lineAngle Angle in degrees clockwise from north, valid values are between 0 and 360

This angle is added to the marker's rotation and data defined rotation before rendering the symbol, and is usually used for orienting symbols to match a line's angle.

void QgsMarkerSymbolLayer::setOffset(QPointF offset)

Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker should have from the original feature's geometry.

Parameters
offset marker offset. Units are specified by offsetUnit()

void QgsMarkerSymbolLayer::setOffsetMapUnitScale(const QgsMapUnitScale& scale)

Sets the map unit scale for the symbol's offset.

Parameters
scale offset map unit scale

void QgsMarkerSymbolLayer::setOffsetUnit(QgsUnitTypes::RenderUnit unit)

Sets the units for the symbol's offset.

Parameters
unit offset units

void QgsMarkerSymbolLayer::setOutputUnit(QgsUnitTypes::RenderUnit unit) override

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

Parameters
unit output units

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

void QgsMarkerSymbolLayer::setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)

Sets the method to use for scaling the marker's size.

Parameters
scaleMethod scale method

void QgsMarkerSymbolLayer::setSize(double size)

Sets the symbol size.

Parameters
size symbol size. Units are specified by sizeUnit().

void QgsMarkerSymbolLayer::setSizeMapUnitScale(const QgsMapUnitScale& scale)

Sets the map unit scale for the symbol's size.

Parameters
scale size map unit scale

void QgsMarkerSymbolLayer::setSizeUnit(QgsUnitTypes::RenderUnit unit)

Sets the units for the symbol's size.

Parameters
unit size units

void QgsMarkerSymbolLayer::setVerticalAnchorPoint(VerticalAnchorPoint v)

Sets the vertical anchor point for positioning the symbol.

Parameters
v anchor point. Symbol will be drawn so that the vertical anchor point is aligned with the marker's desired location.

double QgsMarkerSymbolLayer::size() const

Returns the symbol size.

Units are specified by sizeUnit().

const QgsMapUnitScale& QgsMarkerSymbolLayer::sizeMapUnitScale() const

Returns the map unit scale for the symbol's size.

QgsUnitTypes::RenderUnit QgsMarkerSymbolLayer::sizeUnit() const

Returns the units for the symbol's size.

VerticalAnchorPoint QgsMarkerSymbolLayer::verticalAnchorPoint() const

Returns the vertical anchor point for positioning the symbol.

The symbol will be drawn so that the vertical anchor point is aligned with the marker's desired location.

void QgsMarkerSymbolLayer::writeSldMarker(QDomDocument& doc, QDomElement& element, const QgsStringMap& props) const virtual

Writes the symbol layer definition as a SLD XML element.

Parameters
doc XML document
element parent XML element
props symbol layer definition (see properties())

static QPointF QgsMarkerSymbolLayer::_rotatedOffset(QPointF offset, double angle) protected

Adjusts a marker offset to account for rotation.

Parameters
offset offset prior to rotation
angle rotation angle in degrees clockwise from north
Returns adjusted offset

void QgsMarkerSymbolLayer::markerOffset(QgsSymbolRenderContext& context, double& offsetX, double& offsetY) const protected

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

Parameters
context symbol render context
offsetX will be set to required horizontal offset (in painter units)
offsetY will be set to required vertical offset (in painter units)

void QgsMarkerSymbolLayer::markerOffset(QgsSymbolRenderContext& context, double width, double height, double& offsetX, double& offsetY) const protected

Calculates the required marker offset, including both the symbol offset and any displacement required to align with the marker's anchor point.

Parameters
context symbol render context
width marker width
height marker height
offsetX will be set to required horizontal offset (in painter units)
offsetY will be set to required vertical offset (in painter units)

void QgsMarkerSymbolLayer::markerOffset(QgsSymbolRenderContext& context, double width, double height, QgsUnitTypes::RenderUnit widthUnit, QgsUnitTypes::RenderUnit heightUnit, double& offsetX, double& offsetY, const QgsMapUnitScale& widthMapUnitScale, const QgsMapUnitScale& heightMapUnitScale) const protected