QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
QgsLabelFeature Class Reference

Describes a feature that should be used within the labeling engine. More...

#include <qgslabelfeature.h>

Inheritance diagram for QgsLabelFeature:

Public Member Functions

 QgsLabelFeature (QgsFeatureId id, geos::unique_ptr geometry, QSizeF size, int subPartId=0)
 Constructor for QgsLabelFeature.
virtual ~QgsLabelFeature ()
bool allowDegradedPlacement () const
 Returns true if the label can be placed in inferior fallback positions if it cannot otherwise be placed.
bool alwaysShow () const
 Whether label should be always shown (sets very high label priority).
QgsPointXY anchorPosition () const
 In case of quadrand or aligned positioning, this is set to the anchor point.
Qgis::LabelLinePlacementFlags arrangementFlags () const
 Returns the feature's arrangement flags.
Qgis::CurvedLabelMode curvedLabelMode () const
 Returns the mode which determine how curved labels are generated and placed.
double distLabel () const
 Applies to "around point" placement strategy or linestring features.
QgsFeature feature () const
 Returns the original feature associated with this label.
double fixedAngle () const
 Angle in radians of the fixed angle (relevant only if hasFixedAngle() returns true).
QgsPointXY fixedPosition () const
 Coordinates of the fixed position (relevant only if hasFixedPosition() returns true).
GEOSGeometrygeometry () const
 Gets access to the associated geometry.
bool hasFixedAngle () const
 Whether the label should use a fixed angle instead of using angle from automatic placement.
bool hasFixedPosition () const
 Whether the label should use a fixed position instead of being automatically placed.
bool hasFixedQuadrant () const
 Returns whether the quadrant for the label is fixed.
QgsFeatureId id () const
 Identifier of the label (unique within the parent label provider).
QString labelText () const
 Text of the label.
pal::Layerlayer () const
 Gets PAL layer of the label feature. Should be only used internally in PAL.
double lineAnchorPercent () const
 Returns the percent along the line at which labels should be placed, for line labels only.
QgsLabelLineSettings::AnchorTextPoint lineAnchorTextPoint () const
 Returns the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().
QgsLabelLineSettings::AnchorType lineAnchorType () const
 Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
double maximumDistance () const
 Returns the maximum distance which labels are allowed to be from their corresponding points.
double minimumSize () const
 Returns the minimum size (in map unit) for a feature to be labelled.
Qgis::MultiPartLabelingBehavior multiPartBehavior () const
 Returns the multipart labeling behavior.
const QgsLabelObstacleSettingsobstacleSettings () const
 Returns the label's obstacle settings.
Qgis::LabelOffsetType offsetType () const
 Returns the offset type, which determines how offsets and distance to label behaves.
QgsCoordinateReferenceSystem originalFeatureCrs () const
 Returns the original layer CRS of the feature associated with the label.
QRectF outerBounds () const
 Returns the extreme outer bounds of the label feature, including any surrounding content like borders or background shapes.
Qgis::LabelOverlapHandling overlapHandling () const
 Returns the technique to use for handling overlapping labels for the feature.
double overrunDistance () const
 Returns the permissible distance (in map units) which labels are allowed to overrun the start or end of linear features.
double overrunSmoothDistance () const
 Returns the distance (in map units) with which the ends of linear features are averaged over when calculating the direction at which to overrun labels.
QgsGeometry permissibleZone () const
 Returns the label's permissible zone geometry.
const GEOSPreparedGeometry * permissibleZonePrepared () const
 Returns a GEOS prepared geometry representing the label's permissibleZone().
Qgis::LabelPolygonPlacementFlags polygonPlacementFlags () const
 Returns the polygon placement flags, which dictate how polygon labels can be placed.
QgsPointXY positionOffset () const
 Applies only to "offset from point" placement strategy.
QVector< Qgis::LabelPredefinedPointPositionpredefinedPositionOrder () const
 Returns the priority ordered list of predefined positions for label candidates.
Qgis::LabelPrioritization prioritization () const
 Returns the label prioritization technique.
double priority () const
 Returns the feature's labeling priority.
QgsAbstractLabelProviderprovider () const
 Returns provider of this instance.
QPointF quadOffset () const
 Applies to "offset from point" placement strategy and "around point" (in case hasFixedQuadrant() returns true).
double repeatDistance () const
 Applies only to linestring features - after what distance (in map units) the labels should be repeated (0 = no repetitions).
void setAllowDegradedPlacement (bool allow)
 Sets whether the label can be placed in inferior fallback positions if it cannot otherwise be placed.
void setAlwaysShow (bool enabled)
 Sets whether label should be always shown (sets very high label priority).
void setAnchorPosition (const QgsPointXY &anchorPosition)
 In case of quadrand or aligned positioning, this is set to the anchor point.
void setArrangementFlags (Qgis::LabelLinePlacementFlags flags)
 Sets the feature's arrangement flags.
void setCurvedLabelMode (Qgis::CurvedLabelMode mode)
 Sets the mode which determine how curved labels are generated and placed.
void setDistLabel (double dist)
 Applies to "around point" placement strategy or linestring features.
void setFeature (const QgsFeature &feature)
 Sets the original feature associated with this label.
void setFixedAngle (double angle)
 Sets the angle in radians of the fixed angle (relevant only if hasFixedAngle() returns true).
void setFixedPosition (const QgsPointXY &point)
 Sets coordinates of the fixed position (relevant only if hasFixedPosition() returns true).
void setHasFixedAngle (bool enabled)
 Sets whether the label should use a fixed angle instead of using angle from automatic placement.
void setHasFixedPosition (bool enabled)
 Sets whether the label should use a fixed position instead of being automatically placed.
void setHasFixedQuadrant (bool enabled)
 Sets whether the quadrant for the label must be respected.
void setLabelText (const QString &text)
 Sets text of the label.
void setLayer (pal::Layer *layer)
 Assign PAL layer to the label feature. Should be only used internally in PAL.
void setLineAnchorPercent (double percent)
 Sets the percent along the line at which labels should be placed, for line labels only.
void setLineAnchorTextPoint (QgsLabelLineSettings::AnchorTextPoint point)
 Sets the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().
void setLineAnchorType (QgsLabelLineSettings::AnchorType type)
 Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.
void setMaximumDistance (double distance)
 Sets the maximum distance which labels are allowed to be from their corresponding points.
void setMinimumSize (double size)
 Sets the minimum size (in map unit) for a feature to be labelled.
void setMultiPartBehavior (Qgis::MultiPartLabelingBehavior behavior)
 Sets the multipart labeling behavior.
void setObstacleSettings (const QgsLabelObstacleSettings &settings)
 Sets the label's obstacle settings.
void setOffsetType (Qgis::LabelOffsetType type)
 Sets the offset type, which determines how offsets and distance to label behaves.
void setOriginalFeatureCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the original layer crs of the feature associated with the label.
void setOuterBounds (const QRectF &bounds)
 Sets the extreme outer bounds of the label feature, including any surrounding content like borders or background shapes.
void setOverlapHandling (Qgis::LabelOverlapHandling handling)
 Sets the technique to use for handling overlapping labels for the feature.
void setOverrunDistance (double distance)
 Sets the permissible distance (in map units) which labels are allowed to overrun the start or end of linear features.
void setOverrunSmoothDistance (double distance)
 Sets the distance (in map units) with which the ends of linear features are averaged over when calculating the direction at which to overrun labels.
void setPermissibleZone (const QgsGeometry &geometry)
 Sets the label's permissible zone geometry.
void setPolygonPlacementFlags (Qgis::LabelPolygonPlacementFlags flags)
 Sets the polygon placement flags, which dictate how polygon labels can be placed.
void setPositionOffset (const QgsPointXY &offset)
 Applies only to "offset from point" placement strategy.
void setPredefinedPositionOrder (const QVector< Qgis::LabelPredefinedPointPosition > &order)
 Sets the priority ordered list of predefined positions for label candidates.
void setPrioritization (Qgis::LabelPrioritization prioritization)
 Sets the label prioritization technique.
void setPriority (double priority)
 Sets the priority for labeling the feature.
void setQuadOffset (QPointF quadOffset)
 Set which side of the point to use.
void setRepeatDistance (double dist)
 Applies only to linestring features - set after what distance (in map units) the labels should be repeated (0 = no repetitions).
void setRotatedSize (QSizeF size)
 Sets an alternate label size to be used when a label rotation angle is between 45 to 135 and 235 to 313 degrees and the text rotation mode is set to rotation-based.
void setSymbol (const QgsSymbol *symbol)
 Sets the feature symbol associated with this label.
void setSymbolSize (QSizeF size)
 Sets the size of the rendered symbol associated with this feature.
void setThinningSettings (const QgsLabelFeatureThinningSettings &settings)
 Sets the thinning settings for this label.
void setVisualMargin (const QgsMargins &margin)
 Sets the visual margin for the label feature.
void setWhitespaceCollisionHandling (Qgis::LabelWhitespaceCollisionHandling handling)
 Sets the whitespace collision handling.
void setZIndex (double zIndex)
 Sets the label's z-index.
QSizeF size (double angle=0.0) const
 Size of the label (in map units).
int subPartId () const
 Sub part identifier (for features which register multiple labels).
const QgsSymbolsymbol () const
 Returns the feature symbol associated with this label.
const QSizeF & symbolSize () const
 Returns the size of the rendered symbol associated with this feature, if applicable.
const QgsLabelFeatureThinningSettingsthinningSettings () const
 Returns the thinning settings for this label.
const QgsMarginsvisualMargin () const
 Returns the visual margin for the label feature.
Qgis::LabelWhitespaceCollisionHandling whitespaceCollisionHandling () const
 Returns the whitespace collision handling.
double zIndex () const
 Returns the label's z-index.

Protected Attributes

bool mAlwaysShow = false
 whether to always show label - even in case of collisions
Qgis::LabelLinePlacementFlags mArrangementFlags = Qgis::LabelLinePlacementFlags()
double mDistLabel = 0
 distance of label from the feature (only for "around point" placement or linestrings)
double mFixedAngle = 0
 fixed rotation for the label (instead of automatic choice)
QgsPointXY mFixedPosition
 fixed position for the label (instead of automatic placement)
geos::unique_ptr mGeometry
 Geometry of the feature to be labelled.
bool mHasFixedAngle = false
 whether mFixedAngle should be respected
bool mHasFixedPosition = false
 whether mFixedPosition should be respected
bool mHasFixedQuadrant = false
 whether mQuadOffset should be respected (only for "around point" placement)
QgsFeatureId mId
 Associated ID unique within the parent label provider.
QString mLabelText
 text of the label
pal::LayermLayer = nullptr
 Pointer to PAL layer (assigned when registered to PAL).
double mMaximumDistance = 0
 Maximum distance of label from the feature.
Qgis::LabelOffsetType mOffsetType = Qgis::LabelOffsetType::FromPoint
 Offset type for certain placement modes.
QRectF mOuterBounds
 Extreme outer bounds of the label feature, including any surrounding content like borders or background shapes.
double mOverrunDistance = 0
 Distance to allow label to overrun linear features.
double mOverrunSmoothDistance = 0
 Distance to smooth angle of line start and end when calculating overruns.
QgsGeometry mPermissibleZone
 Optional geometry to use for label's permissible zone.
Qgis::LabelPolygonPlacementFlags mPolygonPlacementFlags = Qgis::LabelPolygonPlacementFlag::AllowPlacementInsideOfPolygon
QgsPointXY mPositionOffset
 offset of label from the feature (only for "offset from point" placement)
QVector< Qgis::LabelPredefinedPointPositionmPredefinedPositionOrder
 Ordered list of predefined positions for label (only for OrderedPositionsAroundPoint placement).
double mPriority = -1
 Priority of the label.
QPointF mQuadOffset
 whether the side of the label is fixed (only for "around point" placement)
double mRepeatDistance = 0
 distance after which label should be repeated (only for linestrings)
QSizeF mRotatedSize
 Width and height of the label when rotated between 45 to 135 and 235 to 315 degrees;.
QSizeF mSize
 Width and height of the label.
int mSubPartId = 0
 Associated sub part ID, for features which register multiple different labels.
QSizeF mSymbolSize
 Size of associated rendered symbol, if applicable.
QgsMargins mVisualMargin
 Visual margin of label contents.
double mZIndex = 0
 Z-index of label (higher z-index labels are rendered on top of lower z-index labels).

Detailed Description

Describes a feature that should be used within the labeling engine.

Those may be the usual textual labels, diagrams, or any other custom type of map annotations (generated by custom label providers).

Instances only contain data relevant to the labeling engine (geometry, label size etc.) necessary for the layout. Rendering of labels is done by label providers.

Individual label providers may create subclasses of QgsLabelFeature in order to add more data to the instances that will be later used for drawing of labels.

Note
this class is not a part of public API yet. See notes in QgsLabelingEngine
not available in Python bindings

Definition at line 58 of file qgslabelfeature.h.

Constructor & Destructor Documentation

◆ QgsLabelFeature()

QgsLabelFeature::QgsLabelFeature ( QgsFeatureId id,
geos::unique_ptr geometry,
QSizeF size,
int subPartId = 0 )

Constructor for QgsLabelFeature.

The feature id argument links the label feature back to the original layer feature.

The geometry argument specifies the geometry associated with the feature, which is used by the labeling engine to generate candidate placements for the label. For a vector layer feature this will generally be the feature's geometry.

The size argument dictates the size of the label's content (e.g. text width and height).

The optional subPartId argument can be used to identify unique labels for features which register multiple labels with the same id.

Definition at line 21 of file qgslabelfeature.cpp.

◆ ~QgsLabelFeature()

QgsLabelFeature::~QgsLabelFeature ( )
virtual

Definition at line 29 of file qgslabelfeature.cpp.

Member Function Documentation

◆ allowDegradedPlacement()

bool QgsLabelFeature::allowDegradedPlacement ( ) const
inline

Returns true if the label can be placed in inferior fallback positions if it cannot otherwise be placed.

For instance, this will permit a curved line label to fallback to a horizontal label at the end of the line if the label cannot otherwise be placed on the line in a curved manner.

See also
setAllowDegradedPlacement()
Since
QGIS 3.26

Definition at line 706 of file qgslabelfeature.h.

◆ alwaysShow()

bool QgsLabelFeature::alwaysShow ( ) const
inline

Whether label should be always shown (sets very high label priority).

Definition at line 385 of file qgslabelfeature.h.

◆ anchorPosition()

QgsPointXY QgsLabelFeature::anchorPosition ( ) const

In case of quadrand or aligned positioning, this is set to the anchor point.

This can be used for proper vector based output like DXF.

Since
QGIS 3.12

Definition at line 73 of file qgslabelfeature.cpp.

◆ arrangementFlags()

Qgis::LabelLinePlacementFlags QgsLabelFeature::arrangementFlags ( ) const
inline

Returns the feature's arrangement flags.

See also
setArrangementFlags

Definition at line 393 of file qgslabelfeature.h.

◆ curvedLabelMode()

Qgis::CurvedLabelMode QgsLabelFeature::curvedLabelMode ( ) const
inline

Returns the mode which determine how curved labels are generated and placed.

See also
setCurvedLabelMode()
Since
QGIS 4.0

Definition at line 581 of file qgslabelfeature.h.

◆ distLabel()

double QgsLabelFeature::distLabel ( ) const
inline

Applies to "around point" placement strategy or linestring features.

Distance of the label from the feature (in map units)

See also
setDistLabel()
maximumDistance()

Definition at line 315 of file qgslabelfeature.h.

◆ feature()

QgsFeature QgsLabelFeature::feature ( ) const

Returns the original feature associated with this label.

See also
setFeature()
Since
QGIS 3.10

Definition at line 59 of file qgslabelfeature.cpp.

◆ fixedAngle()

double QgsLabelFeature::fixedAngle ( ) const
inline

Angle in radians of the fixed angle (relevant only if hasFixedAngle() returns true).

See also
setFixedAngle()

Definition at line 242 of file qgslabelfeature.h.

◆ fixedPosition()

QgsPointXY QgsLabelFeature::fixedPosition ( ) const
inline

Coordinates of the fixed position (relevant only if hasFixedPosition() returns true).

Definition at line 212 of file qgslabelfeature.h.

◆ geometry()

GEOSGeometry * QgsLabelFeature::geometry ( ) const
inline

Gets access to the associated geometry.

Definition at line 87 of file qgslabelfeature.h.

◆ hasFixedAngle()

bool QgsLabelFeature::hasFixedAngle ( ) const
inline

Whether the label should use a fixed angle instead of using angle from automatic placement.

Definition at line 234 of file qgslabelfeature.h.

◆ hasFixedPosition()

bool QgsLabelFeature::hasFixedPosition ( ) const
inline

Whether the label should use a fixed position instead of being automatically placed.

Definition at line 208 of file qgslabelfeature.h.

◆ hasFixedQuadrant()

bool QgsLabelFeature::hasFixedQuadrant ( ) const
inline

Returns whether the quadrant for the label is fixed.

Applies to "around point" placement strategy.

See also
setHasFixedQuadrant
quadOffset

Definition at line 256 of file qgslabelfeature.h.

◆ id()

QgsFeatureId QgsLabelFeature::id ( ) const
inline

Identifier of the label (unique within the parent label provider).

Definition at line 81 of file qgslabelfeature.h.

◆ labelText()

QString QgsLabelFeature::labelText ( ) const
inline

Text of the label.

Used also if "merge connected lines to avoid duplicate labels" is enabled to identify which features may be merged.

Definition at line 424 of file qgslabelfeature.h.

◆ layer()

pal::Layer * QgsLabelFeature::layer ( ) const
inline

Gets PAL layer of the label feature. Should be only used internally in PAL.

Definition at line 429 of file qgslabelfeature.h.

◆ lineAnchorPercent()

double QgsLabelFeature::lineAnchorPercent ( ) const
inline

Returns the percent along the line at which labels should be placed, for line labels only.

By default, this is 0.5 which indicates that labels should be placed as close to the center of the line as possible. A value of 0.0 indicates that the labels should be placed as close to the start of the line as possible, while a value of 1.0 pushes labels towards the end of the line.

See also
setLineAnchorPercent()
lineAnchorType()
Since
QGIS 3.16

Definition at line 521 of file qgslabelfeature.h.

◆ lineAnchorTextPoint()

QgsLabelLineSettings::AnchorTextPoint QgsLabelFeature::lineAnchorTextPoint ( ) const

Returns the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().

See also
setLineAnchorTextPoint()
Since
QGIS 3.26

Definition at line 103 of file qgslabelfeature.cpp.

◆ lineAnchorType()

QgsLabelLineSettings::AnchorType QgsLabelFeature::lineAnchorType ( ) const
inline

Returns the line anchor type, which dictates how the lineAnchorPercent() setting is handled.

See also
setLineAnchorType()
lineAnchorPercent()

Definition at line 544 of file qgslabelfeature.h.

◆ maximumDistance()

double QgsLabelFeature::maximumDistance ( ) const
inline

Returns the maximum distance which labels are allowed to be from their corresponding points.

This setting works alongside distLabel() to define a permissible range of distances at which labels can be placed from their points.

The default value is 0, which indicates that no maximum is set and the that distLabel() always be respected.

See also
setMaximumDistance()
distLabel()
Since
QGIS 3.38

Definition at line 340 of file qgslabelfeature.h.

◆ minimumSize()

double QgsLabelFeature::minimumSize ( ) const
inline

Returns the minimum size (in map unit) for a feature to be labelled.

Note
At the moment this is only used when labeling merged lines
See also
minimumSize()
Since
QGIS 3.20

Definition at line 669 of file qgslabelfeature.h.

◆ multiPartBehavior()

Qgis::MultiPartLabelingBehavior QgsLabelFeature::multiPartBehavior ( ) const
inline

Returns the multipart labeling behavior.

See also
setMultiPartBehavior()
Since
QGIS 4.0

Definition at line 598 of file qgslabelfeature.h.

◆ obstacleSettings()

const QgsLabelObstacleSettings & QgsLabelFeature::obstacleSettings ( ) const

Returns the label's obstacle settings.

See also
setObstacleSettings()
Since
QGIS 3.12

Definition at line 120 of file qgslabelfeature.cpp.

◆ offsetType()

Qgis::LabelOffsetType QgsLabelFeature::offsetType ( ) const
inline

Returns the offset type, which determines how offsets and distance to label behaves.

Support depends on which placement mode is used for generating label candidates.

See also
setOffsetType()

Definition at line 298 of file qgslabelfeature.h.

◆ originalFeatureCrs()

QgsCoordinateReferenceSystem QgsLabelFeature::originalFeatureCrs ( ) const

Returns the original layer CRS of the feature associated with the label.

See also
setOriginalFeatureCrs()
Since
QGIS 3.20

Definition at line 130 of file qgslabelfeature.cpp.

◆ outerBounds()

QRectF QgsLabelFeature::outerBounds ( ) const
inline

Returns the extreme outer bounds of the label feature, including any surrounding content like borders or background shapes.

See also
setOuterBounds()
Since
QGIS 3.30

Definition at line 129 of file qgslabelfeature.h.

◆ overlapHandling()

Qgis::LabelOverlapHandling QgsLabelFeature::overlapHandling ( ) const
inline

Returns the technique to use for handling overlapping labels for the feature.

See also
setOverlapHandling()
Since
QGIS 3.26

Definition at line 686 of file qgslabelfeature.h.

◆ overrunDistance()

double QgsLabelFeature::overrunDistance ( ) const

Returns the permissible distance (in map units) which labels are allowed to overrun the start or end of linear features.

See also
setOverrunDistance()
overrunSmoothDistance()
Since
QGIS 3.10

Definition at line 83 of file qgslabelfeature.cpp.

◆ overrunSmoothDistance()

double QgsLabelFeature::overrunSmoothDistance ( ) const

Returns the distance (in map units) with which the ends of linear features are averaged over when calculating the direction at which to overrun labels.

See also
setOverrunSmoothDistance()
overrunDistance()
Since
QGIS 3.10

Definition at line 93 of file qgslabelfeature.cpp.

◆ permissibleZone()

QgsGeometry QgsLabelFeature::permissibleZone ( ) const
inline

Returns the label's permissible zone geometry.

If a valid geometry is returned, the feature's label MUST be fully contained within this zone, and the feature will not be labeled if no candidates can be generated which are not contained within the zone.

See also
setPermissibleZone()
permissibleZonePrepared()

Definition at line 106 of file qgslabelfeature.h.

◆ permissibleZonePrepared()

const GEOSPreparedGeometry * QgsLabelFeature::permissibleZonePrepared ( ) const
inline

Returns a GEOS prepared geometry representing the label's permissibleZone().

See also
permissibleZone()

Definition at line 113 of file qgslabelfeature.h.

◆ polygonPlacementFlags()

Qgis::LabelPolygonPlacementFlags QgsLabelFeature::polygonPlacementFlags ( ) const
inline

Returns the polygon placement flags, which dictate how polygon labels can be placed.

See also
setPolygonPlacementFlags()
Since
QGIS 3.14

Definition at line 408 of file qgslabelfeature.h.

◆ positionOffset()

QgsPointXY QgsLabelFeature::positionOffset ( ) const
inline

Applies only to "offset from point" placement strategy.

What offset (in map units) to use from the point

Definition at line 284 of file qgslabelfeature.h.

◆ predefinedPositionOrder()

QVector< Qgis::LabelPredefinedPointPosition > QgsLabelFeature::predefinedPositionOrder ( ) const
inline

Returns the priority ordered list of predefined positions for label candidates.

This property is only used for OrderedPositionsAroundPoint placements.

See also
setPredefinedPositionOrder()

Definition at line 363 of file qgslabelfeature.h.

◆ prioritization()

Qgis::LabelPrioritization QgsLabelFeature::prioritization ( ) const
inline

Returns the label prioritization technique.

See also
setPrioritization()
Since
QGIS 3.38

Definition at line 714 of file qgslabelfeature.h.

◆ priority()

double QgsLabelFeature::priority ( ) const
inline

Returns the feature's labeling priority.

Returns
feature's priority, as a value between 0 (highest priority) and 1 (lowest priority). Returns -1.0 if feature will use the layer's default priority.
See also
setPriority

Definition at line 181 of file qgslabelfeature.h.

◆ provider()

QgsAbstractLabelProvider * QgsLabelFeature::provider ( ) const

Returns provider of this instance.

Definition at line 898 of file qgslabelingengine.cpp.

◆ quadOffset()

QPointF QgsLabelFeature::quadOffset ( ) const
inline

Applies to "offset from point" placement strategy and "around point" (in case hasFixedQuadrant() returns true).

Determines which side of the point to use. For X coordinate, values -1, 0, 1 mean left, center, right. For Y coordinate, values -1, 0, 1 mean above, center, below.

Definition at line 272 of file qgslabelfeature.h.

◆ repeatDistance()

double QgsLabelFeature::repeatDistance ( ) const
inline

Applies only to linestring features - after what distance (in map units) the labels should be repeated (0 = no repetitions).

Definition at line 376 of file qgslabelfeature.h.

◆ setAllowDegradedPlacement()

void QgsLabelFeature::setAllowDegradedPlacement ( bool allow)
inline

Sets whether the label can be placed in inferior fallback positions if it cannot otherwise be placed.

For instance, this will permit a curved line label to fallback to a horizontal label at the end of the line if the label cannot otherwise be placed on the line in a curved manner.

See also
allowDegradedPlacement()
Since
QGIS 3.26

Definition at line 734 of file qgslabelfeature.h.

◆ setAlwaysShow()

void QgsLabelFeature::setAlwaysShow ( bool enabled)
inline

Sets whether label should be always shown (sets very high label priority).

Definition at line 387 of file qgslabelfeature.h.

◆ setAnchorPosition()

void QgsLabelFeature::setAnchorPosition ( const QgsPointXY & anchorPosition)

In case of quadrand or aligned positioning, this is set to the anchor point.

This can be used for proper vector based output like DXF.

Since
QGIS 3.12

Definition at line 140 of file qgslabelfeature.cpp.

◆ setArrangementFlags()

void QgsLabelFeature::setArrangementFlags ( Qgis::LabelLinePlacementFlags flags)
inline

Sets the feature's arrangement flags.

Parameters
flagsarrangement flags
See also
arrangementFlags

Definition at line 400 of file qgslabelfeature.h.

◆ setCurvedLabelMode()

void QgsLabelFeature::setCurvedLabelMode ( Qgis::CurvedLabelMode mode)
inline

Sets the mode which determine how curved labels are generated and placed.

See also
curvedLabelMode()
Since
QGIS 4.0

Definition at line 589 of file qgslabelfeature.h.

◆ setDistLabel()

void QgsLabelFeature::setDistLabel ( double dist)
inline

Applies to "around point" placement strategy or linestring features.

Set distance of the label from the feature (in map units)

See also
distLabel()
setMaximumDistance()

Definition at line 324 of file qgslabelfeature.h.

◆ setFeature()

void QgsLabelFeature::setFeature ( const QgsFeature & feature)

Sets the original feature associated with this label.

See also
feature()
Since
QGIS 3.10

Definition at line 78 of file qgslabelfeature.cpp.

◆ setFixedAngle()

void QgsLabelFeature::setFixedAngle ( double angle)
inline

Sets the angle in radians of the fixed angle (relevant only if hasFixedAngle() returns true).

See also
fixedAngle()

Definition at line 248 of file qgslabelfeature.h.

◆ setFixedPosition()

void QgsLabelFeature::setFixedPosition ( const QgsPointXY & point)
inline

Sets coordinates of the fixed position (relevant only if hasFixedPosition() returns true).

Definition at line 215 of file qgslabelfeature.h.

◆ setHasFixedAngle()

void QgsLabelFeature::setHasFixedAngle ( bool enabled)
inline

Sets whether the label should use a fixed angle instead of using angle from automatic placement.

Definition at line 236 of file qgslabelfeature.h.

◆ setHasFixedPosition()

void QgsLabelFeature::setHasFixedPosition ( bool enabled)
inline

Sets whether the label should use a fixed position instead of being automatically placed.

Definition at line 210 of file qgslabelfeature.h.

◆ setHasFixedQuadrant()

void QgsLabelFeature::setHasFixedQuadrant ( bool enabled)
inline

Sets whether the quadrant for the label must be respected.

This can be used to fix the quadrant for specific features when using an "around point" placement.

See also
hasFixedQuadrant
quadOffset

Definition at line 264 of file qgslabelfeature.h.

◆ setLabelText()

void QgsLabelFeature::setLabelText ( const QString & text)
inline

Sets text of the label.

Definition at line 426 of file qgslabelfeature.h.

◆ setLayer()

void QgsLabelFeature::setLayer ( pal::Layer * layer)
inline

Assign PAL layer to the label feature. Should be only used internally in PAL.

Definition at line 431 of file qgslabelfeature.h.

◆ setLineAnchorPercent()

void QgsLabelFeature::setLineAnchorPercent ( double percent)
inline

Sets the percent along the line at which labels should be placed, for line labels only.

By default, this is 0.5 which indicates that labels should be placed as close to the center of the line as possible. A value of 0.0 indicates that the labels should be placed as close to the start of the line as possible, while a value of 1.0 pushes labels towards the end of the line.

See also
lineAnchorPercent()
setLineAnchorType()
Since
QGIS 3.16

Definition at line 535 of file qgslabelfeature.h.

◆ setLineAnchorTextPoint()

void QgsLabelFeature::setLineAnchorTextPoint ( QgsLabelLineSettings::AnchorTextPoint point)
inline

Sets the line anchor text point, which dictates which part of the label text should be placed at the lineAnchorPercent().

See also
lineAnchorTextPoint()
Since
QGIS 3.26

Definition at line 573 of file qgslabelfeature.h.

◆ setLineAnchorType()

void QgsLabelFeature::setLineAnchorType ( QgsLabelLineSettings::AnchorType type)
inline

Sets the line anchor type, which dictates how the lineAnchorPercent() setting is handled.

See also
lineAnchorType()
setLineAnchorPercent()

Definition at line 553 of file qgslabelfeature.h.

◆ setMaximumDistance()

void QgsLabelFeature::setMaximumDistance ( double distance)
inline

Sets the maximum distance which labels are allowed to be from their corresponding points.

This setting works alongside distLabel() to define a permissible range of distances at which labels can be placed from their points.

The default value is 0, which indicates that no maximum is set and the that distLabel() always be respected.

See also
maximumDistance()
setDistLabel()
Since
QGIS 3.38

Definition at line 356 of file qgslabelfeature.h.

◆ setMinimumSize()

void QgsLabelFeature::setMinimumSize ( double size)
inline

Sets the minimum size (in map unit) for a feature to be labelled.

Note
At the moment this is only used when labeling merged lines
See also
setMinimumSize()
Since
QGIS 3.20

Definition at line 678 of file qgslabelfeature.h.

◆ setMultiPartBehavior()

void QgsLabelFeature::setMultiPartBehavior ( Qgis::MultiPartLabelingBehavior behavior)
inline

Sets the multipart labeling behavior.

See also
multiPartBehavior()
Since
QGIS 4.0

Definition at line 607 of file qgslabelfeature.h.

◆ setObstacleSettings()

void QgsLabelFeature::setObstacleSettings ( const QgsLabelObstacleSettings & settings)

Sets the label's obstacle settings.

See also
obstacleSettings()
Since
QGIS 3.12

Definition at line 125 of file qgslabelfeature.cpp.

◆ setOffsetType()

void QgsLabelFeature::setOffsetType ( Qgis::LabelOffsetType type)
inline

Sets the offset type, which determines how offsets and distance to label behaves.

Support depends on which placement mode is used for generating label candidates.

See also
offsetType()

Definition at line 306 of file qgslabelfeature.h.

◆ setOriginalFeatureCrs()

void QgsLabelFeature::setOriginalFeatureCrs ( const QgsCoordinateReferenceSystem & crs)

Sets the original layer crs of the feature associated with the label.

See also
originalFeatureCrs()
Since
QGIS 3.20

Definition at line 135 of file qgslabelfeature.cpp.

◆ setOuterBounds()

void QgsLabelFeature::setOuterBounds ( const QRectF & bounds)
inline

Sets the extreme outer bounds of the label feature, including any surrounding content like borders or background shapes.

See also
outerBounds()
Since
QGIS 3.30

Definition at line 138 of file qgslabelfeature.h.

◆ setOverlapHandling()

void QgsLabelFeature::setOverlapHandling ( Qgis::LabelOverlapHandling handling)
inline

Sets the technique to use for handling overlapping labels for the feature.

See also
overlapHandling()
Since
QGIS 3.26

Definition at line 694 of file qgslabelfeature.h.

◆ setOverrunDistance()

void QgsLabelFeature::setOverrunDistance ( double distance)

Sets the permissible distance (in map units) which labels are allowed to overrun the start or end of linear features.

See also
overrunDistance()
setOverrunSmoothDistance()
Since
QGIS 3.10

Definition at line 88 of file qgslabelfeature.cpp.

◆ setOverrunSmoothDistance()

void QgsLabelFeature::setOverrunSmoothDistance ( double distance)

Sets the distance (in map units) with which the ends of linear features are averaged over when calculating the direction at which to overrun labels.

See also
overrunSmoothDistance()
setOverrunDistance()
Since
QGIS 3.10

Definition at line 98 of file qgslabelfeature.cpp.

◆ setPermissibleZone()

void QgsLabelFeature::setPermissibleZone ( const QgsGeometry & geometry)

Sets the label's permissible zone geometry.

If set, the feature's label MUST be fully contained within this zone, and the feature will not be labeled if no candidates can be generated which are not contained within the zone.

Parameters
geometrypermissible zone geometry. If an invalid QgsGeometry is passed then no zone limit will be applied to the label candidates (this is the default behavior).
See also
permissibleZone()

Definition at line 38 of file qgslabelfeature.cpp.

◆ setPolygonPlacementFlags()

void QgsLabelFeature::setPolygonPlacementFlags ( Qgis::LabelPolygonPlacementFlags flags)
inline

Sets the polygon placement flags, which dictate how polygon labels can be placed.

See also
polygonPlacementFlags()
Since
QGIS 3.14

Definition at line 416 of file qgslabelfeature.h.

◆ setPositionOffset()

void QgsLabelFeature::setPositionOffset ( const QgsPointXY & offset)
inline

Applies only to "offset from point" placement strategy.

Set what offset (in map units) to use from the point

Definition at line 290 of file qgslabelfeature.h.

◆ setPredefinedPositionOrder()

void QgsLabelFeature::setPredefinedPositionOrder ( const QVector< Qgis::LabelPredefinedPointPosition > & order)
inline

Sets the priority ordered list of predefined positions for label candidates.

This property is only used for OrderedPositionsAroundPoint placements.

See also
predefinedPositionOrder()

Definition at line 370 of file qgslabelfeature.h.

◆ setPrioritization()

void QgsLabelFeature::setPrioritization ( Qgis::LabelPrioritization prioritization)
inline

Sets the label prioritization technique.

See also
prioritization()
Since
QGIS 3.26

Definition at line 722 of file qgslabelfeature.h.

◆ setPriority()

void QgsLabelFeature::setPriority ( double priority)
inline

Sets the priority for labeling the feature.

Parameters
priorityfeature's priority, as a value between 0 (highest priority) and 1 (lowest priority). Set to -1.0 to use the layer's default priority for this feature.
See also
priority

Definition at line 190 of file qgslabelfeature.h.

◆ setQuadOffset()

void QgsLabelFeature::setQuadOffset ( QPointF quadOffset)
inline

Set which side of the point to use.

See also
quadOffset

Definition at line 278 of file qgslabelfeature.h.

◆ setRepeatDistance()

void QgsLabelFeature::setRepeatDistance ( double dist)
inline

Applies only to linestring features - set after what distance (in map units) the labels should be repeated (0 = no repetitions).

Definition at line 382 of file qgslabelfeature.h.

◆ setRotatedSize()

void QgsLabelFeature::setRotatedSize ( QSizeF size)
inline

Sets an alternate label size to be used when a label rotation angle is between 45 to 135 and 235 to 313 degrees and the text rotation mode is set to rotation-based.

Since
QGIS 3.10

Definition at line 614 of file qgslabelfeature.h.

◆ setSymbol()

void QgsLabelFeature::setSymbol ( const QgsSymbol * symbol)
inline

Sets the feature symbol associated with this label.

Ownership of symbol is not transferred to the label feature, .

See also
symbol()
Since
QGIS 3.10

Definition at line 467 of file qgslabelfeature.h.

◆ setSymbolSize()

void QgsLabelFeature::setSymbolSize ( QSizeF size)
inline

Sets the size of the rendered symbol associated with this feature.

This size is taken into account in certain label placement modes to avoid placing labels over the rendered symbol for this feature.

See also
symbolSize()

Definition at line 164 of file qgslabelfeature.h.

◆ setThinningSettings()

void QgsLabelFeature::setThinningSettings ( const QgsLabelFeatureThinningSettings & settings)
inline

Sets the thinning settings for this label.

See also
thinningSettings()
Since
QGIS 3.44

Definition at line 644 of file qgslabelfeature.h.

◆ setVisualMargin()

void QgsLabelFeature::setVisualMargin ( const QgsMargins & margin)
inline

Sets the visual margin for the label feature.

The visual margin represents a margin within the label which should not be considered when calculating the positions of candidates for the label feature. It is used in certain label placement modes to adjust the position of candidates so that they all appear to be at visually equal distances from a point feature. For instance, this can be used to place labels which sit above a point so that their baseline rather then the descender of the label is at a preset distance from the point.

Parameters
marginvisual margins for label
See also
visualMargin()

Definition at line 150 of file qgslabelfeature.h.

◆ setWhitespaceCollisionHandling()

void QgsLabelFeature::setWhitespaceCollisionHandling ( Qgis::LabelWhitespaceCollisionHandling handling)
inline

Sets the whitespace collision handling.

See also
whitespaceCollisionHandling()
Since
QGIS 4.0

Definition at line 752 of file qgslabelfeature.h.

◆ setZIndex()

void QgsLabelFeature::setZIndex ( double zIndex)
inline

Sets the label's z-index.

Higher z-index labels are rendered on top of lower z-index labels.

Parameters
zIndexz-index for label
See also
zIndex()

Definition at line 205 of file qgslabelfeature.h.

◆ size()

QSizeF QgsLabelFeature::size ( double angle = 0.0) const

Size of the label (in map units).

An optional angle (in radians) can be specified to return the size taking into account the rotation.

Definition at line 64 of file qgslabelfeature.cpp.

◆ subPartId()

int QgsLabelFeature::subPartId ( ) const
inline

Sub part identifier (for features which register multiple labels).

Definition at line 84 of file qgslabelfeature.h.

◆ symbol()

const QgsSymbol * QgsLabelFeature::symbol ( ) const
inline

Returns the feature symbol associated with this label.

See also
setSymbol()
Since
QGIS 3.10

Definition at line 458 of file qgslabelfeature.h.

◆ symbolSize()

const QSizeF & QgsLabelFeature::symbolSize ( ) const
inline

Returns the size of the rendered symbol associated with this feature, if applicable.

This size is taken into account in certain label placement modes to avoid placing labels over the rendered symbol for this feature. The size will only be set for labels associated with a point feature.

See also
symbolSize()

Definition at line 173 of file qgslabelfeature.h.

◆ thinningSettings()

const QgsLabelFeatureThinningSettings & QgsLabelFeature::thinningSettings ( ) const
inline

Returns the thinning settings for this label.

See also
setThinningSettings()
Since
QGIS 3.44

Definition at line 637 of file qgslabelfeature.h.

◆ visualMargin()

const QgsMargins & QgsLabelFeature::visualMargin ( ) const
inline

Returns the visual margin for the label feature.

See also
setVisualMargin() for details

Definition at line 156 of file qgslabelfeature.h.

◆ whitespaceCollisionHandling()

Qgis::LabelWhitespaceCollisionHandling QgsLabelFeature::whitespaceCollisionHandling ( ) const
inline

Returns the whitespace collision handling.

See also
setWhitespaceCollisionHandling()
Since
QGIS 4.0

Definition at line 743 of file qgslabelfeature.h.

◆ zIndex()

double QgsLabelFeature::zIndex ( ) const
inline

Returns the label's z-index.

Higher z-index labels are rendered on top of lower z-index labels.

See also
setZIndex()

Definition at line 197 of file qgslabelfeature.h.

Member Data Documentation

◆ mAlwaysShow

bool QgsLabelFeature::mAlwaysShow = false
protected

whether to always show label - even in case of collisions

Definition at line 807 of file qgslabelfeature.h.

◆ mArrangementFlags

Qgis::LabelLinePlacementFlags QgsLabelFeature::mArrangementFlags = Qgis::LabelLinePlacementFlags()
protected

Definition at line 816 of file qgslabelfeature.h.

◆ mDistLabel

double QgsLabelFeature::mDistLabel = 0
protected

distance of label from the feature (only for "around point" placement or linestrings)

Definition at line 795 of file qgslabelfeature.h.

◆ mFixedAngle

double QgsLabelFeature::mFixedAngle = 0
protected

fixed rotation for the label (instead of automatic choice)

Definition at line 787 of file qgslabelfeature.h.

◆ mFixedPosition

QgsPointXY QgsLabelFeature::mFixedPosition
protected

fixed position for the label (instead of automatic placement)

Definition at line 783 of file qgslabelfeature.h.

◆ mGeometry

geos::unique_ptr QgsLabelFeature::mGeometry
protected

Geometry of the feature to be labelled.

Definition at line 763 of file qgslabelfeature.h.

◆ mHasFixedAngle

bool QgsLabelFeature::mHasFixedAngle = false
protected

whether mFixedAngle should be respected

Definition at line 785 of file qgslabelfeature.h.

◆ mHasFixedPosition

bool QgsLabelFeature::mHasFixedPosition = false
protected

whether mFixedPosition should be respected

Definition at line 781 of file qgslabelfeature.h.

◆ mHasFixedQuadrant

bool QgsLabelFeature::mHasFixedQuadrant = false
protected

whether mQuadOffset should be respected (only for "around point" placement)

Definition at line 789 of file qgslabelfeature.h.

◆ mId

QgsFeatureId QgsLabelFeature::mId
protected

Associated ID unique within the parent label provider.

Definition at line 759 of file qgslabelfeature.h.

◆ mLabelText

QString QgsLabelFeature::mLabelText
protected

text of the label

Definition at line 809 of file qgslabelfeature.h.

◆ mLayer

pal::Layer* QgsLabelFeature::mLayer = nullptr
protected

Pointer to PAL layer (assigned when registered to PAL).

Definition at line 756 of file qgslabelfeature.h.

◆ mMaximumDistance

double QgsLabelFeature::mMaximumDistance = 0
protected

Maximum distance of label from the feature.

Definition at line 798 of file qgslabelfeature.h.

◆ mOffsetType

Qgis::LabelOffsetType QgsLabelFeature::mOffsetType = Qgis::LabelOffsetType::FromPoint
protected

Offset type for certain placement modes.

Definition at line 801 of file qgslabelfeature.h.

◆ mOuterBounds

QRectF QgsLabelFeature::mOuterBounds
protected

Extreme outer bounds of the label feature, including any surrounding content like borders or background shapes.

Definition at line 771 of file qgslabelfeature.h.

◆ mOverrunDistance

double QgsLabelFeature::mOverrunDistance = 0
protected

Distance to allow label to overrun linear features.

Definition at line 812 of file qgslabelfeature.h.

◆ mOverrunSmoothDistance

double QgsLabelFeature::mOverrunSmoothDistance = 0
protected

Distance to smooth angle of line start and end when calculating overruns.

Definition at line 814 of file qgslabelfeature.h.

◆ mPermissibleZone

QgsGeometry QgsLabelFeature::mPermissibleZone
protected

Optional geometry to use for label's permissible zone.

Definition at line 765 of file qgslabelfeature.h.

◆ mPolygonPlacementFlags

Definition at line 817 of file qgslabelfeature.h.

◆ mPositionOffset

QgsPointXY QgsLabelFeature::mPositionOffset
protected

offset of label from the feature (only for "offset from point" placement)

Definition at line 793 of file qgslabelfeature.h.

◆ mPredefinedPositionOrder

QVector< Qgis::LabelPredefinedPointPosition > QgsLabelFeature::mPredefinedPositionOrder
protected

Ordered list of predefined positions for label (only for OrderedPositionsAroundPoint placement).

Definition at line 803 of file qgslabelfeature.h.

◆ mPriority

double QgsLabelFeature::mPriority = -1
protected

Priority of the label.

Definition at line 777 of file qgslabelfeature.h.

◆ mQuadOffset

QPointF QgsLabelFeature::mQuadOffset
protected

whether the side of the label is fixed (only for "around point" placement)

Definition at line 791 of file qgslabelfeature.h.

◆ mRepeatDistance

double QgsLabelFeature::mRepeatDistance = 0
protected

distance after which label should be repeated (only for linestrings)

Definition at line 805 of file qgslabelfeature.h.

◆ mRotatedSize

QSizeF QgsLabelFeature::mRotatedSize
protected

Width and height of the label when rotated between 45 to 135 and 235 to 315 degrees;.

Definition at line 769 of file qgslabelfeature.h.

◆ mSize

QSizeF QgsLabelFeature::mSize
protected

Width and height of the label.

Definition at line 767 of file qgslabelfeature.h.

◆ mSubPartId

int QgsLabelFeature::mSubPartId = 0
protected

Associated sub part ID, for features which register multiple different labels.

Definition at line 761 of file qgslabelfeature.h.

◆ mSymbolSize

QSizeF QgsLabelFeature::mSymbolSize
protected

Size of associated rendered symbol, if applicable.

Definition at line 775 of file qgslabelfeature.h.

◆ mVisualMargin

QgsMargins QgsLabelFeature::mVisualMargin
protected

Visual margin of label contents.

Definition at line 773 of file qgslabelfeature.h.

◆ mZIndex

double QgsLabelFeature::mZIndex = 0
protected

Z-index of label (higher z-index labels are rendered on top of lower z-index labels).

Definition at line 779 of file qgslabelfeature.h.


The documentation for this class was generated from the following files: