21 #ifndef QGSPALLABELING_H
22 #define QGSPALLABELING_H
24 #include "qgis_core.h"
28 #include <QFontDatabase>
201 MultiFollowPlacement,
240 FontLetterSpacing = 28,
241 FontWordSpacing = 29,
245 MultiLineWrapChar = 31,
246 AutoWrapLength = 101,
247 MultiLineHeight = 32,
248 MultiLineAlignment = 33,
249 TextOrientation = 110,
253 DirSymbPlacement = 37,
266 BufferJoinStyle = 44,
267 BufferBlendMode = 45,
271 MaskBufferSize = 105,
272 MaskBufferUnit = 106,
284 ShapeRotationType = 52,
287 ShapeOffsetUnits = 55,
289 ShapeRadiiUnits = 57,
290 ShapeTransparency = 63,
294 ShapeStrokeColor = 59,
295 ShapeStrokeWidth = 60,
296 ShapeStrokeWidthUnits = 61,
302 ShadowOffsetAngle = 67,
303 ShadowOffsetDist = 68,
304 ShadowOffsetUnits = 69,
306 ShadowRadiusUnits = 71,
307 ShadowTransparency = 72,
311 ShadowBlendMode = 75,
321 CurvedCharAngleInOut = 83,
330 RepeatDistanceUnit = 86,
332 PredefinedPositionOrder = 91,
333 LinePlacementOptions = 99,
334 OverrunDistance = 102,
336 PolygonLabelOutside = 109,
337 LineAnchorPercent = 111,
338 LineAnchorClipping = 112,
341 ScaleVisibility = 23,
403 bool containsAdvancedEffects()
const;
419 bool drawLabels =
true;
434 bool isExpression =
false;
444 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
449 bool useSubstitutions =
false;
466 int autoWrapLength = 0;
478 bool useMaxLineLengthForAutoWrap =
true;
489 bool formatNumbers =
false;
503 bool plusSign =
false;
529 bool centroidWhole =
false;
536 bool centroidInside =
false;
544 QVector< PredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
549 bool fitInPolygonOnly =
false;
580 double repeatDistance = 0;
634 double angleOffset = 0;
637 bool preserveRotation =
true;
643 double maxCurvedCharAngleIn = 25.0;
649 double maxCurvedCharAngleOut = -25.0;
664 bool scaleVisibility =
false;
676 double maximumScale = 0;
688 double minimumScale = 0;
695 bool fontLimitPixelSize =
false;
702 int fontMinPixelSize = 0;
709 int fontMaxPixelSize = 10000;
712 bool displayAll =
false;
721 bool labelPerPart =
false;
726 SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
727 SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
728 SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
729 SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
730 SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
731 SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
732 SIP_PROPERTY( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
733 SIP_PROPERTY( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
734 SIP_PROPERTY( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
735 SIP_PROPERTY( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
736 SIP_PROPERTY( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
737 SIP_PROPERTY( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
738 SIP_PROPERTY( name = placeDirectionSymbol, get = _getPlaceDirectionSymbol, set = _setPlaceDirectionSymbol )
740 SIP_PROPERTY( name = overrunDistance, get = _getOverrunDistance, set = _setOverrunDistance )
741 SIP_PROPERTY( name = overrunDistanceUnit, get = _getOverrunDistanceUnit, set = _setOverrunDistanceUnit )
742 SIP_PROPERTY( name = overrunDistanceMapUnitScale, get = _getOverrunDistanceMapUnitScale, set = _setOverrunDistanceMapUnitScale )
746 bool _limitNumLabels()
const {
return mThinningSettings.limitNumberOfLabelsEnabled(); }
747 void _setLimitNumLabels(
bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
748 int _maxNumLabels()
const {
return mThinningSettings.maximumNumberLabels(); }
749 void _setMaxNumLabels(
int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
750 double _minFeatureSize()
const {
return mThinningSettings.minimumFeatureSize(); }
751 void _setMinFeatureSize(
double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
752 bool _getIsObstacle()
const {
return mObstacleSettings.isObstacle(); }
753 void _setIsObstacle(
bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
754 double _getObstacleFactor()
const {
return mObstacleSettings.factor(); }
755 void _setObstacleFactor(
double factor ) { mObstacleSettings.setFactor( factor ); }
756 ObstacleType _getObstacleType()
const {
return static_cast< ObstacleType
>( mObstacleSettings.type() ); }
758 unsigned int _getLinePlacementFlags()
const {
return static_cast< unsigned int >( mLineSettings.placementFlags() ); }
759 void _setLinePlacementFlags(
unsigned int flags ) { mLineSettings.setPlacementFlags(
static_cast< QgsLabeling::LinePlacementFlags
>( flags ) ); }
760 bool _getMergeLines()
const {
return mLineSettings.mergeLines(); }
761 void _setMergeLines(
bool merge ) { mLineSettings.setMergeLines( merge ); }
762 bool _getAddDirectionSymbol()
const {
return mLineSettings.addDirectionSymbol(); }
763 void _setAddDirectionSymbol(
bool add ) { mLineSettings.setAddDirectionSymbol( add ); }
764 QString _getLeftDirectionSymbol()
const {
return mLineSettings.leftDirectionSymbol(); }
765 void _setLeftDirectionSymbol(
const QString &symbol ) { mLineSettings.setLeftDirectionSymbol( symbol ); }
766 QString _getRightDirectionSymbol()
const {
return mLineSettings.rightDirectionSymbol(); }
767 void _setRightDirectionSymbol(
const QString &symbol ) { mLineSettings.setRightDirectionSymbol( symbol ); }
768 bool _getReverseDirectionSymbol()
const {
return mLineSettings.reverseDirectionSymbol(); }
769 void _setReverseDirectionSymbol(
bool reverse ) { mLineSettings.setReverseDirectionSymbol( reverse ); }
771 DirectionSymbols _getPlaceDirectionSymbol()
const {
return static_cast< DirectionSymbols
>( mLineSettings.directionSymbolPlacement() ); }
774 double _getOverrunDistance()
const {
return mLineSettings.overrunDistance(); }
775 void _setOverrunDistance(
double distance ) { mLineSettings.setOverrunDistance( distance ); }
778 QgsMapUnitScale _getOverrunDistanceMapUnitScale()
const {
return mLineSettings.overrunDistanceMapUnitScale(); }
779 void _setOverrunDistanceMapUnitScale(
const QgsMapUnitScale &scale ) { mLineSettings.setOverrunDistanceMapUnitScale( scale ); }
792 bool geometryGeneratorEnabled =
false;
819 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,
822 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 );
995 static QPixmap labelSettingsPreviewPixmap(
const QgsPalLayerSettings &settings, QSize size,
const QString &previewText = QString(),
int padding = 0 );
1023 int mFeaturesToLabel = 0;
1024 int mFeatsSendingToPal = 0;
1025 int mFeatsRegPal = 0;
1040 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1047 enum DataDefinedValueType
1066 bool dataDefinedValEval( DataDefinedValueType valType,
1068 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1070 void parseTextStyle( QFont &labelFont,
1095 QMap<Property, QVariant> dataDefinedValues;
1102 std::unique_ptr< QFontDatabase > mFontDB;
1106 std::unique_ptr< QgsCallout > mCallout;
1112 QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1116 bool mRenderStarted =
false;
1118 QString mLegendString = QObject::tr(
"Aa" );
1122 static void initPropertyDefinitions();
1151 static bool staticWillUseLayer(
const QgsMapLayer *layer );
1192 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1202 static QStringList splitToGraphemes(
const QString &text );
1207 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1211 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1215 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1219 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1223 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1227 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
UnplacedLabelVisibility
Unplaced label visibility.
@ FollowEngineSetting
Respect the label engine setting.
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.
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.
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle 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.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
QgsCoordinateTransform ct
QString legendString() const
legendString
@ ShowDefined
Show upside down when rotation is layer- or data-defined.
@ Upright
Upside-down labels (90 <= angle < 270) are shown upright.
void setLineSettings(const QgsLabelLineSettings &settings)
Sets the label line settings, which contain settings related to how the label engine places and forma...
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
Placement
Placement modes which determine how label candidates are generated for a feature.
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only....
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode.
@ BottomSlightlyLeft
Label below point, slightly left of center.
@ BottomMiddle
Label directly below point.
@ BottomSlightlyRight
Label below point, slightly right of center.
@ MiddleLeft
Label on left of point.
@ TopSlightlyRight
Label on top of point, slightly right of center.
@ TopSlightlyLeft
Label on top of point, slightly left of center.
@ MiddleRight
Label on right of point.
@ TopMiddle
Label directly above point.
@ BottomRight
Label on bottom right of point.
@ BottomLeft
Label on bottom-left of point.
@ TopRight
Label on top-right of point.
@ TopLeft
Label on top-left of point.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
Property
Data definable properties.
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
void setPolygonPlacementFlags(QgsLabeling::PolygonPlacementFlags flags)
Sets the polygon placement flags, which dictate how polygon labels can be placed.
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
@ FromPoint
Offset distance applies from point geometry.
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
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.
QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const
Returns the polygon placement flags, which dictate how polygon labels can be placed.
QString geometryGenerator
The geometry generator expression. Null if disabled.
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.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
QString fieldName
Name of field (or an expression) to use for label text.
QgsLabelLineSettings & lineSettings()
Returns the label line settings, which contain settings related to how the label engine places and fo...
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning 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.
A collection of string replacements (specified using QgsStringReplacement objects).
Abstract base class for all rendered symbols.
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.
RenderUnit
Rendering size units.
@ RenderMillimeters
Millimeters.
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.
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