QGIS API Documentation 3.39.0-Master (93ce9bf5c90)
Loading...
Searching...
No Matches
qgslabellinesettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslabellinesettings.h
3 --------------------------
4 Date : August 2020
5 Copyright : (C) 2020 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
16#ifndef QGSLABELLINESETTINGS_H
17#define QGSLABELLINESETTINGS_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsmapunitscale.h"
22#include <QString>
23
26
37class CORE_EXPORT QgsLabelLineSettings
38{
39 Q_GADGET
40
41 public:
42
46 enum class DirectionSymbolPlacement : int
47 {
48 SymbolLeftRight,
49 SymbolAbove,
50 SymbolBelow
51 };
52 Q_ENUM( DirectionSymbolPlacement )
53
54
57 enum class AnchorType : int
58 {
59 HintOnly,
60 Strict,
61 };
62 Q_ENUM( AnchorType )
63
64
69 enum class AnchorClipping : int
70 {
71 UseVisiblePartsOfLine,
72 UseEntireLine,
73 };
74 Q_ENUM( AnchorClipping )
75
76
81 enum class AnchorTextPoint : int
82 {
83 StartOfText,
84 CenterOfText,
85 EndOfText,
86 FollowPlacement,
87 };
88 Q_ENUM( AnchorTextPoint )
89
90
96 Qgis::LabelLinePlacementFlags placementFlags() const { return mPlacementFlags; }
97
104 void setPlacementFlags( Qgis::LabelLinePlacementFlags flags ) { mPlacementFlags = flags; }
105
112 bool mergeLines() const { return mMergeLines; }
113
120 void setMergeLines( bool merge ) { mMergeLines = merge; }
121
126 void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context );
127
139 bool addDirectionSymbol() const { return mAddDirectionSymbol; }
140
152 void setAddDirectionSymbol( bool enabled ) { mAddDirectionSymbol = enabled; }
153
161 QString leftDirectionSymbol() const { return mLeftDirectionSymbol; }
162
170 void setLeftDirectionSymbol( const QString &symbol ) { mLeftDirectionSymbol = symbol; }
171
179 QString rightDirectionSymbol() const { return mRightDirectionSymbol; }
180
188 void setRightDirectionSymbol( const QString &symbol ) { mRightDirectionSymbol = symbol; }
189
195 bool reverseDirectionSymbol() const { return mReverseDirectionSymbol; }
196
202 void setReverseDirectionSymbol( bool reversed ) { mReverseDirectionSymbol = reversed; }
203
212 DirectionSymbolPlacement directionSymbolPlacement() const { return mPlaceDirectionSymbol; }
213
222 void setDirectionSymbolPlacement( DirectionSymbolPlacement placement ) { mPlaceDirectionSymbol = placement; }
223
230 double overrunDistance() const { return mOverrunDistance; }
231
238 void setOverrunDistance( double distance ) { mOverrunDistance = distance; }
239
246 Qgis::RenderUnit overrunDistanceUnit() const {return mOverrunDistanceUnit; }
247
254 void setOverrunDistanceUnit( const Qgis::RenderUnit &unit ) { mOverrunDistanceUnit = unit;}
255
262 QgsMapUnitScale overrunDistanceMapUnitScale() const { return mOverrunDistanceMapUnitScale; }
263
270 void setOverrunDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mOverrunDistanceMapUnitScale = scale; }
271
285 double lineAnchorPercent() const { return mLineAnchorPercent; }
286
300 void setLineAnchorPercent( double percent ) { mLineAnchorPercent = percent; }
301
310 AnchorType anchorType() const { return mAnchorType; }
311
320 void setAnchorType( AnchorType type ) { mAnchorType = type; }
321
332 AnchorClipping anchorClipping() const { return mAnchorClipping; }
333
344 void setAnchorClipping( AnchorClipping clipping ) { mAnchorClipping = clipping; }
345
354 AnchorTextPoint anchorTextPoint() const { return mAnchorTextPoint; }
355
364 void setAnchorTextPoint( AnchorTextPoint point ) { mAnchorTextPoint = point; }
365
366 private:
368 bool mMergeLines = false;
369 bool mAddDirectionSymbol = false;
370 QString mLeftDirectionSymbol = QString( '<' );
371 QString mRightDirectionSymbol = QString( '>' );
372 bool mReverseDirectionSymbol = false;
373 DirectionSymbolPlacement mPlaceDirectionSymbol = DirectionSymbolPlacement::SymbolLeftRight;
374 double mOverrunDistance = 0;
375 Qgis::RenderUnit mOverrunDistanceUnit = Qgis::RenderUnit::Millimeters;
376 QgsMapUnitScale mOverrunDistanceMapUnitScale;
377
378 double mLineAnchorPercent = 0.5;
379 AnchorType mAnchorType = AnchorType::HintOnly;
380 AnchorClipping mAnchorClipping = AnchorClipping::UseVisiblePartsOfLine;
381 AnchorTextPoint mAnchorTextPoint = AnchorTextPoint::FollowPlacement;
382};
383
384#endif // QGSLABELLINESETTINGS_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
@ MapOrientation
Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather than the...
@ AboveLine
Labels can be placed above a line feature. Unless MapOrientation is also specified this mode respects...
QFlags< LabelLinePlacementFlag > LabelLinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
Definition qgis.h:1221
RenderUnit
Rendering size units.
Definition qgis.h:4819
@ Millimeters
Millimeters.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Contains settings related to how the label engine places and formats labels for line features (or pol...
void setPlacementFlags(Qgis::LabelLinePlacementFlags flags)
Returns the line placement flags, which dictate how line labels can be placed above or below the line...
AnchorType
Line anchor types.
bool reverseDirectionSymbol() const
Returns true if direction symbols should be reversed.
void setLineAnchorPercent(double percent)
Sets the percent along the line at which labels should be placed.
DirectionSymbolPlacement directionSymbolPlacement() const
Returns the placement for direction symbols.
AnchorClipping
Clipping behavior for line anchor calculation.
void setDirectionSymbolPlacement(DirectionSymbolPlacement placement)
Sets the placement for direction symbols.
AnchorType anchorType() const
Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
Qgis::RenderUnit overrunDistanceUnit() const
Returns the units for label overrun distance.
QString leftDirectionSymbol() const
Returns the string to use for left direction arrows.
void setAnchorTextPoint(AnchorTextPoint point)
Sets the line anchor text point, which dictates which part of the label text should be placed at the ...
void setLeftDirectionSymbol(const QString &symbol)
Sets the string to use for left direction arrows.
QgsMapUnitScale overrunDistanceMapUnitScale() const
Returns the map unit scale for label overrun distance.
AnchorTextPoint anchorTextPoint() const
Returns the line anchor text point, which dictates which part of the label text should be placed at t...
double overrunDistance() const
Returns the distance which labels are allowed to overrun past the start or end of line features.
void setMergeLines(bool merge)
Sets whether connected line features with identical label text should be merged prior to generating l...
DirectionSymbolPlacement
Placement options for direction symbols.
void setRightDirectionSymbol(const QString &symbol)
Sets the string to use for right direction arrows.
AnchorTextPoint
Anchor point of label text.
QString rightDirectionSymbol() const
Returns the string to use for right direction arrows.
void setAnchorClipping(AnchorClipping clipping)
Sets the line anchor clipping mode, which dictates how line strings are clipped before calculating th...
void setOverrunDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for label overrun distance.
bool addDirectionSymbol() const
Returns true if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) w...
double lineAnchorPercent() const
Returns the percent along the line at which labels should be placed.
bool mergeLines() const
Returns true if connected line features with identical label text should be merged prior to generatin...
void setAnchorType(AnchorType type)
Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
void setOverrunDistanceUnit(const Qgis::RenderUnit &unit)
Sets the unit for label overrun distance.
void setOverrunDistance(double distance)
Sets the distance which labels are allowed to overrun past the start or end of line features.
AnchorClipping anchorClipping() const
Returns the line anchor clipping mode, which dictates how line strings are clipped before calculating...
void setReverseDirectionSymbol(bool reversed)
Sets whether the direction symbols should be reversed.
void setAddDirectionSymbol(bool enabled)
Sets whether '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will...
Struct for storing maximum and minimum scales for measurements in map units.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.