QgsTextLabelFeature class

Class that adds extra information to QgsLabelFeature for text labels.

Base classes

class QgsLabelFeature
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
class QgsLabelFeature
The QgsLabelFeature class describes a feature that should be used within the labeling engine.

Constructors, destructors, conversion operators

QgsTextLabelFeature(QgsFeatureId id, geos::unique_ptr geometry, QSizeF size)
Construct text label feature.
QgsTextLabelFeature(QgsFeatureId id, GEOSGeometry* geometry, const QSizeF& size)
Construct text label feature.
~QgsTextLabelFeature() override
Clean up.
~QgsTextLabelFeature()
Clean up.

Public functions

void calculateInfo(bool curvedLabeling, QFontMetricsF* fm, const QgsMapToPixel* xform, double maxinangle, double maxoutangle)
calculate data for info(). setDefinedFont() must have been called already.
void calculateInfo(bool curvedLabeling, QFontMetricsF* fm, const QgsMapToPixel* xform, double fontScale, double maxinangle, double maxoutangle)
calculate data for info(). setDefinedFont() must have been called already.
auto dataDefinedValues() const -> const QMap<QgsPalLayerSettings::Property, QVariant>&
Gets data-defined values.
auto dataDefinedValues() const -> const QMap<QgsPalLayerSettings::DataDefinedProperties, QVariant>&
Gets data-defined values.
auto definedFont() -> QFont
Font to be used for rendering.
auto definedFont() -> QFont
Font to be used for rendering.
auto labelFontMetrics() -> QFontMetricsF*
Metrics of the font for rendering.
auto labelFontMetrics() -> QFontMetricsF*
Metrics of the font for rendering.
void setDataDefinedValues(const QMap<QgsPalLayerSettings::Property, QVariant>& values)
Sets data-defined values.
void setDataDefinedValues(const QMap<QgsPalLayerSettings::DataDefinedProperties, QVariant>& values)
Sets data-defined values.
void setDefinedFont(const QFont& f)
Sets font to be used for rendering.
void setDefinedFont(const QFont& f)
Sets font to be used for rendering.
auto text(int partId) const -> QString
Returns the text component corresponding to a specified label part.
auto text(int partId) const -> QString
Returns the text component corresponding to a specified label part.

Protected variables

QStringList mClusters
List of graphemes (used for curved labels)
QMap<QgsPalLayerSettings::Property, QVariant> mDataDefinedValues
Stores attribute values for data defined properties.
QMap<QgsPalLayerSettings::DataDefinedProperties, QVariant> mDataDefinedValues
Stores attribute values for data defined properties.
QFont mDefinedFont
Font for rendering.
QFontMetricsF* mFontMetrics
Metrics of the font for rendering.

Function documentation

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

Construct text label feature.

QgsTextLabelFeature::~QgsTextLabelFeature() override

Clean up.

void QgsTextLabelFeature::calculateInfo(bool curvedLabeling, QFontMetricsF* fm, const QgsMapToPixel* xform, double maxinangle, double maxoutangle)

calculate data for info(). setDefinedFont() must have been called already.

const QMap<QgsPalLayerSettings::Property, QVariant>& QgsTextLabelFeature::dataDefinedValues() const

Gets data-defined values.

QFont QgsTextLabelFeature::definedFont()

Font to be used for rendering.

QFontMetricsF* QgsTextLabelFeature::labelFontMetrics()

Metrics of the font for rendering.

void QgsTextLabelFeature::setDataDefinedValues(const QMap<QgsPalLayerSettings::Property, QVariant>& values)

Sets data-defined values.

void QgsTextLabelFeature::setDefinedFont(const QFont& f)

Sets font to be used for rendering.

QString QgsTextLabelFeature::text(int partId) const

Returns the text component corresponding to a specified label part.

Parameters
partId Set to -1 for labels which are not broken into parts (e.g., non-curved labels), or the required part index for labels which are broken into parts (curved labels)

QString QgsTextLabelFeature::text(int partId) const

Returns the text component corresponding to a specified label part.

Parameters
partId Set to -1 for labels which are not broken into parts (e.g., non-curved labels), or the required part index for labels which are broken into parts (curved labels)

Variable documentation

QMap<QgsPalLayerSettings::Property, QVariant> QgsTextLabelFeature::mDataDefinedValues protected

Stores attribute values for data defined properties.