QgsSimpleMarkerSymbolLayerBase class
Abstract base class for simple marker symbol layers.
Contents
Handles creation of the symbol shapes but leaves the actual drawing of the symbols to subclasses.
Base classes
- class QgsMarkerSymbolLayer
- Abstract base class for marker symbol layers.
Derived classes
- class QgsFilledMarkerSymbolLayer
- Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
- class QgsSimpleMarkerSymbolLayer
- Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
Public types
- enum Shape { Square, Diamond, Pentagon, Hexagon, Triangle, EquilateralTriangle, Star, Arrow, Circle, Cross, CrossFill, Cross2, Line, ArrowHead, ArrowHeadFilled, SemiCircle, ThirdCircle, QuarterCircle, QuarterSquare, HalfSquare, DiagonalHalfSquare, RightHalfTriangle, LeftHalfTriangle }
- Marker symbol shapes.
Public static functions
-
static auto availableShapes() -> QList<QgsSimpleMarkerSymbolLayerBase::
Shape> - Returns a list of all available shape types.
-
static auto decodeShape(const QString& name,
bool* ok = nullptr) -> QgsSimpleMarkerSymbolLayerBase::
Shape - Attempts to decode a string representation of a shape name to the corresponding shape.
-
static auto encodeShape(QgsSimpleMarkerSymbolLayerBase::
Shape shape) -> QString - Encodes a shape to its string representation.
-
static auto shapeIsFilled(QgsSimpleMarkerSymbolLayerBase::
Shape shape) -> bool - Returns true if a symbol shape has a fill.
Constructors, destructors, conversion operators
-
QgsSimpleMarkerSymbolLayerBase(QgsSimpleMarkerSymbolLayerBase::
Shape shape = Circle, double size = DEFAULT_ SIMPLEMARKER_ SIZE, double angle = DEFAULT_ SIMPLEMARKER_ ANGLE, QgsSymbol:: ScaleMethod scaleMethod = DEFAULT_ SCALE_ METHOD) - Constructor for QgsSimpleMarkerSymbolLayerBase.
Public functions
- auto bounds(QPointF point, QgsSymbolRenderContext& context) -> QRectF override
- 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.
- void renderPoint(QPointF point, QgsSymbolRenderContext& context) override
- Renders a marker at the specified point.
-
void setShape(QgsSimpleMarkerSymbolLayerBase::
Shape shape) - Sets the rendered marker shape.
-
auto shape() const -> QgsSimpleMarkerSymbolLayerBase::
Shape - Returns the shape for the rendered marker symbol.
Protected functions
- void calculateOffsetAndRotation(QgsSymbolRenderContext& context, double scaledSize, bool& hasDataDefinedRotation, QPointF& offset, double& angle) const
- Calculates the marker offset and rotation.
- auto calculateSize(QgsSymbolRenderContext& context, bool& hasDataDefinedSize) const -> double
- Calculates the desired size of the marker, considering data defined size overrides.
- auto prepareMarkerPath(Shape symbol) -> bool
- Prepares the layer for drawing the specified shape (QPainterPath version)
- auto prepareMarkerShape(Shape shape) -> bool
- Prepares the layer for drawing the specified shape (QPolygonF version)
- auto shapeToPolygon(Shape shape, QPolygonF& polygon) const -> bool
- Creates a polygon representing the specified shape.
Protected variables
Private functions
-
void draw(QgsSymbolRenderContext& context,
QgsSimpleMarkerSymbolLayerBase::
Shape shape, const QPolygonF& polygon, const QPainterPath& path) =0SIP_FORCE virtual - Derived classes must implement draw() to handle drawing the generated shape onto the painter surface.
Enum documentation
enum QgsSimpleMarkerSymbolLayerBase:: Shape
Marker symbol shapes.
| Enumerators | |
|---|---|
| Square |
Square. |
| Diamond |
Diamond. |
| Pentagon |
Pentagon. |
| Hexagon |
Hexagon. |
| Triangle |
Triangle. |
| EquilateralTriangle |
Equilateral triangle. |
| Star |
Star. |
| Arrow |
Arrow. |
| Circle |
Circle. |
| Cross |
Cross (lines only) |
| CrossFill |
Solid filled cross. |
| Cross2 |
Rotated cross (lines only), "x" shape. |
| Line |
Vertical line. |
| ArrowHead |
Right facing arrow head (unfilled, lines only) |
| ArrowHeadFilled |
Right facing filled arrow head. |
| SemiCircle |
Semi circle (top half) |
| ThirdCircle |
One third circle (top left third) |
| QuarterCircle |
Quarter circle (top left quarter) |
| QuarterSquare |
Quarter square (top left quarter) |
| HalfSquare |
Half square (left half) |
| DiagonalHalfSquare |
Diagonal half square (bottom left half) |
| RightHalfTriangle |
Right half of triangle. |
| LeftHalfTriangle |
Left half of triangle. |
Function documentation
static QgsSimpleMarkerSymbolLayerBase:: Shape QgsSimpleMarkerSymbolLayerBase:: decodeShape(const QString& name,
bool* ok = nullptr)
Attempts to decode a string representation of a shape name to the corresponding shape.
| Parameters | |
|---|---|
| name | encoded shape name |
| ok | if specified, will be set to true if shape was successfully decoded |
| Returns | decoded name |
static QString QgsSimpleMarkerSymbolLayerBase:: encodeShape(QgsSimpleMarkerSymbolLayerBase:: Shape shape)
Encodes a shape to its string representation.
| Parameters | |
|---|---|
| shape | shape to encode |
| Returns | encoded string |
static bool QgsSimpleMarkerSymbolLayerBase:: shapeIsFilled(QgsSimpleMarkerSymbolLayerBase:: Shape shape)
Returns true if a symbol shape has a fill.
| Parameters | |
|---|---|
| shape | shape to test |
| Returns | true if shape uses a fill, or false if shape uses lines only |
QgsSimpleMarkerSymbolLayerBase:: QgsSimpleMarkerSymbolLayerBase(QgsSimpleMarkerSymbolLayerBase:: Shape shape = Circle,
double size = DEFAULT_ SIMPLEMARKER_ SIZE,
double angle = DEFAULT_ SIMPLEMARKER_ ANGLE,
QgsSymbol:: ScaleMethod scaleMethod = DEFAULT_ SCALE_ METHOD)
Constructor for QgsSimpleMarkerSymbolLayerBase.
| Parameters | |
|---|---|
| shape | symbol shape for markers |
| size | symbol size (in mm) |
| angle | symbol rotation angle |
| scaleMethod | scaling method for data defined scaling |
QRectF QgsSimpleMarkerSymbolLayerBase:: bounds(QPointF point,
QgsSymbolRenderContext& context) override
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 |
|---|
void QgsSimpleMarkerSymbolLayerBase:: renderPoint(QPointF point,
QgsSymbolRenderContext& context) override
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.
void QgsSimpleMarkerSymbolLayerBase:: setShape(QgsSimpleMarkerSymbolLayerBase:: Shape shape)
Sets the rendered marker shape.
| Parameters | |
|---|---|
| shape | new marker shape |
QgsSimpleMarkerSymbolLayerBase:: Shape QgsSimpleMarkerSymbolLayerBase:: shape() const
Returns the shape for the rendered marker symbol.
void QgsSimpleMarkerSymbolLayerBase:: calculateOffsetAndRotation(QgsSymbolRenderContext& context,
double scaledSize,
bool& hasDataDefinedRotation,
QPointF& offset,
double& angle) const protected
Calculates the marker offset and rotation.
| Parameters | |
|---|---|
| context | symbol render context |
| scaledSize | size of symbol to render |
| hasDataDefinedRotation | will be set to true if marker has data defined rotation |
| offset | will be set to calculated marker offset (in painter units) |
| angle | will be set to calculated marker angle |
double QgsSimpleMarkerSymbolLayerBase:: calculateSize(QgsSymbolRenderContext& context,
bool& hasDataDefinedSize) const protected
Calculates the desired size of the marker, considering data defined size overrides.
| Parameters | |
|---|---|
| context | symbol render context |
| hasDataDefinedSize | will be set to true if marker uses data defined sizes |
| Returns | marker size, in original size units |
bool QgsSimpleMarkerSymbolLayerBase:: shapeToPolygon(Shape shape,
QPolygonF& polygon) const protected
Creates a polygon representing the specified shape.
| Parameters | |
|---|---|
| shape | shape to create |
| polygon | destination polygon for shape |
| Returns | true if shape was successfully stored in polygon |
void QgsSimpleMarkerSymbolLayerBase:: draw(QgsSymbolRenderContext& context,
QgsSimpleMarkerSymbolLayerBase:: Shape shape,
const QPolygonF& polygon,
const QPainterPath& path) =0SIP_FORCE virtual private
Derived classes must implement draw() to handle drawing the generated shape onto the painter surface.
| Parameters | |
|---|---|
| context | symbol render context |
| shape | shape to draw |
| polygon | polygon representing transformed marker shape. May be empty, in which case the shape will be specified in the path argument. |
| path | transformed painter path representing shape to draw |