QGIS API Documentation 4.3.0-Master (0978c174f8e)
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.h"
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgsmapunitscale.h"
23
24#include <QString>
25
28
39class CORE_EXPORT QgsLabelLineSettings
40{
41 Q_GADGET
42
43 public:
47 enum class DirectionSymbolPlacement : int
48 {
49 SymbolLeftRight,
50 SymbolAbove,
51 SymbolBelow
52 };
53 Q_ENUM( DirectionSymbolPlacement )
54
55
58 enum class AnchorType : int
59 {
60 HintOnly,
61 Strict,
62 };
63 Q_ENUM( AnchorType )
64
65
70 enum class AnchorClipping : int
71 {
72 UseVisiblePartsOfLine,
73 UseEntireLine,
74 };
75 Q_ENUM( AnchorClipping )
76
77
83 Qgis::LabelLinePlacementFlags placementFlags() const { return mPlacementFlags; }
84
91 void setPlacementFlags( Qgis::LabelLinePlacementFlags flags ) { mPlacementFlags = flags; }
92
99 bool mergeLines() const { return mMergeLines; }
100
107 void setMergeLines( bool merge ) { mMergeLines = merge; }
108
113 void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context );
114
126 bool addDirectionSymbol() const { return mAddDirectionSymbol; }
127
139 void setAddDirectionSymbol( bool enabled ) { mAddDirectionSymbol = enabled; }
140
148 QString leftDirectionSymbol() const { return mLeftDirectionSymbol; }
149
157 void setLeftDirectionSymbol( const QString &symbol ) { mLeftDirectionSymbol = symbol; }
158
166 QString rightDirectionSymbol() const { return mRightDirectionSymbol; }
167
175 void setRightDirectionSymbol( const QString &symbol ) { mRightDirectionSymbol = symbol; }
176
182 bool reverseDirectionSymbol() const { return mReverseDirectionSymbol; }
183
189 void setReverseDirectionSymbol( bool reversed ) { mReverseDirectionSymbol = reversed; }
190
199 DirectionSymbolPlacement directionSymbolPlacement() const { return mPlaceDirectionSymbol; }
200
209 void setDirectionSymbolPlacement( DirectionSymbolPlacement placement ) { mPlaceDirectionSymbol = placement; }
210
217 double overrunDistance() const { return mOverrunDistance; }
218
225 void setOverrunDistance( double distance ) { mOverrunDistance = distance; }
226
233 Qgis::RenderUnit overrunDistanceUnit() const { return mOverrunDistanceUnit; }
234
241 void setOverrunDistanceUnit( const Qgis::RenderUnit &unit ) { mOverrunDistanceUnit = unit; }
242
249 QgsMapUnitScale overrunDistanceMapUnitScale() const { return mOverrunDistanceMapUnitScale; }
250
257 void setOverrunDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mOverrunDistanceMapUnitScale = scale; }
258
272 double lineAnchorPercent() const { return mLineAnchorPercent; }
273
287 void setLineAnchorPercent( double percent ) { mLineAnchorPercent = percent; }
288
297 AnchorType anchorType() const { return mAnchorType; }
298
307 void setAnchorType( AnchorType type ) { mAnchorType = type; }
308
319 AnchorClipping anchorClipping() const { return mAnchorClipping; }
320
331 void setAnchorClipping( AnchorClipping clipping ) { mAnchorClipping = clipping; }
332
341 Qgis::TextAnchorPoint anchorTextPoint() const { return mAnchorTextPoint; }
342
351 void setAnchorTextPoint( Qgis::TextAnchorPoint point ) { mAnchorTextPoint = point; }
352
359 Qgis::CurvedLabelMode curvedLabelMode() const { return mCurvedLabelMode; }
360
367 void setCurvedLabelMode( Qgis::CurvedLabelMode mode ) { mCurvedLabelMode = mode; }
368
369 private:
371 bool mMergeLines = false;
372 bool mAddDirectionSymbol = false;
373 QString mLeftDirectionSymbol = QString( '<' );
374 QString mRightDirectionSymbol = QString( '>' );
375 bool mReverseDirectionSymbol = false;
376 DirectionSymbolPlacement mPlaceDirectionSymbol = DirectionSymbolPlacement::SymbolLeftRight;
377 double mOverrunDistance = 0;
378 Qgis::RenderUnit mOverrunDistanceUnit = Qgis::RenderUnit::Millimeters;
379 QgsMapUnitScale mOverrunDistanceMapUnitScale;
380
381 double mLineAnchorPercent = 0.5;
382 AnchorType mAnchorType = AnchorType::HintOnly;
383 AnchorClipping mAnchorClipping = AnchorClipping::UseVisiblePartsOfLine;
385
387};
388
389#endif // QGSLABELLINESETTINGS_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
CurvedLabelMode
Modes which determine how curved labels are generated and placed.
Definition qgis.h:1306
@ Default
Default curved placement, characters are placed in an optimal position along the line....
Definition qgis.h:1307
@ MapOrientation
Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather than the...
Definition qgis.h:1399
@ AboveLine
Labels can be placed above a line feature. Unless MapOrientation is also specified this mode respects...
Definition qgis.h:1397
TextAnchorPoint
Anchor point of label text.
Definition qgis.h:1475
@ FollowPlacement
Automatically set the anchor point based on the line anchor point value. Values <25% of line length w...
Definition qgis.h:1479
QFlags< LabelLinePlacementFlag > LabelLinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
Definition qgis.h:1410
RenderUnit
Rendering size units.
Definition qgis.h:5650
@ Millimeters
Millimeters.
Definition qgis.h:5651
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...
Qgis::LabelLinePlacementFlags placementFlags() const
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.
void setAnchorTextPoint(Qgis::TextAnchorPoint point)
Sets the line anchor text point, which dictates which part of the label text should be placed at the ...
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 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.
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...
Qgis::TextAnchorPoint anchorTextPoint() const
Returns the line anchor text point, which dictates which part of the label text should be placed at t...
DirectionSymbolPlacement
Placement options for direction symbols.
Qgis::CurvedLabelMode curvedLabelMode() const
Returns the mode which determine how curved labels are generated and placed.
void setRightDirectionSymbol(const QString &symbol)
Sets the string to use for right direction arrows.
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...
void setCurvedLabelMode(Qgis::CurvedLabelMode mode)
Sets the mode which determine how curved labels are generated and placed.
Struct for storing maximum and minimum scales for measurements in map units.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.