QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgspallabeling.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspallabeling.h
3 Smart labeling for vector layers
4 -------------------
5 begin : June 2009
6 copyright : (C) Martin Dobias
7 email : wonder dot sk at gmail dot com
8
9 ***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPALLABELING_H
19#define QGSPALLABELING_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include <QString>
24#include <QFont>
25#include <QFontDatabase>
26#include <QColor>
27#include <QHash>
28#include <QList>
29#include <QPainter>
30#include <QRectF>
31#include <QMap>
32#include "qgsfeature.h"
33#include "qgsgeometry.h"
34#include "qgsfields.h"
35#include "qgspointxy.h"
36#include "qgsmapunitscale.h"
37#include "qgsstringutils.h"
38#include "qgstextformat.h"
44#include "qgslabeling.h"
46#include "qgsexpression.h"
47
48class QgsTextDocument;
50
51namespace pal SIP_SKIP
52{
53 class Pal;
54 class Layer;
55 class LabelPosition;
56}
57
59class QgsRectangle;
60class QgsMapToPixel;
61class QgsFeature;
63class QgsVectorLayer;
64class QgsExpression;
65class QFontMetricsF;
66class QPainter;
67class QPicture;
68class QgsGeometry;
71class QgsMapSettings;
72class QgsLabelFeature;
76class QgsDxfExport;
79class QgsCallout;
80
86class CORE_EXPORT QgsPalLayerSettings
87{
88 public:
92
94 QgsPalLayerSettings &operator=( const QgsPalLayerSettings &s );
95
96 //TODO QGIS 4.0 - remove, replaced by QgsLabeling::LinePlacementFlags
97
104 {
105 OnLine = 1,
106 AboveLine = 2,
109 BelowLine = 4,
112 MapOrientation = 8,
115 };
116
119 {
122 SymbolBelow
123 };
124
125 //TODO QGIS 4.0 - Remove -- moved to QgsLabelEngineObstacleSettings
126
132 {
133 PolygonInterior,
135 PolygonBoundary,
137 PolygonWhole
141 };
142
145 {
146 // text style
147 Size = 0,
148 Bold = 1,
149 Italic = 2,
150 Underline = 3,
151 Color = 4,
152 Strikeout = 5,
153 Family = 6,
154 FontStyle = 21,
155 FontSizeUnit = 22,
156 FontTransp = 18,
157 FontOpacity = 92,
158 FontCase = 27,
159 FontLetterSpacing = 28,
160 FontWordSpacing = 29,
161 FontBlendMode = 30,
162 FontStretchFactor = 113,
163
164 // text formatting
165 MultiLineWrapChar = 31,
166 AutoWrapLength = 101,
167 MultiLineHeight = 32,
168 MultiLineAlignment = 33,
169 TextOrientation = 110,
170 DirSymbDraw = 34,
171 DirSymbLeft = 35,
172 DirSymbRight = 36,
173 DirSymbPlacement = 37,
174 DirSymbReverse = 38,
175 NumFormat = 39,
176 NumDecimals = 40,
177 NumPlusSign = 41,
178
179 // text buffer
180 BufferDraw = 42,
181 BufferSize = 7,
182 BufferUnit = 43,
183 BufferColor = 8,
184 BufferTransp = 19,
185 BufferOpacity = 94,
186 BufferJoinStyle = 44,
187 BufferBlendMode = 45,
188
189 // mask buffer
190 MaskEnabled = 104,
191 MaskBufferSize = 105,
192 MaskBufferUnit = 106,
193 MaskOpacity = 107,
194 MaskJoinStyle = 108,
195
196 // background
197 ShapeDraw = 46,
198 ShapeKind = 47,
199 ShapeSVGFile = 48,
200 ShapeSizeType = 49,
201 ShapeSizeX = 50,
202 ShapeSizeY = 85,
203 ShapeSizeUnits = 51,
204 ShapeRotationType = 52,
205 ShapeRotation = 53,
206 ShapeOffset = 54,
207 ShapeOffsetUnits = 55,
208 ShapeRadii = 56,
209 ShapeRadiiUnits = 57,
210 ShapeTransparency = 63,
211 ShapeOpacity = 93,
212 ShapeBlendMode = 64,
213 ShapeFillColor = 58,
214 ShapeStrokeColor = 59,
215 ShapeStrokeWidth = 60,
216 ShapeStrokeWidthUnits = 61,
217 ShapeJoinStyle = 62,
218
219 // drop shadow
220 ShadowDraw = 65,
221 ShadowUnder = 66,
222 ShadowOffsetAngle = 67,
223 ShadowOffsetDist = 68,
224 ShadowOffsetUnits = 69,
225 ShadowRadius = 70,
226 ShadowRadiusUnits = 71,
227 ShadowTransparency = 72,
228 ShadowOpacity = 95,
229 ShadowScale = 73,
230 ShadowColor = 74,
231 ShadowBlendMode = 75,
232
233 // placement
234 CentroidWhole = 76,
235 OffsetQuad = 77,
236 OffsetXY = 78,
237 OffsetUnits = 80,
238 LabelDistance = 13,
239 DistanceUnits = 81,
240 OffsetRotation = 82,
241 CurvedCharAngleInOut = 83,
242 // (data defined only)
243 PositionX = 9,
244 PositionY = 10,
245 PositionPoint = 114,
246 Hali = 11,
247 Vali = 12,
248 Rotation = 14,
249 LabelRotation = 96,
250 RepeatDistance = 84,
251 RepeatDistanceUnit = 86,
252 Priority = 87,
253 PredefinedPositionOrder = 91,
254 LinePlacementOptions = 99,
255 OverrunDistance = 102,
256 LabelAllParts = 103,
257 PolygonLabelOutside = 109,
258 LineAnchorPercent = 111,
259 LineAnchorClipping = 112,
260 LineAnchorType = 115,
261 LineAnchorTextPoint = 116,
262
263 // rendering
264 ScaleVisibility = 23,
265 MinScale = 16,
266 MinimumScale = 97,
267 MaxScale = 17,
268 MaximumScale = 98,
269 FontLimitPixel = 24,
270 FontMinPixel = 25,
271 FontMaxPixel = 26,
272 IsObstacle = 88,
273 ObstacleFactor = 89,
274 ZIndex = 90,
275 CalloutDraw = 100,
276
277 AllowDegradedPlacement = 117,
278 OverlapHandling = 118,
279
280 // (data defined only)
281 Show = 15,
282 AlwaysShow = 20
283 };
284
285
297 bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames SIP_INOUT, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs );
298
303 QSet<QString> referencedFields( const QgsRenderContext &context ) const;
304
313 void startRender( QgsRenderContext &context );
314
322 void stopRender( QgsRenderContext &context );
323
329 bool containsAdvancedEffects() const;
330
335 static const QgsPropertiesDefinition &propertyDefinitions();
336
345 bool drawLabels = true;
346
347 //-- text style
348
354 QString fieldName;
355
360 bool isExpression = false;
361
365 QgsExpression *getLabelExpression();
366
370 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
371
375 bool useSubstitutions = false;
376
377 //-- text formatting
378
383 QString wrapChar;
384
392 int autoWrapLength = 0;
393
404 bool useMaxLineLengthForAutoWrap = true;
405
407 Qgis::LabelMultiLineAlignment multilineAlign = Qgis::LabelMultiLineAlignment::FollowPlacement;
408
415 bool formatNumbers = false;
416
422 int decimals = 3;
423
429 bool plusSign = false;
430
431 //-- placement
432
435
442 QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const { return mPolygonPlacementFlags; }
443
450 void setPolygonPlacementFlags( QgsLabeling::PolygonPlacementFlags flags ) { mPolygonPlacementFlags = flags; }
451
456 bool centroidWhole = false;
457
463 bool centroidInside = false;
464
471 QVector< Qgis::LabelPredefinedPointPosition > predefinedPositionOrder SIP_SKIP;
472
476 bool fitInPolygonOnly = false;
477
483 double dist = 0;
484
491
498
501
507 double repeatDistance = 0;
508
515
522
526 Qgis::LabelQuadrantPosition quadOffset = Qgis::LabelQuadrantPosition::Over;
527
534 double xOffset = 0;
535
542 double yOffset = 0;
543
551
559
561 double angleOffset = 0;
562
564 bool preserveRotation = true;
565
571 QgsUnitTypes::AngleUnit rotationUnit() const;
572
578 void setRotationUnit( QgsUnitTypes::AngleUnit angleUnit );
579
584 double maxCurvedCharAngleIn = 25.0;
585
590 double maxCurvedCharAngleOut = -25.0;
591
596 int priority = 5;
597
598 //-- rendering
599
605 bool scaleVisibility = false;
606
617 double maximumScale = 0;
618
629 double minimumScale = 0;
630
636 bool fontLimitPixelSize = false;
637
643 int fontMinPixelSize = 0;
644
650 int fontMaxPixelSize = 10000;
651
653 Qgis::UpsideDownLabelHandling upsidedownLabels = Qgis::UpsideDownLabelHandling::FlipUpsideDownLabels;
654
659 bool labelPerPart = false;
660
661 // TODO QGIS 4.0 - remove this junk
662
663#ifdef SIP_RUN
664 SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
665 SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
666 SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
667 SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
668 SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
669 SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
670 SIP_PROPERTY( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
671 SIP_PROPERTY( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
672 SIP_PROPERTY( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
673 SIP_PROPERTY( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
674 SIP_PROPERTY( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
675 SIP_PROPERTY( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
676 SIP_PROPERTY( name = placeDirectionSymbol, get = _getPlaceDirectionSymbol, set = _setPlaceDirectionSymbol )
677
678 SIP_PROPERTY( name = overrunDistance, get = _getOverrunDistance, set = _setOverrunDistance )
679 SIP_PROPERTY( name = overrunDistanceUnit, get = _getOverrunDistanceUnit, set = _setOverrunDistanceUnit )
680 SIP_PROPERTY( name = overrunDistanceMapUnitScale, get = _getOverrunDistanceMapUnitScale, set = _setOverrunDistanceMapUnitScale )
681 SIP_PROPERTY( name = displayAll, get = _getDisplayAll, set = _setDisplayAll )
682#endif
683
685 bool _limitNumLabels() const { return mThinningSettings.limitNumberOfLabelsEnabled(); }
686 void _setLimitNumLabels( bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
687 int _maxNumLabels() const { return mThinningSettings.maximumNumberLabels(); }
688 void _setMaxNumLabels( int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
689 double _minFeatureSize() const { return mThinningSettings.minimumFeatureSize(); }
690 void _setMinFeatureSize( double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
691 bool _getIsObstacle() const { return mObstacleSettings.isObstacle(); }
692 void _setIsObstacle( bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
693 double _getObstacleFactor() const { return mObstacleSettings.factor(); }
694 void _setObstacleFactor( double factor ) { mObstacleSettings.setFactor( factor ); }
695 ObstacleType _getObstacleType() const { return static_cast< ObstacleType>( mObstacleSettings.type() ); }
696 void _setObstacleType( ObstacleType type ) { mObstacleSettings.setType( static_cast< QgsLabelObstacleSettings::ObstacleType>( type ) ); }
697 unsigned int _getLinePlacementFlags() const { return static_cast< unsigned int >( mLineSettings.placementFlags() ); }
698 void _setLinePlacementFlags( unsigned int flags ) { mLineSettings.setPlacementFlags( static_cast< QgsLabeling::LinePlacementFlags >( flags ) ); }
699 bool _getMergeLines() const { return mLineSettings.mergeLines(); }
700 void _setMergeLines( bool merge ) { mLineSettings.setMergeLines( merge ); }
701 bool _getAddDirectionSymbol() const { return mLineSettings.addDirectionSymbol(); }
702 void _setAddDirectionSymbol( bool add ) { mLineSettings.setAddDirectionSymbol( add ); }
703 QString _getLeftDirectionSymbol() const { return mLineSettings.leftDirectionSymbol(); }
704 void _setLeftDirectionSymbol( const QString &symbol ) { mLineSettings.setLeftDirectionSymbol( symbol ); }
705 QString _getRightDirectionSymbol() const { return mLineSettings.rightDirectionSymbol(); }
706 void _setRightDirectionSymbol( const QString &symbol ) { mLineSettings.setRightDirectionSymbol( symbol ); }
707 bool _getReverseDirectionSymbol() const { return mLineSettings.reverseDirectionSymbol(); }
708 void _setReverseDirectionSymbol( bool reverse ) { mLineSettings.setReverseDirectionSymbol( reverse ); }
710 DirectionSymbols _getPlaceDirectionSymbol() const { return static_cast< DirectionSymbols>( mLineSettings.directionSymbolPlacement() ); }
711 void _setPlaceDirectionSymbol( DirectionSymbols placement ) { mLineSettings.setDirectionSymbolPlacement( static_cast< QgsLabelLineSettings::DirectionSymbolPlacement>( placement ) ); }
713 double _getOverrunDistance() const { return mLineSettings.overrunDistance(); }
714 void _setOverrunDistance( double distance ) { mLineSettings.setOverrunDistance( distance ); }
715 QgsUnitTypes::RenderUnit _getOverrunDistanceUnit() const { return mLineSettings.overrunDistanceUnit(); }
716 void _setOverrunDistanceUnit( QgsUnitTypes::RenderUnit unit ) { mLineSettings.setOverrunDistanceUnit( unit ); }
717 QgsMapUnitScale _getOverrunDistanceMapUnitScale() const { return mLineSettings.overrunDistanceMapUnitScale(); }
718 void _setOverrunDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mLineSettings.setOverrunDistanceMapUnitScale( scale ); }
719 bool _getDisplayAll() const { return mPlacementSettings.overlapHandling() == Qgis::LabelOverlapHandling::AllowOverlapIfRequired; }
720 void _setDisplayAll( bool display ) { mPlacementSettings.setOverlapHandling( display ? Qgis::LabelOverlapHandling::AllowOverlapIfRequired : Qgis::LabelOverlapHandling::PreventOverlap ); mPlacementSettings.setAllowDegradedPlacement( display ); }
722
724 double zIndex = 0;
725
728
730 QgsWkbTypes::GeometryType geometryGeneratorType = QgsWkbTypes::GeometryType::PointGeometry;
731
733 bool geometryGeneratorEnabled = false;
734
740
745 void setLegendString( const QString &legendString ) { mLegendString = legendString; }
746
751 QString legendString() const { return mLegendString; }
752
759#ifndef SIP_RUN
760 void calculateLabelSize( const QFontMetricsF *fm, const QString &text, double &labelX, double &labelY, const QgsFeature *f = nullptr, QgsRenderContext *context = nullptr, double *rotatedLabelX SIP_OUT = nullptr, double *rotatedLabelY SIP_OUT = nullptr,
761 QgsTextDocument *document = nullptr, QgsTextDocumentMetrics *documentMetrics = nullptr );
762#else
763 void calculateLabelSize( const QFontMetricsF *fm, const QString &text, double &labelX, double &labelY, const QgsFeature *f = nullptr, QgsRenderContext *context = nullptr, double *rotatedLabelX SIP_OUT = nullptr, double *rotatedLabelY SIP_OUT = nullptr );
764#endif
765
775 void registerFeature( const QgsFeature &f, QgsRenderContext &context );
776
777#ifndef SIP_RUN
778
795 std::unique_ptr< QgsLabelFeature > registerFeatureWithDetails( const QgsFeature &feature, QgsRenderContext &context,
796 QgsGeometry obstacleGeometry = QgsGeometry(), const QgsSymbol *symbol = nullptr );
797#endif
798
803 void readXml( const QDomElement &elem, const QgsReadWriteContext &context );
804
809 QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
810
816 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
817
825 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
826
834 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
835
841 const QgsTextFormat &format() const { return mFormat; }
842
849 void setFormat( const QgsTextFormat &format ) { mFormat = format; }
850
859 QgsCallout *callout() const { return mCallout.get(); }
860
869 void setCallout( QgsCallout *callout SIP_TRANSFER );
870
879 const QgsLabelLineSettings &lineSettings() const { return mLineSettings; } SIP_SKIP
880
888 QgsLabelLineSettings &lineSettings() { return mLineSettings; }
889
897 void setLineSettings( const QgsLabelLineSettings &settings ) { mLineSettings = settings; }
898
905 const QgsLabelObstacleSettings &obstacleSettings() const { return mObstacleSettings; } SIP_SKIP
906
912 QgsLabelObstacleSettings &obstacleSettings() { return mObstacleSettings; }
913
919 void setObstacleSettings( const QgsLabelObstacleSettings &settings ) { mObstacleSettings = settings; }
920
927 const QgsLabelThinningSettings &thinningSettings() const { return mThinningSettings; } SIP_SKIP
928
934 QgsLabelThinningSettings &thinningSettings() { return mThinningSettings; }
935
941 void setThinningSettings( const QgsLabelThinningSettings &settings ) { mThinningSettings = settings; }
942
949 const QgsLabelPlacementSettings &placementSettings() const { return mPlacementSettings; } SIP_SKIP
950
956 QgsLabelPlacementSettings &placementSettings() { return mPlacementSettings; }
957
963 void setPlacementSettings( const QgsLabelPlacementSettings &settings ) { mPlacementSettings = settings; }
964
973 static QPixmap labelSettingsPreviewPixmap( const QgsPalLayerSettings &settings, QSize size, const QString &previewText = QString(), int padding = 0 );
974
981 Qgis::UnplacedLabelVisibility unplacedVisibility() const;
982
989 void setUnplacedVisibility( Qgis::UnplacedLabelVisibility visibility );
990
991 // temporary stuff: set when layer gets prepared or labeled
992 const QgsFeature *mCurFeat = nullptr;
994 int fieldIndex = 0;
995 const QgsMapToPixel *xform = nullptr;
997
1001 int mFeaturesToLabel = 0; // total features that will probably be labeled, may be less (figured before PAL)
1002 int mFeatsSendingToPal = 0; // total features tested for sending into PAL (relative to maxNumLabels)
1003 int mFeatsRegPal = 0; // number of features registered in PAL, when using limitNumLabels
1004
1005 private:
1006
1007 friend class QgsVectorLayer; // to allow calling readFromLayerCustomProperties()
1008
1013 void readFromLayerCustomProperties( QgsVectorLayer *layer );
1014
1018 void readOldDataDefinedPropertyMap( QgsVectorLayer *layer, QDomElement *parentElem );
1019
1023 void readOldDataDefinedProperty( QgsVectorLayer *layer, QgsPalLayerSettings::Property p );
1024
1025 enum DataDefinedValueType
1026 {
1027 DDBool,
1028 DDInt,
1029 DDIntPos,
1030 DDDouble,
1031 DDDoublePos,
1032 DDRotation180,
1033 DDOpacity,
1034 DDString,
1035 DDUnits,
1036 DDColor,
1037 DDJoinStyle,
1038 DDBlendMode,
1039 DDPointF,
1040 DDSizeF,
1041 };
1042
1043 // convenience data defined evaluation function
1044 bool dataDefinedValEval( DataDefinedValueType valType,
1046 QVariant &exprVal, QgsExpressionContext &context, const QVariant &originalValue = QVariant() );
1047
1048 void parseTextStyle( QFont &labelFont,
1049 QgsUnitTypes::RenderUnit fontunits,
1050 QgsRenderContext &context );
1051
1052 void parseTextBuffer( QgsRenderContext &context );
1053
1054 void parseTextMask( QgsRenderContext &context );
1055
1056 void parseTextFormatting( QgsRenderContext &context );
1057
1058 void parseShapeBackground( QgsRenderContext &context );
1059
1060 void parseDropShadow( QgsRenderContext &context );
1061
1066 bool checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const;
1067
1071 std::unique_ptr< QgsLabelFeature > registerObstacleFeature( const QgsFeature &f, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
1072
1073 QMap<Property, QVariant> dataDefinedValues;
1074
1076 QgsPropertyCollection mDataDefinedProperties;
1077
1078 QgsExpression *expression = nullptr;
1079
1080 std::unique_ptr< QFontDatabase > mFontDB;
1081
1082 QgsTextFormat mFormat;
1083
1084 std::unique_ptr< QgsCallout > mCallout;
1085
1086 QgsLabelPlacementSettings mPlacementSettings;
1087 QgsLabelLineSettings mLineSettings;
1088 QgsLabelObstacleSettings mObstacleSettings;
1089 QgsLabelThinningSettings mThinningSettings;
1090
1091 QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1092
1093 QgsExpression mGeometryGeneratorExpression;
1094
1095 bool mRenderStarted = false;
1096
1097 QString mLegendString = QObject::tr( "Aa" );
1098
1100
1103
1104 static void initPropertyDefinitions();
1105};
1106
1111class CORE_EXPORT QgsLabelCandidate
1112{
1113 public:
1114 QgsLabelCandidate( const QRectF &r, double c ): rect( r ), cost( c ) {}
1115
1116 QRectF rect;
1117 double cost;
1118};
1119
1125class CORE_EXPORT QgsPalLabeling
1126{
1127 public:
1128
1133 static bool staticWillUseLayer( const QgsMapLayer *layer );
1134
1136 static void drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList<QgsLabelCandidate> *candidates = nullptr ) SIP_SKIP;
1137
1148 static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false ) SIP_FACTORY;
1149
1160 static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false );
1161
1174 static QStringList splitToLines( const QString &text, const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
1175
1184 static QStringList splitToGraphemes( const QString &text );
1185
1186 private:
1188 static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
1189 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1190
1192 static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
1193 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1194
1196 static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr,
1197 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1198
1200 static void dataDefinedTextMask( QgsPalLayerSettings &tmpLyr,
1201 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1202
1204 static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr,
1205 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1206
1208 static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr,
1209 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1210
1211 friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1212 friend class QgsDxfExport; // to allow calling the static methods above
1213
1222 static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
1223
1225};
1226
1227
1228#endif // QGSPALLABELING_H
LabelOffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
Definition: qgis.h:608
@ FromPoint
Offset distance applies from point geometry.
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.
Definition: qgis.h:561
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
LabelQuadrantPosition
Label quadrant positions.
Definition: qgis.h:622
UnplacedLabelVisibility
Unplaced label visibility.
Definition: qgis.h:534
@ FollowEngineSetting
Respect the label engine setting.
LabelMultiLineAlignment
Text alignment for multi-line labels.
Definition: qgis.h:658
@ AllowOverlapIfRequired
Avoids overlapping labels when possible, but permit overlaps if labels for features cannot otherwise ...
@ PreventOverlap
Do not allow labels to overlap other labels.
UpsideDownLabelHandling
Handling techniques for upside down labels.
Definition: qgis.h:643
Abstract base class for callout renderers.
Definition: qgscallout.h:53
This class represents a coordinate reference system (CRS).
Class for doing transforms between two map coordinate systems.
Stores the settings for rendering of all diagrams for a layer.
Exports QGIS layers to the DXF format.
Definition: qgsdxfexport.h:65
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Container of fields for a vector layer.
Definition: qgsfields.h:45
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:164
Represents a label candidate.
QgsLabelCandidate(const QRectF &r, double c)
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
Contains settings related to how the label engine places and formats labels for line features (or pol...
DirectionSymbolPlacement
Placement options for direction symbols.
Contains settings related to how the label engine treats features as obstacles.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
Contains general settings related to how labels are placed.
A class to query the labeling structure at a given point (small wrapper around pal RTree class)
Contains settings related to how the label engine removes candidate label positions and reduces the n...
The QgsLabelingEngine class provides map labeling functionality.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
The QgsMapSettings class contains configuration for rendering of the map.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:39
Struct for storing maximum and minimum scales for measurements in map units.
PAL labeling utilities.
Contains settings for how a map layer will be labeled.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
const QgsLabelPlacementSettings & placementSettings() const
Returns the label placement settings.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
QString wrapChar
Wrapping character string.
@ SymbolAbove
Place direction symbols on above label.
@ SymbolLeftRight
Place direction symbols on left/right of label.
QgsCoordinateTransform ct
QString legendString() const
legendString
void setLineSettings(const QgsLabelLineSettings &settings)
Sets the label line settings, which contain settings related to how the label engine places and forma...
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
QgsLabelLineSettings & lineSettings()
Returns the label line settings, which contain settings related to how the label engine places and fo...
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
Property
Data definable properties.
void setPolygonPlacementFlags(QgsLabeling::PolygonPlacementFlags flags)
Sets the polygon placement flags, which dictate how polygon labels can be placed.
void setLegendString(const QString &legendString)
setLegendString
void setThinningSettings(const QgsLabelThinningSettings &settings)
Sets the label thinning settings.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
void setPlacementSettings(const QgsLabelPlacementSettings &settings)
Sets the label placement settings.
QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const
Returns the polygon placement flags, which dictate how polygon labels can be placed.
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning settings.
QString geometryGenerator
The geometry generator expression. Null if disabled.
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
QString fieldName
Name of field (or an expression) to use for label text.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
QgsLabelPlacementSettings & placementSettings()
Returns the label placement settings.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
A class to represent a 2D point.
Definition: qgspointxy.h:59
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
The class is used as a container of context for various read/write operations on other objects.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
Contains information about the context of a rendering operation.
A collection of string replacements (specified using QgsStringReplacement objects).
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:93
Contains pre-calculated metrics of a QgsTextDocument.
Represents a document consisting of one or more QgsTextBlock objects.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:41
Class that adds extra information to QgsLabelFeature for text labels.
AngleUnit
Units of angles.
Definition: qgsunittypes.h:132
@ AngleDegrees
Degrees.
Definition: qgsunittypes.h:133
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
Represents a vector layer which manages a vector based data sets.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
LabelPosition is a candidate feature label position.
Definition: labelposition.h:56
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:3061
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:3060
#define SIP_PROPERTY(name, getter, setter)
Definition: qgis_sip.h:273
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_INOUT
Definition: qgis_sip.h:71
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
const QgsCoordinateReferenceSystem & crs