QGIS API Documentation  3.14.0-Pi (9f7028fd23)
Public Member Functions | Protected Attributes | List of all members
QgsLabelFeature Class Reference

The QgsLabelFeature class 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). More...

#include <qgslabelfeature.h>

Inheritance diagram for QgsLabelFeature:
Inheritance graph
[legend]

Public Member Functions

 QgsLabelFeature (QgsFeatureId id, geos::unique_ptr geometry, QSizeF size)
 Create label feature, takes ownership of the geometry instance. More...
 
virtual ~QgsLabelFeature ()
 Clean up geometry and curved label info (if present) More...
 
bool alwaysShow () const
 Whether label should be always shown (sets very high label priority) More...
 
QgsPointXY anchorPosition () const
 In case of quadrand or aligned positioning, this is set to the anchor point. More...
 
QgsLabeling::LinePlacementFlags arrangementFlags () const
 Returns the feature's arrangement flags. More...
 
pal::LabelInfocurvedLabelInfo () const
 Gets additional info required for curved label placement. Returns nullptr if not set. More...
 
double distLabel () const
 Applies to "around point" placement strategy or linestring features. More...
 
QgsFeature feature () const
 Returns the original feature associated with this label. More...
 
double fixedAngle () const
 Angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true) More...
 
QgsPointXY fixedPosition () const
 Coordinates of the fixed position (relevant only if hasFixedPosition() returns true) More...
 
GEOSGeometry * geometry () const
 Gets access to the associated geometry. More...
 
bool hasFixedAngle () const
 Whether the label should use a fixed angle instead of using angle from automatic placement. More...
 
bool hasFixedPosition () const
 Whether the label should use a fixed position instead of being automatically placed. More...
 
bool hasFixedQuadrant () const
 Returns whether the quadrant for the label is fixed. More...
 
QgsFeatureId id () const
 Identifier of the label (unique within the parent label provider) More...
 
bool labelAllParts () const
 Returns true if all parts of the feature should be labeled. More...
 
QString labelText () const
 Text of the label. More...
 
pal::Layerlayer () const
 Gets PAL layer of the label feature. Should be only used internally in PAL. More...
 
const QgsLabelObstacleSettingsobstacleSettings () const
 Returns the label's obstacle settings. More...
 
QgsPalLayerSettings::OffsetType offsetType () const
 Returns the offset type, which determines how offsets and distance to label behaves. More...
 
double overrunDistance () const
 Returns the permissible distance (in map units) which labels are allowed to overrun the start or end of linear features. More...
 
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. More...
 
QgsGeometry permissibleZone () const
 Returns the label's permissible zone geometry. More...
 
const GEOSPreparedGeometry * permissibleZonePrepared () const
 Returns a GEOS prepared geometry representing the label's permissibleZone(). More...
 
QgsLabeling::PolygonPlacementFlags polygonPlacementFlags () const
 Returns the polygon placement flags, which dictate how polygon labels can be placed. More...
 
QgsPointXY positionOffset () const
 Applies only to "offset from point" placement strategy. More...
 
QVector< QgsPalLayerSettings::PredefinedPointPositionpredefinedPositionOrder () const
 Returns the priority ordered list of predefined positions for label candidates. More...
 
double priority () const
 Returns the feature's labeling priority. More...
 
QgsAbstractLabelProviderprovider () const
 Returns provider of this instance. More...
 
QPointF quadOffset () const
 Applies to "offset from point" placement strategy and "around point" (in case hasFixedQuadrant() returns true). More...
 
double repeatDistance () const
 Applies only to linestring features - after what distance (in map units) the labels should be repeated (0 = no repetitions) More...
 
void setAlwaysShow (bool enabled)
 Sets whether label should be always shown (sets very high label priority) More...
 
void setAnchorPosition (const QgsPointXY &anchorPosition)
 In case of quadrand or aligned positioning, this is set to the anchor point. More...
 
void setArrangementFlags (QgsLabeling::LinePlacementFlags flags)
 Sets the feature's arrangement flags. More...
 
void setCurvedLabelInfo (pal::LabelInfo *info)
 takes ownership of the instance More...
 
void setDistLabel (double dist)
 Applies to "around point" placement strategy or linestring features. More...
 
void setFeature (const QgsFeature &feature)
 Sets the original feature associated with this label. More...
 
void setFixedAngle (double angle)
 Sets angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true) More...
 
void setFixedPosition (const QgsPointXY &point)
 Sets coordinates of the fixed position (relevant only if hasFixedPosition() returns true) More...
 
void setHasFixedAngle (bool enabled)
 Sets whether the label should use a fixed angle instead of using angle from automatic placement. More...
 
void setHasFixedPosition (bool enabled)
 Sets whether the label should use a fixed position instead of being automatically placed. More...
 
void setHasFixedQuadrant (bool enabled)
 Sets whether the quadrant for the label must be respected. More...
 
void setLabelAllParts (bool labelAllParts)
 Sets whether all parts of the feature should be labeled. More...
 
void setLabelText (const QString &text)
 Sets text of the label. More...
 
void setLayer (pal::Layer *layer)
 Assign PAL layer to the label feature. Should be only used internally in PAL. More...
 
void setObstacleSettings (const QgsLabelObstacleSettings &settings)
 Sets the label's obstacle settings. More...
 
void setOffsetType (QgsPalLayerSettings::OffsetType type)
 Sets the offset type, which determines how offsets and distance to label behaves. More...
 
void setOverrunDistance (double distance)
 Sets the permissible distance (in map units) which labels are allowed to overrun the start or end of linear features. More...
 
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. More...
 
void setPermissibleZone (const QgsGeometry &geometry)
 Sets the label's permissible zone geometry. More...
 
void setPolygonPlacementFlags (QgsLabeling::PolygonPlacementFlags flags)
 Sets the polygon placement flags, which dictate how polygon labels can be placed. More...
 
void setPositionOffset (const QgsPointXY &offset)
 Applies only to "offset from point" placement strategy. More...
 
void setPredefinedPositionOrder (const QVector< QgsPalLayerSettings::PredefinedPointPosition > &order)
 Sets the priority ordered list of predefined positions for label candidates. More...
 
void setPriority (double priority)
 Sets the priority for labeling the feature. More...
 
void setQuadOffset (QPointF quadOffset)
 Set which side of the point to use. More...
 
void setRepeatDistance (double dist)
 Applies only to linestring features - set after what distance (in map units) the labels should be repeated (0 = no repetitions) More...
 
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. More...
 
void setSymbol (const QgsSymbol *symbol)
 Sets the feature symbol associated with this label. More...
 
void setSymbolSize (QSizeF size)
 Sets the size of the rendered symbol associated with this feature. More...
 
void setVisualMargin (const QgsMargins &margin)
 Sets the visual margin for the label feature. More...
 
void setZIndex (double zIndex)
 Sets the label's z-index. More...
 
QSizeF size (double angle=0.0) const
 Size of the label (in map units) More...
 
const QgsSymbolsymbol ()
 Returns the feature symbol associated with this label. More...
 
const QSizeF & symbolSize () const
 Returns the size of the rendered symbol associated with this feature, if applicable. More...
 
const QgsMarginsvisualMargin () const
 Returns the visual margin for the label feature. More...
 
double zIndex () const
 Returns the label's z-index. More...
 

Protected Attributes

bool mAlwaysShow = false
 whether to always show label - even in case of collisions More...
 
QgsLabeling::LinePlacementFlags mArrangementFlags = nullptr
 
double mDistLabel = 0
 distance of label from the feature (only for "around point" placement or linestrings) More...
 
double mFixedAngle = 0
 fixed rotation for the label (instead of automatic choice) More...
 
QgsPointXY mFixedPosition
 fixed position for the label (instead of automatic placement) More...
 
geos::unique_ptr mGeometry
 Geometry of the feature to be labelled. More...
 
bool mHasFixedAngle = false
 whether mFixedAngle should be respected More...
 
bool mHasFixedPosition = false
 whether mFixedPosition should be respected More...
 
bool mHasFixedQuadrant = false
 whether mQuadOffset should be respected (only for "around point" placement) More...
 
QgsFeatureId mId
 Associated ID unique within the parent label provider. More...
 
pal::LabelInfomInfo = nullptr
 extra information for curved labels (may be nullptr) More...
 
QString mLabelText
 text of the label More...
 
pal::LayermLayer = nullptr
 Pointer to PAL layer (assigned when registered to PAL) More...
 
QgsPalLayerSettings::OffsetType mOffsetType = QgsPalLayerSettings::FromPoint
 Offset type for certain placement modes. More...
 
double mOverrunDistance = 0
 Distance to allow label to overrun linear features. More...
 
double mOverrunSmoothDistance = 0
 Distance to smooth angle of line start and end when calculating overruns. More...
 
QgsGeometry mPermissibleZone
 Optional geometry to use for label's permissible zone. More...
 
QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon
 
QgsPointXY mPositionOffset
 offset of label from the feature (only for "offset from point" placement) More...
 
QVector< QgsPalLayerSettings::PredefinedPointPositionmPredefinedPositionOrder
 Ordered list of predefined positions for label (only for OrderedPositionsAroundPoint placement) More...
 
double mPriority = -1
 Priority of the label. More...
 
QPointF mQuadOffset
 whether the side of the label is fixed (only for "around point" placement) More...
 
double mRepeatDistance = 0
 distance after which label should be repeated (only for linestrings) More...
 
QSizeF mRotatedSize
 Width and height of the label when rotated between 45 to 135 and 235 to 315 degrees;. More...
 
QSizeF mSize
 Width and height of the label. More...
 
QSizeF mSymbolSize
 Size of associated rendered symbol, if applicable. More...
 
QgsMargins mVisualMargin
 Visual margin of label contents. More...
 
double mZIndex = 0
 Z-index of label (higher z-index labels are rendered on top of lower z-index labels) More...
 

Detailed Description

The QgsLabelFeature class 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
Since
QGIS 2.12

Definition at line 56 of file qgslabelfeature.h.

Constructor & Destructor Documentation

◆ QgsLabelFeature()

QgsLabelFeature::QgsLabelFeature ( QgsFeatureId  id,
geos::unique_ptr  geometry,
QSizeF  size 
)

Create label feature, takes ownership of the geometry instance.

Definition at line 20 of file qgslabelfeature.cpp.

◆ ~QgsLabelFeature()

QgsLabelFeature::~QgsLabelFeature ( )
virtual

Clean up geometry and curved label info (if present)

Definition at line 27 of file qgslabelfeature.cpp.

Member Function Documentation

◆ alwaysShow()

bool QgsLabelFeature::alwaysShow ( ) const
inline

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

Definition at line 304 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()

QgsLabeling::LinePlacementFlags QgsLabelFeature::arrangementFlags ( ) const
inline

Returns the feature's arrangement flags.

See also
setArrangementFlags

Definition at line 312 of file qgslabelfeature.h.

◆ curvedLabelInfo()

pal::LabelInfo* QgsLabelFeature::curvedLabelInfo ( ) const
inline

Gets additional info required for curved label placement. Returns nullptr if not set.

Definition at line 348 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)

Definition at line 269 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 degrees of the fixed angle (relevant only if hasFixedAngle() returns true)

Definition at line 203 of file qgslabelfeature.h.

◆ fixedPosition()

QgsPointXY QgsLabelFeature::fixedPosition ( ) const
inline

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

Definition at line 177 of file qgslabelfeature.h.

◆ geometry()

GEOSGeometry* QgsLabelFeature::geometry ( ) const
inline

Gets access to the associated geometry.

Definition at line 69 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 199 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 173 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 213 of file qgslabelfeature.h.

◆ id()

QgsFeatureId QgsLabelFeature::id ( ) const
inline

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

Definition at line 66 of file qgslabelfeature.h.

◆ labelAllParts()

bool QgsLabelFeature::labelAllParts ( ) const
inline

Returns true if all parts of the feature should be labeled.

See also
setLabelAllParts()
Since
QGIS 3.10

Definition at line 438 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 343 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 353 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 103 of file qgslabelfeature.cpp.

◆ offsetType()

QgsPalLayerSettings::OffsetType 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 255 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()
Since
QGIS 3.0

Definition at line 90 of file qgslabelfeature.h.

◆ permissibleZonePrepared()

const GEOSPreparedGeometry* QgsLabelFeature::permissibleZonePrepared ( ) const
inline

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

See also
permissibleZone()
Since
QGIS 3.0

Definition at line 98 of file qgslabelfeature.h.

◆ polygonPlacementFlags()

QgsLabeling::PolygonPlacementFlags 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 327 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 241 of file qgslabelfeature.h.

◆ predefinedPositionOrder()

QVector< QgsPalLayerSettings::PredefinedPointPosition > 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 282 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 144 of file qgslabelfeature.h.

◆ provider()

QgsAbstractLabelProvider * QgsLabelFeature::provider ( ) const

Returns provider of this instance.

Definition at line 607 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 229 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 295 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 306 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 113 of file qgslabelfeature.cpp.

◆ setArrangementFlags()

void QgsLabelFeature::setArrangementFlags ( QgsLabeling::LinePlacementFlags  flags)
inline

Sets the feature's arrangement flags.

Parameters
flagsarrangement flags
See also
arrangementFlags

Definition at line 319 of file qgslabelfeature.h.

◆ setCurvedLabelInfo()

void QgsLabelFeature::setCurvedLabelInfo ( pal::LabelInfo info)
inline

takes ownership of the instance

Definition at line 350 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)

Definition at line 275 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 angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true)

Definition at line 205 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 180 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 201 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 175 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 221 of file qgslabelfeature.h.

◆ setLabelAllParts()

void QgsLabelFeature::setLabelAllParts ( bool  labelAllParts)
inline

Sets whether all parts of the feature should be labeled.

See also
labelAllParts()
Since
QGIS 3.10

Definition at line 445 of file qgslabelfeature.h.

◆ setLabelText()

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

Sets text of the label.

Definition at line 345 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 355 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 108 of file qgslabelfeature.cpp.

◆ setOffsetType()

void QgsLabelFeature::setOffsetType ( QgsPalLayerSettings::OffsetType  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 263 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()
Since
QGIS 3.0

Definition at line 38 of file qgslabelfeature.cpp.

◆ setPolygonPlacementFlags()

void QgsLabelFeature::setPolygonPlacementFlags ( QgsLabeling::PolygonPlacementFlags  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 335 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 247 of file qgslabelfeature.h.

◆ setPredefinedPositionOrder()

void QgsLabelFeature::setPredefinedPositionOrder ( const QVector< QgsPalLayerSettings::PredefinedPointPosition > &  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 289 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 153 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 235 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 301 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 452 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 391 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 127 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 113 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()
Since
QGIS 2.14

Definition at line 170 of file qgslabelfeature.h.

◆ size()

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

Size of the label (in map units)

Definition at line 64 of file qgslabelfeature.cpp.

◆ symbol()

const QgsSymbol* QgsLabelFeature::symbol ( )
inline

Returns the feature symbol associated with this label.

See also
setSymbol()
Since
QGIS 3.10

Definition at line 382 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 136 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 119 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()
Since
QGIS 2.14

Definition at line 161 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 515 of file qgslabelfeature.h.

◆ mArrangementFlags

QgsLabeling::LinePlacementFlags QgsLabelFeature::mArrangementFlags = nullptr
protected

Definition at line 526 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 507 of file qgslabelfeature.h.

◆ mFixedAngle

double QgsLabelFeature::mFixedAngle = 0
protected

fixed rotation for the label (instead of automatic choice)

Definition at line 499 of file qgslabelfeature.h.

◆ mFixedPosition

QgsPointXY QgsLabelFeature::mFixedPosition
protected

fixed position for the label (instead of automatic placement)

Definition at line 495 of file qgslabelfeature.h.

◆ mGeometry

geos::unique_ptr QgsLabelFeature::mGeometry
protected

Geometry of the feature to be labelled.

Definition at line 477 of file qgslabelfeature.h.

◆ mHasFixedAngle

bool QgsLabelFeature::mHasFixedAngle = false
protected

whether mFixedAngle should be respected

Definition at line 497 of file qgslabelfeature.h.

◆ mHasFixedPosition

bool QgsLabelFeature::mHasFixedPosition = false
protected

whether mFixedPosition should be respected

Definition at line 493 of file qgslabelfeature.h.

◆ mHasFixedQuadrant

bool QgsLabelFeature::mHasFixedQuadrant = false
protected

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

Definition at line 501 of file qgslabelfeature.h.

◆ mId

QgsFeatureId QgsLabelFeature::mId
protected

Associated ID unique within the parent label provider.

Definition at line 475 of file qgslabelfeature.h.

◆ mInfo

pal::LabelInfo* QgsLabelFeature::mInfo = nullptr
protected

extra information for curved labels (may be nullptr)

Definition at line 519 of file qgslabelfeature.h.

◆ mLabelText

QString QgsLabelFeature::mLabelText
protected

text of the label

Definition at line 517 of file qgslabelfeature.h.

◆ mLayer

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

Pointer to PAL layer (assigned when registered to PAL)

Definition at line 472 of file qgslabelfeature.h.

◆ mOffsetType

QgsPalLayerSettings::OffsetType QgsLabelFeature::mOffsetType = QgsPalLayerSettings::FromPoint
protected

Offset type for certain placement modes.

Definition at line 509 of file qgslabelfeature.h.

◆ mOverrunDistance

double QgsLabelFeature::mOverrunDistance = 0
protected

Distance to allow label to overrun linear features.

Definition at line 522 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 524 of file qgslabelfeature.h.

◆ mPermissibleZone

QgsGeometry QgsLabelFeature::mPermissibleZone
protected

Optional geometry to use for label's permissible zone.

Definition at line 479 of file qgslabelfeature.h.

◆ mPolygonPlacementFlags

QgsLabeling::PolygonPlacementFlags QgsLabelFeature::mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon
protected

Definition at line 527 of file qgslabelfeature.h.

◆ mPositionOffset

QgsPointXY QgsLabelFeature::mPositionOffset
protected

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

Definition at line 505 of file qgslabelfeature.h.

◆ mPredefinedPositionOrder

QVector< QgsPalLayerSettings::PredefinedPointPosition > QgsLabelFeature::mPredefinedPositionOrder
protected

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

Definition at line 511 of file qgslabelfeature.h.

◆ mPriority

double QgsLabelFeature::mPriority = -1
protected

Priority of the label.

Definition at line 489 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 503 of file qgslabelfeature.h.

◆ mRepeatDistance

double QgsLabelFeature::mRepeatDistance = 0
protected

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

Definition at line 513 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 483 of file qgslabelfeature.h.

◆ mSize

QSizeF QgsLabelFeature::mSize
protected

Width and height of the label.

Definition at line 481 of file qgslabelfeature.h.

◆ mSymbolSize

QSizeF QgsLabelFeature::mSymbolSize
protected

Size of associated rendered symbol, if applicable.

Definition at line 487 of file qgslabelfeature.h.

◆ mVisualMargin

QgsMargins QgsLabelFeature::mVisualMargin
protected

Visual margin of label contents.

Definition at line 485 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 491 of file qgslabelfeature.h.


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