18 #ifndef QGSPALLABELING_H
19 #define QGSPALLABELING_H
21 #include "qgis_core.h"
25 #include <QFontDatabase>
199 MultiFollowPlacement,
238 FontLetterSpacing = 28,
239 FontWordSpacing = 29,
241 FontStretchFactor = 113,
244 MultiLineWrapChar = 31,
245 AutoWrapLength = 101,
246 MultiLineHeight = 32,
247 MultiLineAlignment = 33,
248 TextOrientation = 110,
252 DirSymbPlacement = 37,
265 BufferJoinStyle = 44,
266 BufferBlendMode = 45,
270 MaskBufferSize = 105,
271 MaskBufferUnit = 106,
283 ShapeRotationType = 52,
286 ShapeOffsetUnits = 55,
288 ShapeRadiiUnits = 57,
289 ShapeTransparency = 63,
293 ShapeStrokeColor = 59,
294 ShapeStrokeWidth = 60,
295 ShapeStrokeWidthUnits = 61,
301 ShadowOffsetAngle = 67,
302 ShadowOffsetDist = 68,
303 ShadowOffsetUnits = 69,
305 ShadowRadiusUnits = 71,
306 ShadowTransparency = 72,
310 ShadowBlendMode = 75,
320 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;
657 double maxCurvedCharAngleIn = 25.0;
663 double maxCurvedCharAngleOut = -25.0;
678 bool scaleVisibility =
false;
690 double maximumScale = 0;
702 double minimumScale = 0;
709 bool fontLimitPixelSize =
false;
716 int fontMinPixelSize = 0;
723 int fontMaxPixelSize = 10000;
726 bool displayAll =
false;
735 bool labelPerPart =
false;
740 SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
741 SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
742 SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
743 SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
744 SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
745 SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
746 SIP_PROPERTY( name = placementFlags, get = _getLinePlacementFlags, set = _setLinePlacementFlags )
747 SIP_PROPERTY( name = mergeLines, get = _getMergeLines, set = _setMergeLines )
748 SIP_PROPERTY( name = addDirectionSymbol, get = _getAddDirectionSymbol, set = _setAddDirectionSymbol )
749 SIP_PROPERTY( name = leftDirectionSymbol, get = _getLeftDirectionSymbol, set = _setLeftDirectionSymbol )
750 SIP_PROPERTY( name = rightDirectionSymbol, get = _getRightDirectionSymbol, set = _setRightDirectionSymbol )
751 SIP_PROPERTY( name = reverseDirectionSymbol, get = _getReverseDirectionSymbol, set = _setReverseDirectionSymbol )
752 SIP_PROPERTY( name = placeDirectionSymbol, get = _getPlaceDirectionSymbol, set = _setPlaceDirectionSymbol )
754 SIP_PROPERTY( name = overrunDistance, get = _getOverrunDistance, set = _setOverrunDistance )
755 SIP_PROPERTY( name = overrunDistanceUnit, get = _getOverrunDistanceUnit, set = _setOverrunDistanceUnit )
756 SIP_PROPERTY( name = overrunDistanceMapUnitScale, get = _getOverrunDistanceMapUnitScale, set = _setOverrunDistanceMapUnitScale )
760 bool _limitNumLabels()
const {
return mThinningSettings.limitNumberOfLabelsEnabled(); }
761 void _setLimitNumLabels(
bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
762 int _maxNumLabels()
const {
return mThinningSettings.maximumNumberLabels(); }
763 void _setMaxNumLabels(
int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
764 double _minFeatureSize()
const {
return mThinningSettings.minimumFeatureSize(); }
765 void _setMinFeatureSize(
double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
766 bool _getIsObstacle()
const {
return mObstacleSettings.isObstacle(); }
767 void _setIsObstacle(
bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
768 double _getObstacleFactor()
const {
return mObstacleSettings.factor(); }
769 void _setObstacleFactor(
double factor ) { mObstacleSettings.setFactor( factor ); }
770 ObstacleType _getObstacleType()
const {
return static_cast< ObstacleType
>( mObstacleSettings.type() ); }
772 unsigned int _getLinePlacementFlags()
const {
return static_cast< unsigned int >( mLineSettings.placementFlags() ); }
773 void _setLinePlacementFlags(
unsigned int flags ) { mLineSettings.setPlacementFlags(
static_cast< QgsLabeling::LinePlacementFlags
>( flags ) ); }
774 bool _getMergeLines()
const {
return mLineSettings.mergeLines(); }
775 void _setMergeLines(
bool merge ) { mLineSettings.setMergeLines( merge ); }
776 bool _getAddDirectionSymbol()
const {
return mLineSettings.addDirectionSymbol(); }
777 void _setAddDirectionSymbol(
bool add ) { mLineSettings.setAddDirectionSymbol( add ); }
778 QString _getLeftDirectionSymbol()
const {
return mLineSettings.leftDirectionSymbol(); }
779 void _setLeftDirectionSymbol(
const QString &symbol ) { mLineSettings.setLeftDirectionSymbol( symbol ); }
780 QString _getRightDirectionSymbol()
const {
return mLineSettings.rightDirectionSymbol(); }
781 void _setRightDirectionSymbol(
const QString &symbol ) { mLineSettings.setRightDirectionSymbol( symbol ); }
782 bool _getReverseDirectionSymbol()
const {
return mLineSettings.reverseDirectionSymbol(); }
783 void _setReverseDirectionSymbol(
bool reverse ) { mLineSettings.setReverseDirectionSymbol( reverse ); }
785 DirectionSymbols _getPlaceDirectionSymbol()
const {
return static_cast< DirectionSymbols
>( mLineSettings.directionSymbolPlacement() ); }
788 double _getOverrunDistance()
const {
return mLineSettings.overrunDistance(); }
789 void _setOverrunDistance(
double distance ) { mLineSettings.setOverrunDistance( distance ); }
792 QgsMapUnitScale _getOverrunDistanceMapUnitScale()
const {
return mLineSettings.overrunDistanceMapUnitScale(); }
793 void _setOverrunDistanceMapUnitScale(
const QgsMapUnitScale &scale ) { mLineSettings.setOverrunDistanceMapUnitScale( scale ); }
806 bool geometryGeneratorEnabled =
false;
833 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,
836 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 );
1024 static QPixmap labelSettingsPreviewPixmap(
const QgsPalLayerSettings &settings, QSize size,
const QString &previewText = QString(),
int padding = 0 );
1052 int mFeaturesToLabel = 0;
1053 int mFeatsSendingToPal = 0;
1054 int mFeatsRegPal = 0;
1069 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1076 enum DataDefinedValueType
1095 bool dataDefinedValEval( DataDefinedValueType valType,
1097 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1099 void parseTextStyle( QFont &labelFont,
1124 QMap<Property, QVariant> dataDefinedValues;
1131 std::unique_ptr< QFontDatabase > mFontDB;
1135 std::unique_ptr< QgsCallout > mCallout;
1141 QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1145 bool mRenderStarted =
false;
1147 QString mLegendString = QObject::tr(
"Aa" );
1154 static void initPropertyDefinitions();
1183 static bool staticWillUseLayer(
const QgsMapLayer *layer );
1224 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1234 static QStringList splitToGraphemes(
const QString &text );
1239 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1243 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1247 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1251 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1255 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1259 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