QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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  public:
42 
46  enum class DirectionSymbolPlacement : int
47  {
49  SymbolAbove,
50  SymbolBelow
51  };
52 
56  enum class AnchorType : int
57  {
58  HintOnly,
59  Strict,
60  };
61 
68  QgsLabeling::LinePlacementFlags placementFlags() const { return mPlacementFlags; }
69 
76  void setPlacementFlags( QgsLabeling::LinePlacementFlags flags ) { mPlacementFlags = flags; }
77 
84  bool mergeLines() const { return mMergeLines; }
85 
92  void setMergeLines( bool merge ) { mMergeLines = merge; }
93 
98  void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context );
99 
111  bool addDirectionSymbol() const { return mAddDirectionSymbol; }
112 
124  void setAddDirectionSymbol( bool enabled ) { mAddDirectionSymbol = enabled; }
125 
133  QString leftDirectionSymbol() const { return mLeftDirectionSymbol; }
134 
142  void setLeftDirectionSymbol( const QString &symbol ) { mLeftDirectionSymbol = symbol; }
143 
151  QString rightDirectionSymbol() const { return mRightDirectionSymbol; }
152 
160  void setRightDirectionSymbol( const QString &symbol ) { mRightDirectionSymbol = symbol; }
161 
167  bool reverseDirectionSymbol() const { return mReverseDirectionSymbol; }
168 
174  void setReverseDirectionSymbol( bool reversed ) { mReverseDirectionSymbol = reversed; }
175 
184  DirectionSymbolPlacement directionSymbolPlacement() const { return mPlaceDirectionSymbol; }
185 
194  void setDirectionSymbolPlacement( DirectionSymbolPlacement placement ) { mPlaceDirectionSymbol = placement; }
195 
202  double overrunDistance() const { return mOverrunDistance; }
203 
210  void setOverrunDistance( double distance ) { mOverrunDistance = distance; }
211 
218  QgsUnitTypes::RenderUnit overrunDistanceUnit() const {return mOverrunDistanceUnit; }
219 
226  void setOverrunDistanceUnit( const QgsUnitTypes::RenderUnit &unit ) { mOverrunDistanceUnit = unit;}
227 
234  QgsMapUnitScale overrunDistanceMapUnitScale() const { return mOverrunDistanceMapUnitScale; }
235 
242  void setOverrunDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mOverrunDistanceMapUnitScale = scale; }
243 
255  double lineAnchorPercent() const { return mLineAnchorPercent; }
256 
268  void setLineAnchorPercent( double percent ) { mLineAnchorPercent = percent; }
269 
277  AnchorType anchorType() const { return mAnchorType; }
278 
286  void setAnchorType( AnchorType type ) { mAnchorType = type; }
287 
288  private:
289  QgsLabeling::LinePlacementFlags mPlacementFlags = QgsLabeling::LinePlacementFlag::AboveLine | QgsLabeling::LinePlacementFlag::MapOrientation;
290  bool mMergeLines = false;
291  bool mAddDirectionSymbol = false;
292  QString mLeftDirectionSymbol = QString( '<' );
293  QString mRightDirectionSymbol = QString( '>' );
294  bool mReverseDirectionSymbol = false;
295  DirectionSymbolPlacement mPlaceDirectionSymbol = DirectionSymbolPlacement::SymbolLeftRight;
296  double mOverrunDistance = 0;
298  QgsMapUnitScale mOverrunDistanceMapUnitScale;
299 
300  double mLineAnchorPercent = 0.5;
301  AnchorType mAnchorType = AnchorType::HintOnly;
302 };
303 
304 #endif // QGSLABELLINESETTINGS_H
QgsLabelLineSettings::setDirectionSymbolPlacement
void setDirectionSymbolPlacement(DirectionSymbolPlacement placement)
Sets the placement for direction symbols.
Definition: qgslabellinesettings.h:194
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
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:160
SymbolLeftRight
SymbolLeftRight
Place direction symbols on left/right of label.
Definition: qgspallabeling.h:310
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:210
QgsLabelLineSettings::setOverrunDistanceUnit
void setOverrunDistanceUnit(const QgsUnitTypes::RenderUnit &unit)
Sets the unit for label overrun distance.
Definition: qgslabellinesettings.h:226
MapOrientation
MapOrientation
Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather than the...
Definition: qgspallabeling.h:280
AboveLine
AboveLine
Labels can be placed above a line feature.
Definition: qgspallabeling.h:274
qgsunittypes.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
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:92
QgsLabelLineSettings::reverseDirectionSymbol
bool reverseDirectionSymbol() const
Returns true if direction symbols should be reversed.
Definition: qgslabellinesettings.h:167
QgsLabelLineSettings::leftDirectionSymbol
QString leftDirectionSymbol() const
Returns the string to use for left direction arrows.
Definition: qgslabellinesettings.h:133
QgsLabelLineSettings::overrunDistanceMapUnitScale
QgsMapUnitScale overrunDistanceMapUnitScale() const
Returns the map unit scale for label overrun distance.
Definition: qgslabellinesettings.h:234
QgsLabelLineSettings::setOverrunDistanceMapUnitScale
void setOverrunDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for label overrun distance.
Definition: qgslabellinesettings.h:242
QgsLabelLineSettings::lineAnchorPercent
double lineAnchorPercent() const
Returns the percent along the line at which labels should be placed.
Definition: qgslabellinesettings.h:255
QgsLabelLineSettings::mergeLines
bool mergeLines() const
Returns true if connected line features with identical label text should be merged prior to generatin...
Definition: qgslabellinesettings.h:84
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:202
qgis_sip.h
QgsLabelLineSettings::rightDirectionSymbol
QString rightDirectionSymbol() const
Returns the string to use for right direction arrows.
Definition: qgslabellinesettings.h:151
QgsLabelLineSettings::anchorType
AnchorType anchorType() const
Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
Definition: qgslabellinesettings.h:277
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:38
QgsLabelLineSettings::AnchorType
AnchorType
Line anchor types.
Definition: qgslabellinesettings.h:57
QgsLabelLineSettings::setLineAnchorPercent
void setLineAnchorPercent(double percent)
Sets the percent along the line at which labels should be placed.
Definition: qgslabellinesettings.h:268
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:319
qgslabeling.h
QgsLabelLineSettings
Contains settings related to how the label engine places and formats labels for line features (or pol...
Definition: qgslabellinesettings.h:40
QgsLabelLineSettings::overrunDistanceUnit
QgsUnitTypes::RenderUnit overrunDistanceUnit() const
Returns the units for label overrun distance.
Definition: qgslabellinesettings.h:218
QgsLabelLineSettings::setAddDirectionSymbol
void setAddDirectionSymbol(bool enabled)
Sets whether '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will...
Definition: qgslabellinesettings.h:124
QgsLabelLineSettings::setAnchorType
void setAnchorType(AnchorType type)
Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
Definition: qgslabellinesettings.h:286
QgsLabelLineSettings::setLeftDirectionSymbol
void setLeftDirectionSymbol(const QString &symbol)
Sets the string to use for left direction arrows.
Definition: qgslabellinesettings.h:142
qgsmapunitscale.h
QgsLabelLineSettings::placementFlags
QgsLabeling::LinePlacementFlags placementFlags() const
Returns the line placement flags, which dictate how line labels can be placed above or below the line...
Definition: qgslabellinesettings.h:68
QgsLabelLineSettings::directionSymbolPlacement
DirectionSymbolPlacement directionSymbolPlacement() const
Returns the placement for direction symbols.
Definition: qgslabellinesettings.h:184
QgsLabelLineSettings::addDirectionSymbol
bool addDirectionSymbol() const
Returns true if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) w...
Definition: qgslabellinesettings.h:111
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:76
QgsLabelLineSettings::DirectionSymbolPlacement
DirectionSymbolPlacement
Placement options for direction symbols.
Definition: qgslabellinesettings.h:47
SymbolAbove
SymbolAbove
Place direction symbols on above label.
Definition: qgspallabeling.h:311
QgsLabelLineSettings::setReverseDirectionSymbol
void setReverseDirectionSymbol(bool reversed)
Sets whether the direction symbols should be reversed.
Definition: qgslabellinesettings.h:174