18 #ifndef QGSPALLABELING_H
19 #define QGSPALLABELING_H
21 #include "qgis_core.h"
25 #include <QFontDatabase>
199 MultiFollowPlacement,
238 FontLetterSpacing = 28,
239 FontWordSpacing = 29,
243 MultiLineWrapChar = 31,
244 AutoWrapLength = 101,
245 MultiLineHeight = 32,
246 MultiLineAlignment = 33,
247 TextOrientation = 110,
251 DirSymbPlacement = 37,
264 BufferJoinStyle = 44,
265 BufferBlendMode = 45,
269 MaskBufferSize = 105,
270 MaskBufferUnit = 106,
282 ShapeRotationType = 52,
285 ShapeOffsetUnits = 55,
287 ShapeRadiiUnits = 57,
288 ShapeTransparency = 63,
292 ShapeStrokeColor = 59,
293 ShapeStrokeWidth = 60,
294 ShapeStrokeWidthUnits = 61,
300 ShadowOffsetAngle = 67,
301 ShadowOffsetDist = 68,
302 ShadowOffsetUnits = 69,
304 ShadowRadiusUnits = 71,
305 ShadowTransparency = 72,
309 ShadowBlendMode = 75,
319 CurvedCharAngleInOut = 83,
328 RepeatDistanceUnit = 86,
330 PredefinedPositionOrder = 91,
331 LinePlacementOptions = 99,
332 OverrunDistance = 102,
334 PolygonLabelOutside = 109,
335 LineAnchorPercent = 111,
336 LineAnchorClipping = 112,
339 ScaleVisibility = 23,
401 bool containsAdvancedEffects()
const;
417 bool drawLabels =
true;
432 bool isExpression =
false;
442 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
447 bool useSubstitutions =
false;
464 int autoWrapLength = 0;
476 bool useMaxLineLengthForAutoWrap =
true;
487 bool formatNumbers =
false;
501 bool plusSign =
false;
527 bool centroidWhole =
false;
534 bool centroidInside =
false;
542 QVector< PredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
547 bool fitInPolygonOnly =
false;
578 double repeatDistance = 0;
632 double angleOffset = 0;
635 bool preserveRotation =
true;
655 double maxCurvedCharAngleIn = 25.0;
661 double maxCurvedCharAngleOut = -25.0;
676 bool scaleVisibility =
false;
688 double maximumScale = 0;
700 double minimumScale = 0;
707 bool fontLimitPixelSize =
false;
714 int fontMinPixelSize = 0;
721 int fontMaxPixelSize = 10000;
724 bool displayAll =
false;
733 bool labelPerPart =
false;
738 SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
739 SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
740 SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
741 SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
742 SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
743 SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
744 SIP_PROPERTY( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
745 SIP_PROPERTY( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
746 SIP_PROPERTY( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
747 SIP_PROPERTY( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
748 SIP_PROPERTY( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
749 SIP_PROPERTY( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
750 SIP_PROPERTY( name = placeDirectionSymbol, get = _getPlaceDirectionSymbol, set = _setPlaceDirectionSymbol )
752 SIP_PROPERTY( name = overrunDistance, get = _getOverrunDistance, set = _setOverrunDistance )
753 SIP_PROPERTY( name = overrunDistanceUnit, get = _getOverrunDistanceUnit, set = _setOverrunDistanceUnit )
754 SIP_PROPERTY( name = overrunDistanceMapUnitScale, get = _getOverrunDistanceMapUnitScale, set = _setOverrunDistanceMapUnitScale )
758 bool _limitNumLabels()
const {
return mThinningSettings.limitNumberOfLabelsEnabled(); }
759 void _setLimitNumLabels(
bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
760 int _maxNumLabels()
const {
return mThinningSettings.maximumNumberLabels(); }
761 void _setMaxNumLabels(
int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
762 double _minFeatureSize()
const {
return mThinningSettings.minimumFeatureSize(); }
763 void _setMinFeatureSize(
double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
764 bool _getIsObstacle()
const {
return mObstacleSettings.isObstacle(); }
765 void _setIsObstacle(
bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
766 double _getObstacleFactor()
const {
return mObstacleSettings.factor(); }
767 void _setObstacleFactor(
double factor ) { mObstacleSettings.setFactor( factor ); }
768 ObstacleType _getObstacleType()
const {
return static_cast< ObstacleType
>( mObstacleSettings.type() ); }
770 unsigned int _getLinePlacementFlags()
const {
return static_cast< unsigned int >( mLineSettings.placementFlags() ); }
771 void _setLinePlacementFlags(
unsigned int flags ) { mLineSettings.setPlacementFlags(
static_cast< QgsLabeling::LinePlacementFlags
>( flags ) ); }
772 bool _getMergeLines()
const {
return mLineSettings.mergeLines(); }
773 void _setMergeLines(
bool merge ) { mLineSettings.setMergeLines( merge ); }
774 bool _getAddDirectionSymbol()
const {
return mLineSettings.addDirectionSymbol(); }
775 void _setAddDirectionSymbol(
bool add ) { mLineSettings.setAddDirectionSymbol( add ); }
776 QString _getLeftDirectionSymbol()
const {
return mLineSettings.leftDirectionSymbol(); }
777 void _setLeftDirectionSymbol(
const QString &symbol ) { mLineSettings.setLeftDirectionSymbol( symbol ); }
778 QString _getRightDirectionSymbol()
const {
return mLineSettings.rightDirectionSymbol(); }
779 void _setRightDirectionSymbol(
const QString &symbol ) { mLineSettings.setRightDirectionSymbol( symbol ); }
780 bool _getReverseDirectionSymbol()
const {
return mLineSettings.reverseDirectionSymbol(); }
781 void _setReverseDirectionSymbol(
bool reverse ) { mLineSettings.setReverseDirectionSymbol( reverse ); }
783 DirectionSymbols _getPlaceDirectionSymbol()
const {
return static_cast< DirectionSymbols
>( mLineSettings.directionSymbolPlacement() ); }
786 double _getOverrunDistance()
const {
return mLineSettings.overrunDistance(); }
787 void _setOverrunDistance(
double distance ) { mLineSettings.setOverrunDistance( distance ); }
790 QgsMapUnitScale _getOverrunDistanceMapUnitScale()
const {
return mLineSettings.overrunDistanceMapUnitScale(); }
791 void _setOverrunDistanceMapUnitScale(
const QgsMapUnitScale &scale ) { mLineSettings.setOverrunDistanceMapUnitScale( scale ); }
804 bool geometryGeneratorEnabled =
false;
831 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,
834 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 );
1022 static QPixmap labelSettingsPreviewPixmap(
const QgsPalLayerSettings &settings, QSize size,
const QString &previewText = QString(),
int padding = 0 );
1050 int mFeaturesToLabel = 0;
1051 int mFeatsSendingToPal = 0;
1052 int mFeatsRegPal = 0;
1067 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1074 enum DataDefinedValueType
1093 bool dataDefinedValEval( DataDefinedValueType valType,
1095 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1097 void parseTextStyle( QFont &labelFont,
1122 QMap<Property, QVariant> dataDefinedValues;
1129 std::unique_ptr< QFontDatabase > mFontDB;
1133 std::unique_ptr< QgsCallout > mCallout;
1139 QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1143 bool mRenderStarted =
false;
1145 QString mLegendString = QObject::tr(
"Aa" );
1152 static void initPropertyDefinitions();
1181 static bool staticWillUseLayer(
const QgsMapLayer *layer );
1222 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1232 static QStringList splitToGraphemes(
const QString &text );
1237 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1241 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1245 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1249 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1253 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1257 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.
AngleUnit
Units of angles.
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