QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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_core.h"
19#include "qgis.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
48 QgsLinearReferencingSymbolLayer *clone() const override SIP_FACTORY;
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
63 QgsTextFormat textFormat() const;
64
70 void setTextFormat( const QgsTextFormat &format );
71
77 QgsNumericFormat *numericFormat() const;
78
86 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
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
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
LinearReferencingPlacement
Defines how/where the labels should be placed in a linear referencing symbol layer.
Definition qgis.h:2926
@ IntervalCartesian2D
Place labels at regular intervals, using Cartesian distance calculations on a 2D plane.
LinearReferencingLabelSource
Defines what quantity to use for the labels shown in a linear referencing symbol layer.
Definition qgis.h:2940
@ CartesianDistance2D
Distance along line, calculated using Cartesian calculations on a 2D plane.
RenderUnit
Rendering size units.
Definition qgis.h:4847
@ Millimeters
Millimeters.
Abstract base class for all geometries.
Line string geometry type, with support for z-dimension and m-values.
Abstract base class for line symbol layers.
double offset() const
Returns the line's offset.
Line symbol layer used for decorating accordingly to linear referencing.
double averageAngleLength() const
Returns the length of line over which the line's direction is averaged when calculating individual la...
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...
Qgis::RenderUnit labelOffsetUnit() const
Returns the unit used for the offset between the line and linear referencing labels.
void setLabelOffset(const QPointF &offset)
Sets the offset between the line and linear referencing labels.
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...
Qgis::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
void setRotateLabels(bool rotate)
Sets whether the labels and symbols should be rotated to match their line segment orientation.
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.
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.
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
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:76