18#ifndef QGSPALLABELING_H
19#define QGSPALLABELING_H
25#include <QFontDatabase>
159 FontLetterSpacing = 28,
160 FontWordSpacing = 29,
162 FontStretchFactor = 113,
165 MultiLineWrapChar = 31,
166 AutoWrapLength = 101,
167 MultiLineHeight = 32,
168 MultiLineAlignment = 33,
169 TextOrientation = 110,
173 DirSymbPlacement = 37,
186 BufferJoinStyle = 44,
187 BufferBlendMode = 45,
191 MaskBufferSize = 105,
192 MaskBufferUnit = 106,
204 ShapeRotationType = 52,
207 ShapeOffsetUnits = 55,
209 ShapeRadiiUnits = 57,
210 ShapeTransparency = 63,
214 ShapeStrokeColor = 59,
215 ShapeStrokeWidth = 60,
216 ShapeStrokeWidthUnits = 61,
222 ShadowOffsetAngle = 67,
223 ShadowOffsetDist = 68,
224 ShadowOffsetUnits = 69,
226 ShadowRadiusUnits = 71,
227 ShadowTransparency = 72,
231 ShadowBlendMode = 75,
241 CurvedCharAngleInOut = 83,
251 RepeatDistanceUnit = 86,
253 PredefinedPositionOrder = 91,
254 LinePlacementOptions = 99,
255 OverrunDistance = 102,
257 PolygonLabelOutside = 109,
258 LineAnchorPercent = 111,
259 LineAnchorClipping = 112,
260 LineAnchorType = 115,
261 LineAnchorTextPoint = 116,
264 ScaleVisibility = 23,
277 AllowDegradedPlacement = 117,
278 OverlapHandling = 118,
329 bool containsAdvancedEffects()
const;
345 bool drawLabels =
true;
360 bool isExpression =
false;
370 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
375 bool useSubstitutions =
false;
392 int autoWrapLength = 0;
404 bool useMaxLineLengthForAutoWrap =
true;
415 bool formatNumbers =
false;
429 bool plusSign =
false;
456 bool centroidWhole =
false;
463 bool centroidInside =
false;
471 QVector< Qgis::LabelPredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
476 bool fitInPolygonOnly =
false;
507 double repeatDistance = 0;
561 double angleOffset = 0;
564 bool preserveRotation =
true;
584 double maxCurvedCharAngleIn = 25.0;
590 double maxCurvedCharAngleOut = -25.0;
605 bool scaleVisibility =
false;
617 double maximumScale = 0;
629 double minimumScale = 0;
636 bool fontLimitPixelSize =
false;
643 int fontMinPixelSize = 0;
650 int fontMaxPixelSize = 10000;
659 bool labelPerPart =
false;
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 )
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 )
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() ); }
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() ); }
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 ); }
733 bool geometryGeneratorEnabled =
false;
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,
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 );
1002 int mFeaturesToLabel = 0;
1003 int mFeatsSendingToPal = 0;
1004 int mFeatsRegPal = 0;
1019 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1026 enum DataDefinedValueType
1045 bool dataDefinedValEval( DataDefinedValueType valType,
1047 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1049 void parseTextStyle( QFont &labelFont,
1074 QMap<Property, QVariant> dataDefinedValues;
1081 std::unique_ptr< QFontDatabase > mFontDB;
1085 std::unique_ptr< QgsCallout > mCallout;
1096 bool mRenderStarted =
false;
1098 QString mLegendString = QObject::tr(
"Aa" );
1105 static void initPropertyDefinitions();
1134 static bool staticWillUseLayer(
const QgsMapLayer *layer );
1175 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1185 static QStringList splitToGraphemes(
const QString &text );
1190 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1194 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1198 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1202 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1206 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1210 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
The Qgis class provides global constants for use throughout the application.
AngleUnit
Units of angles.
LabelOffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
@ FromPoint
Offset distance applies from point geometry.
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.
@ 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.
UnplacedLabelVisibility
Unplaced label visibility.
@ FollowEngineSetting
Respect the label engine setting.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
LabelMultiLineAlignment
Text alignment for multi-line labels.
@ FollowPlacement
Alignment follows placement of label, e.g., labels to the left of a feature will be drawn with right ...
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
@ AllowOverlapIfRequired
Avoids overlapping labels when possible, but permit overlaps if labels for features cannot otherwise ...
UpsideDownLabelHandling
Polygon placement flags, which control how candidates are generated for a polygon feature.
@ FlipUpsideDownLabels
Upside-down labels (90 <= angle < 270) are shown upright.
Abstract base class for callout renderers.
This class represents a coordinate reference system (CRS).
Stores the settings for rendering of all diagrams for a layer.
Exports QGIS layers to the DXF format.
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...
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
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.
The QgsMapSettings class contains configuration for rendering of the map.
Perform transforms between map coordinates and device coordinates.
Struct for storing maximum and minimum scales for measurements in map units.
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.
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.
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.
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.
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.
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
#define Q_NOWARN_DEPRECATED_PUSH
#define SIP_PROPERTY(name, getter, setter)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
const QgsCoordinateReferenceSystem & crs