QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgslabeling.h"
22 #include "qgsunittypes.h"
23 #include "qgsmapunitscale.h"
24 #include <QString>
25 
28 
39 class CORE_EXPORT QgsLabelLineSettings
40 {
41  Q_GADGET
42 
43  public:
44 
48  enum class DirectionSymbolPlacement : int
49  {
50  SymbolLeftRight,
51  SymbolAbove,
52  SymbolBelow
53  };
54  Q_ENUM( DirectionSymbolPlacement )
55 
56 
59  enum class AnchorType : int
60  {
61  HintOnly,
62  Strict,
63  };
64  Q_ENUM( AnchorType )
65 
66 
71  enum class AnchorClipping : int
72  {
73  UseVisiblePartsOfLine,
74  UseEntireLine,
75  };
76  Q_ENUM( AnchorClipping )
77 
78 
83  enum class AnchorTextPoint : int
84  {
85  StartOfText,
86  CenterOfText,
87  EndOfText,
88  FollowPlacement,
89  };
90  Q_ENUM( AnchorTextPoint )
91 
92 
98  QgsLabeling::LinePlacementFlags placementFlags() const { return mPlacementFlags; }
99 
106  void setPlacementFlags( QgsLabeling::LinePlacementFlags flags ) { mPlacementFlags = flags; }
107 
114  bool mergeLines() const { return mMergeLines; }
115 
122  void setMergeLines( bool merge ) { mMergeLines = merge; }
123 
128  void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context );
129 
141  bool addDirectionSymbol() const { return mAddDirectionSymbol; }
142 
154  void setAddDirectionSymbol( bool enabled ) { mAddDirectionSymbol = enabled; }
155 
163  QString leftDirectionSymbol() const { return mLeftDirectionSymbol; }
164 
172  void setLeftDirectionSymbol( const QString &symbol ) { mLeftDirectionSymbol = symbol; }
173 
181  QString rightDirectionSymbol() const { return mRightDirectionSymbol; }
182 
190  void setRightDirectionSymbol( const QString &symbol ) { mRightDirectionSymbol = symbol; }
191 
197  bool reverseDirectionSymbol() const { return mReverseDirectionSymbol; }
198 
204  void setReverseDirectionSymbol( bool reversed ) { mReverseDirectionSymbol = reversed; }
205 
214  DirectionSymbolPlacement directionSymbolPlacement() const { return mPlaceDirectionSymbol; }
215 
224  void setDirectionSymbolPlacement( DirectionSymbolPlacement placement ) { mPlaceDirectionSymbol = placement; }
225 
232  double overrunDistance() const { return mOverrunDistance; }
233 
240  void setOverrunDistance( double distance ) { mOverrunDistance = distance; }
241 
248  QgsUnitTypes::RenderUnit overrunDistanceUnit() const {return mOverrunDistanceUnit; }
249 
256  void setOverrunDistanceUnit( const QgsUnitTypes::RenderUnit &unit ) { mOverrunDistanceUnit = unit;}
257 
264  QgsMapUnitScale overrunDistanceMapUnitScale() const { return mOverrunDistanceMapUnitScale; }
265 
272  void setOverrunDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mOverrunDistanceMapUnitScale = scale; }
273 
287  double lineAnchorPercent() const { return mLineAnchorPercent; }
288 
302  void setLineAnchorPercent( double percent ) { mLineAnchorPercent = percent; }
303 
312  AnchorType anchorType() const { return mAnchorType; }
313 
322  void setAnchorType( AnchorType type ) { mAnchorType = type; }
323 
334  AnchorClipping anchorClipping() const { return mAnchorClipping; }
335 
346  void setAnchorClipping( AnchorClipping clipping ) { mAnchorClipping = clipping; }
347 
356  AnchorTextPoint anchorTextPoint() const { return mAnchorTextPoint; }
357 
366  void setAnchorTextPoint( AnchorTextPoint point ) { mAnchorTextPoint = point; }
367 
368  private:
369  QgsLabeling::LinePlacementFlags mPlacementFlags = QgsLabeling::LinePlacementFlag::AboveLine | QgsLabeling::LinePlacementFlag::MapOrientation;
370  bool mMergeLines = false;
371  bool mAddDirectionSymbol = false;
372  QString mLeftDirectionSymbol = QString( '<' );
373  QString mRightDirectionSymbol = QString( '>' );
374  bool mReverseDirectionSymbol = false;
375  DirectionSymbolPlacement mPlaceDirectionSymbol = DirectionSymbolPlacement::SymbolLeftRight;
376  double mOverrunDistance = 0;
378  QgsMapUnitScale mOverrunDistanceMapUnitScale;
379 
380  double mLineAnchorPercent = 0.5;
381  AnchorType mAnchorType = AnchorType::HintOnly;
382  AnchorClipping mAnchorClipping = AnchorClipping::UseVisiblePartsOfLine;
383  AnchorTextPoint mAnchorTextPoint = AnchorTextPoint::FollowPlacement;
384 };
385 
386 #endif // QGSLABELLINESETTINGS_H
QgsLabelLineSettings::setDirectionSymbolPlacement
void setDirectionSymbolPlacement(DirectionSymbolPlacement placement)
Sets the placement for direction symbols.
Definition: qgslabellinesettings.h:224
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsLabelLineSettings::setRightDirectionSymbol
void setRightDirectionSymbol(const QString &symbol)
Sets the string to use for right direction arrows.
Definition: qgslabellinesettings.h:190
QgsLabelLineSettings::anchorTextPoint
AnchorTextPoint anchorTextPoint() const
Returns the line anchor text point, which dictates which part of the label text should be placed at t...
Definition: qgslabellinesettings.h:356
QgsLabelLineSettings::setOverrunDistance
void setOverrunDistance(double distance)
Sets the distance which labels are allowed to overrun past the start or end of line features.
Definition: qgslabellinesettings.h:240
QgsLabelLineSettings::setOverrunDistanceUnit
void setOverrunDistanceUnit(const QgsUnitTypes::RenderUnit &unit)
Sets the unit for label overrun distance.
Definition: qgslabellinesettings.h:256
qgsunittypes.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsLabelLineSettings::setMergeLines
void setMergeLines(bool merge)
Sets whether connected line features with identical label text should be merged prior to generating l...
Definition: qgslabellinesettings.h:122
QgsLabelLineSettings::reverseDirectionSymbol
bool reverseDirectionSymbol() const
Returns true if direction symbols should be reversed.
Definition: qgslabellinesettings.h:197
QgsLabelLineSettings::setAnchorTextPoint
void setAnchorTextPoint(AnchorTextPoint point)
Sets the line anchor text point, which dictates which part of the label text should be placed at the ...
Definition: qgslabellinesettings.h:366
QgsLabelLineSettings::setAnchorClipping
void setAnchorClipping(AnchorClipping clipping)
Sets the line anchor clipping mode, which dictates how line strings are clipped before calculating th...
Definition: qgslabellinesettings.h:346
QgsLabelLineSettings::leftDirectionSymbol
QString leftDirectionSymbol() const
Returns the string to use for left direction arrows.
Definition: qgslabellinesettings.h:163
QgsLabelLineSettings::overrunDistanceMapUnitScale
QgsMapUnitScale overrunDistanceMapUnitScale() const
Returns the map unit scale for label overrun distance.
Definition: qgslabellinesettings.h:264
QgsLabelLineSettings::setOverrunDistanceMapUnitScale
void setOverrunDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for label overrun distance.
Definition: qgslabellinesettings.h:272
QgsLabelLineSettings::lineAnchorPercent
double lineAnchorPercent() const
Returns the percent along the line at which labels should be placed.
Definition: qgslabellinesettings.h:287
QgsLabelLineSettings::mergeLines
bool mergeLines() const
Returns true if connected line features with identical label text should be merged prior to generatin...
Definition: qgslabellinesettings.h:114
QgsLabelLineSettings::overrunDistance
double overrunDistance() const
Returns the distance which labels are allowed to overrun past the start or end of line features.
Definition: qgslabellinesettings.h:232
QgsLabelLineSettings::anchorClipping
AnchorClipping anchorClipping() const
Returns the line anchor clipping mode, which dictates how line strings are clipped before calculating...
Definition: qgslabellinesettings.h:334
QgsLabeling
Contains constants and enums relating to labeling.
Definition: qgslabeling.h:31
qgis_sip.h
QgsLabelLineSettings::rightDirectionSymbol
QString rightDirectionSymbol() const
Returns the string to use for right direction arrows.
Definition: qgslabellinesettings.h:181
QgsLabelLineSettings::anchorType
AnchorType anchorType() const
Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
Definition: qgslabellinesettings.h:312
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsLabelLineSettings::AnchorTextPoint
AnchorTextPoint
Anchor point of label text.
Definition: qgslabellinesettings.h:83
QgsLabelLineSettings::AnchorType
AnchorType
Line anchor types.
Definition: qgslabellinesettings.h:59
QgsLabelLineSettings::setLineAnchorPercent
void setLineAnchorPercent(double percent)
Sets the percent along the line at which labels should be placed.
Definition: qgslabellinesettings.h:302
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
qgslabeling.h
QgsLabelLineSettings
Contains settings related to how the label engine places and formats labels for line features (or pol...
Definition: qgslabellinesettings.h:39
QgsLabelLineSettings::overrunDistanceUnit
QgsUnitTypes::RenderUnit overrunDistanceUnit() const
Returns the units for label overrun distance.
Definition: qgslabellinesettings.h:248
QgsLabelLineSettings::setAddDirectionSymbol
void setAddDirectionSymbol(bool enabled)
Sets whether '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will...
Definition: qgslabellinesettings.h:154
QgsLabelLineSettings::setAnchorType
void setAnchorType(AnchorType type)
Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
Definition: qgslabellinesettings.h:322
QgsLabelLineSettings::setLeftDirectionSymbol
void setLeftDirectionSymbol(const QString &symbol)
Sets the string to use for left direction arrows.
Definition: qgslabellinesettings.h:172
qgsmapunitscale.h
QgsLabelLineSettings::directionSymbolPlacement
DirectionSymbolPlacement directionSymbolPlacement() const
Returns the placement for direction symbols.
Definition: qgslabellinesettings.h:214
QgsLabelLineSettings::addDirectionSymbol
bool addDirectionSymbol() const
Returns true if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) w...
Definition: qgslabellinesettings.h:141
QgsLabelLineSettings::AnchorClipping
AnchorClipping
Clipping behavior for line anchor calculation.
Definition: qgslabellinesettings.h:71
QgsLabelLineSettings::setPlacementFlags
void setPlacementFlags(QgsLabeling::LinePlacementFlags flags)
Returns the line placement flags, which dictate how line labels can be placed above or below the line...
Definition: qgslabellinesettings.h:106
QgsLabelLineSettings::DirectionSymbolPlacement
DirectionSymbolPlacement
Placement options for direction symbols.
Definition: qgslabellinesettings.h:48
QgsLabelLineSettings::setReverseDirectionSymbol
void setReverseDirectionSymbol(bool reversed)
Sets whether the direction symbols should be reversed.
Definition: qgslabellinesettings.h:204