QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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"
45#include "qgsexpression.h"
46
47class QgsTextDocument;
49
50namespace pal SIP_SKIP
51{
52 class Pal;
53 class Layer;
54 class LabelPosition;
55}
56
58class QgsRectangle;
59class QgsMapToPixel;
60class QgsFeature;
62class QgsVectorLayer;
63class QgsExpression;
64class QFontMetricsF;
65class QPainter;
66class QPicture;
67class QgsGeometry;
70class QgsMapLayer;
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 Qgis::LabelPolygonPlacementFlags polygonPlacementFlags() const { return mPolygonPlacementFlags; }
443
450 void setPolygonPlacementFlags( Qgis::LabelPolygonPlacementFlags 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
490 Qgis::RenderUnit distUnits = Qgis::RenderUnit::Millimeters;
491
498
501
507 double repeatDistance = 0;
508
514 Qgis::RenderUnit repeatDistanceUnit = Qgis::RenderUnit::Millimeters;
515
522
526 Qgis::LabelQuadrantPosition quadOffset = Qgis::LabelQuadrantPosition::Over;
527
534 double xOffset = 0;
535
542 double yOffset = 0;
543
550 Qgis::RenderUnit offsetUnits = Qgis::RenderUnit::Millimeters;
551
559
561 double angleOffset = 0;
562
564 bool preserveRotation = true;
565
571 Qgis::AngleUnit rotationUnit() const;
572
578 void setRotationUnit( Qgis::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< Qgis::LabelLinePlacementFlags >( 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 Qgis::RenderUnit _getOverrunDistanceUnit() const { return mLineSettings.overrunDistanceUnit(); }
716 void _setOverrunDistanceUnit( Qgis::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 Qgis::GeometryType geometryGeneratorType = Qgis::GeometryType::Point;
731
733 bool geometryGeneratorEnabled = false;
734
739 Qgis::GeometryType layerType = Qgis::GeometryType::Unknown;
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, QRectF *outerBounds = 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
974 static QPixmap labelSettingsPreviewPixmap( const QgsPalLayerSettings &settings, QSize size, const QString &previewText = QString(), int padding = 0, const QgsScreenProperties &screen = QgsScreenProperties() );
975
982 Qgis::UnplacedLabelVisibility unplacedVisibility() const;
983
990 void setUnplacedVisibility( Qgis::UnplacedLabelVisibility visibility );
991
992 // temporary stuff: set when layer gets prepared or labeled
993 const QgsFeature *mCurFeat = nullptr;
995 int fieldIndex = 0;
996 const QgsMapToPixel *xform = nullptr;
998
1002 int mFeaturesToLabel = 0; // total features that will probably be labeled, may be less (figured before PAL)
1003 int mFeatsSendingToPal = 0; // total features tested for sending into PAL (relative to maxNumLabels)
1004 int mFeatsRegPal = 0; // number of features registered in PAL, when using limitNumLabels
1005
1006 private:
1007
1008 friend class QgsVectorLayer; // to allow calling readFromLayerCustomProperties()
1009
1014 void readFromLayerCustomProperties( QgsVectorLayer *layer );
1015
1019 void readOldDataDefinedPropertyMap( QgsVectorLayer *layer, QDomElement *parentElem );
1020
1024 void readOldDataDefinedProperty( QgsVectorLayer *layer, QgsPalLayerSettings::Property p );
1025
1026 enum DataDefinedValueType
1027 {
1028 DDBool,
1029 DDInt,
1030 DDIntPos,
1031 DDDouble,
1032 DDDoublePos,
1033 DDRotation180,
1034 DDOpacity,
1035 DDString,
1036 DDUnits,
1037 DDColor,
1038 DDJoinStyle,
1039 DDBlendMode,
1040 DDPointF,
1041 DDSizeF,
1042 };
1043
1044 // convenience data defined evaluation function
1045 bool dataDefinedValEval( DataDefinedValueType valType,
1047 QVariant &exprVal, QgsExpressionContext &context, const QVariant &originalValue = QVariant() );
1048
1049 void parseTextStyle( QFont &labelFont,
1050 Qgis::RenderUnit fontunits,
1051 QgsRenderContext &context );
1052
1053 void parseTextBuffer( QgsRenderContext &context );
1054
1055 void parseTextMask( QgsRenderContext &context );
1056
1057 void parseTextFormatting( QgsRenderContext &context );
1058
1059 void parseShapeBackground( QgsRenderContext &context );
1060
1061 void parseDropShadow( QgsRenderContext &context );
1062
1067 bool checkMinimumSizeMM( const QgsRenderContext &ct, const QgsGeometry &geom, double minSize ) const;
1068
1072 std::unique_ptr< QgsLabelFeature > registerObstacleFeature( const QgsFeature &f, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry() );
1073
1074 QMap<Property, QVariant> dataDefinedValues;
1075
1077 QgsPropertyCollection mDataDefinedProperties;
1078
1079 QgsExpression *expression = nullptr;
1080
1081 std::unique_ptr< QFontDatabase > mFontDB;
1082
1083 QgsTextFormat mFormat;
1084
1085 std::unique_ptr< QgsCallout > mCallout;
1086
1087 QgsLabelPlacementSettings mPlacementSettings;
1088 QgsLabelLineSettings mLineSettings;
1089 QgsLabelObstacleSettings mObstacleSettings;
1090 QgsLabelThinningSettings mThinningSettings;
1091
1092 Qgis::LabelPolygonPlacementFlags mPolygonPlacementFlags = Qgis::LabelPolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1093
1094 QgsExpression mGeometryGeneratorExpression;
1095
1096 bool mRenderStarted = false;
1097
1098 QString mLegendString = QObject::tr( "Aa" );
1099
1101
1103 Qgis::AngleUnit mRotationUnit = Qgis::AngleUnit::Degrees;
1104
1105 static void initPropertyDefinitions();
1106};
1107
1112class CORE_EXPORT QgsLabelCandidate
1113{
1114 public:
1115 QgsLabelCandidate( const QRectF &r, double c ): rect( r ), cost( c ) {}
1116
1117 QRectF rect;
1118 double cost;
1119};
1120
1126class CORE_EXPORT QgsPalLabeling
1127{
1128 public:
1129
1134 static bool staticWillUseLayer( const QgsMapLayer *layer );
1135
1137 static void drawLabelCandidateRect( pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList<QgsLabelCandidate> *candidates = nullptr ) SIP_SKIP;
1138
1149 static QgsGeometry prepareGeometry( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false ) SIP_FACTORY;
1150
1161 static bool geometryRequiresPreparation( const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry = QgsGeometry(), bool mergeLines = false );
1162
1175 static QStringList splitToLines( const QString &text, const QString &wrapCharacter, int autoWrapLength = 0, bool useMaxLineLengthWhenAutoWrapping = true );
1176
1185 static QStringList splitToGraphemes( const QString &text );
1186
1187 private:
1189 static void dataDefinedTextStyle( QgsPalLayerSettings &tmpLyr,
1190 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1191
1193 static void dataDefinedTextFormatting( QgsPalLayerSettings &tmpLyr,
1194 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1195
1197 static void dataDefinedTextBuffer( QgsPalLayerSettings &tmpLyr,
1198 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1199
1201 static void dataDefinedTextMask( QgsPalLayerSettings &tmpLyr,
1202 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1203
1205 static void dataDefinedShapeBackground( QgsPalLayerSettings &tmpLyr,
1206 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1207
1209 static void dataDefinedDropShadow( QgsPalLayerSettings &tmpLyr,
1210 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1211
1212 friend class QgsVectorLayerLabelProvider; // to allow calling the static methods above
1213 friend class QgsDxfExport; // to allow calling the static methods above
1214
1223 static bool checkMinimumSizeMM( const QgsRenderContext &context, const QgsGeometry &geom, double minSize );
1224
1226};
1227
1228
1229#endif // QGSPALLABELING_H
AngleUnit
Units of angles.
Definition: qgis.h:3396
LabelOffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
Definition: qgis.h:828
@ FromPoint
Offset distance applies from point geometry.
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.
Definition: qgis.h:782
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ AllowPlacementInsideOfPolygon
Labels can be placed inside a polygon feature.
LabelQuadrantPosition
Label quadrant positions.
Definition: qgis.h:842
UnplacedLabelVisibility
Unplaced label visibility.
Definition: qgis.h:755
@ FollowEngineSetting
Respect the label engine setting.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:227
LabelMultiLineAlignment
Text alignment for multi-line labels.
Definition: qgis.h:925
RenderUnit
Rendering size units.
Definition: qgis.h:3441
@ 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
Polygon placement flags, which control how candidates are generated for a polygon feature.
Definition: qgis.h:910
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.
void setPolygonPlacementFlags(Qgis::LabelPolygonPlacementFlags flags)
Sets the polygon placement flags, which dictate how polygon labels can be placed.
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 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.
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.
Qgis::LabelPolygonPlacementFlags polygonPlacementFlags() const
Returns the polygon placement flags, which dictate how polygon labels can be placed.
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.
Stores properties relating to a screen.
A collection of string replacements (specified using QgsStringReplacement objects).
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:94
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:42
Class that adds extra information to QgsLabelFeature for text labels.
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.
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:4572
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:4571
#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