QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslinearreferencingsymbollayer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslinearreferencingsymbollayer.h
3 ---------------------
4 begin : August 2024
5 copyright : (C) 2024 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSLINEARREFERENCINGSYMBOLLAYER_H
16#define QGSLINEARREFERENCINGSYMBOLLAYER_H
17
18#include "qgis.h"
19#include "qgis_core.h"
20#include "qgssymbollayer.h"
21#include "qgstextformat.h"
22
24
36{
37 public:
40
46 static QgsSymbolLayer *create( const QVariantMap &properties = QVariantMap() ) SIP_FACTORY;
47
49 QVariantMap properties() const override;
50 QString layerType() const override;
51 Qgis::SymbolLayerFlags flags() const override;
52 QgsSymbol *subSymbol() override;
53 bool setSubSymbol( QgsSymbol *symbol SIP_TRANSFER ) override;
54 void startRender( QgsSymbolRenderContext &context ) override;
55 void stopRender( QgsSymbolRenderContext &context ) override;
56 void renderPolyline( const QPolygonF &points, QgsSymbolRenderContext &context ) override;
57
64
70 void setTextFormat( const QgsTextFormat &format );
71
78
87
95 double interval() const;
96
104 void setInterval( double interval );
105
116 double skipMultiplesOf() const;
117
128 void setSkipMultiplesOf( double multiple );
129
135 bool rotateLabels() const { return mRotateLabels; }
136
142 void setRotateLabels( bool rotate ) { mRotateLabels = rotate; }
143
152 QPointF labelOffset() const { return mLabelOffset; }
153
162 void setLabelOffset( const QPointF &offset ) { mLabelOffset = offset; }
163
170 Qgis::RenderUnit labelOffsetUnit() const { return mLabelOffsetUnit; }
171
178 void setLabelOffsetUnit( Qgis::RenderUnit unit ) { mLabelOffsetUnit = unit; }
179
185 const QgsMapUnitScale &labelOffsetMapUnitScale() const { return mLabelOffsetMapUnitScale; }
186
192 void setLabelOffsetMapUnitScale( const QgsMapUnitScale &scale ) { mLabelOffsetMapUnitScale = scale; }
193
201 bool showMarker() const;
202
210 void setShowMarker( bool show );
211
217 Qgis::LinearReferencingPlacement placement() const;
218
224 void setPlacement( Qgis::LinearReferencingPlacement placement );
225
231 Qgis::LinearReferencingLabelSource labelSource() const;
232
238 void setLabelSource( Qgis::LinearReferencingLabelSource source );
239
250 double averageAngleLength() const { return mAverageAngleLength; }
251
262 void setAverageAngleLength( double length ) { mAverageAngleLength = length; }
263
272 void setAverageAngleUnit( Qgis::RenderUnit unit ) { mAverageAngleLengthUnit = unit; }
273
282 Qgis::RenderUnit averageAngleUnit() const { return mAverageAngleLengthUnit; }
283
292 void setAverageAngleMapUnitScale( const QgsMapUnitScale &scale ) { mAverageAngleLengthMapUnitScale = scale; }
293
302 const QgsMapUnitScale &averageAngleMapUnitScale() const { return mAverageAngleLengthMapUnitScale; }
303
304 private:
305 void renderPolylineInterval( const QgsLineString *line, QgsSymbolRenderContext &context, double skipMultiples, const QPointF &labelOffsetPainterUnits, double averageAngleLengthPainterUnits, bool showMarker );
306 void renderPolylineVertex( const QgsLineString *line, QgsSymbolRenderContext &context, double skipMultiples, const QPointF &labelOffsetPainterUnits, double averageAngleLengthPainterUnits, bool showMarker );
307 void renderGeometryPart( QgsSymbolRenderContext &context, const QgsAbstractGeometry *geometry, double labelOffsetPainterUnitsX, double labelOffsetPainterUnitsY, double skipMultiples, double averageAngleDistancePainterUnits, bool showMarker );
308 void renderLineString( QgsSymbolRenderContext &context, const QgsLineString *line, double labelOffsetPainterUnitsX, double labelOffsetPainterUnitsY, double skipMultiples, double averageAngleDistancePainterUnits, bool showMarker );
309
310 static QPointF pointToPainter( QgsSymbolRenderContext &context, double x, double y, double z );
311
314
315 double mInterval = 1000;
316 double mSkipMultiplesOf = 0;
317 bool mRotateLabels = true;
318
319 QPointF mLabelOffset{ 1, 0 };
321 QgsMapUnitScale mLabelOffsetMapUnitScale;
322
323 QgsTextFormat mTextFormat;
324 std::unique_ptr<QgsNumericFormat> mNumericFormat;
325
326 bool mShowMarker = false;
327 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
328
329 double mAverageAngleLength = 4;
330 Qgis::RenderUnit mAverageAngleLengthUnit = Qgis::RenderUnit::Millimeters;
331 QgsMapUnitScale mAverageAngleLengthMapUnitScale;
332
333 QString mLabelProviderId;
334
335};
336
337#endif // QGSLINEARREFERENCINGSYMBOLLAYER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
LinearReferencingPlacement
Defines how/where the labels should be placed in a linear referencing symbol layer.
Definition qgis.h:3149
@ IntervalCartesian2D
Place labels at regular intervals, using Cartesian distance calculations on a 2D plane.
Definition qgis.h:3150
LinearReferencingLabelSource
Defines what quantity to use for the labels shown in a linear referencing symbol layer.
Definition qgis.h:3163
@ CartesianDistance2D
Distance along line, calculated using Cartesian calculations on a 2D plane.
Definition qgis.h:3164
RenderUnit
Rendering size units.
Definition qgis.h:5183
@ Millimeters
Millimeters.
Definition qgis.h:5184
Abstract base class for all geometries.
Line string geometry type, with support for z-dimension and m-values.
QgsLineSymbolLayer(const QgsLineSymbolLayer &other)=delete
double offset() const
Returns the line's offset.
Qgis::SymbolLayerFlags flags() const override
Returns flags which control the symbol layer's behavior.
double averageAngleLength() const
Returns the length of line over which the line's direction is averaged when calculating individual la...
void startRender(QgsSymbolRenderContext &context) override
Called before a set of rendering operations commences on the supplied render context.
void setAverageAngleUnit(Qgis::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
void setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
void setSkipMultiplesOf(double multiple)
Sets the multiple distance to skip labels for.
QVariantMap properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
Qgis::RenderUnit labelOffsetUnit() const
Returns the unit used for the offset between the line and linear referencing labels.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
void setLabelOffset(const QPointF &offset)
Sets the offset between the line and linear referencing labels.
QgsTextFormat textFormat() const
Returns the text format used to render the layer.
QString layerType() const override
Returns a string that represents this layer type.
bool rotateLabels() const
Returns true if the labels and symbols are to be rotated to match their line segment orientation.
void setNumericFormat(QgsNumericFormat *format)
Sets the numeric format used to format the labels for the layer.
QgsNumericFormat * numericFormat() const
Returns the numeric format used to format the labels for the layer.
QPointF labelOffset() const
Returns the offset between the line and linear referencing labels.
const QgsMapUnitScale & labelOffsetMapUnitScale() const
Returns the map unit scale used for calculating the offset between the line and linear referencing la...
void setInterval(double interval)
Sets the interval between labels.
Qgis::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
void stopRender(QgsSymbolRenderContext &context) override
Called after a set of rendering operations has finished on the supplied render context.
void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context) override
Renders the line symbol layer along the line joining points, using the given render context.
void setRotateLabels(bool rotate)
Sets whether the labels and symbols should be rotated to match their line segment orientation.
bool setSubSymbol(QgsSymbol *symbol) override
Sets layer's subsymbol. takes ownership of the passed symbol.
void setTextFormat(const QgsTextFormat &format)
Sets the text format used to render the layer.
const QgsMapUnitScale & averageAngleMapUnitScale() const
Returns the map unit scale for the length over which the line's direction is averaged when calculatin...
void setLabelOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset between the line and linear referencing label...
void setLabelOffsetUnit(Qgis::RenderUnit unit)
Sets the unit used for the offset between the line and linear referencing labels.
double skipMultiplesOf() const
Returns the multiple distance to skip labels for.
QgsLinearReferencingSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsLinearReferencingSymbolLayer, using the specified properties.
double interval() const
Returns the interval between labels.
void setAverageAngleLength(double length)
Sets the length of line over which the line's direction is averaged when calculating individual label...
Struct for storing maximum and minimum scales for measurements in map units.
Abstract base class for numeric formatters, which allow for formatting a numeric value for display.
QgsSymbolLayer(const QgsSymbolLayer &other)
Encapsulates the context in which a symbol is being rendered.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
Container for all settings relating to text rendering.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84