QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgstextlabelfeature.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstextlabelfeature.h
3  ---------------------
4  begin : December 2015
5  copyright : (C) 2015 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSTEXTLABELFEATURE_H
16 #define QGSTEXTLABELFEATURE_H
17 
18 #define SIP_NO_FILE
19 
20 #include "qgslabelfeature.h"
21 #include "qgstextdocument.h"
22 
24 
32 {
33  public:
36 
38  ~QgsTextLabelFeature() override;
39 
46  QString text( int partId ) const;
47 
56  QgsTextCharacterFormat characterFormat( int partId ) const;
57 
63  bool hasCharacterFormat( int partId ) const;
64 
66  void calculateInfo( bool curvedLabeling, QFontMetricsF *fm, const QgsMapToPixel *xform, double maxinangle, double maxoutangle, QgsTextDocument *document = nullptr );
67 
69  const QMap< QgsPalLayerSettings::Property, QVariant > &dataDefinedValues() const { return mDataDefinedValues; }
71  void setDataDefinedValues( const QMap< QgsPalLayerSettings::Property, QVariant > &values ) { mDataDefinedValues = values; }
72 
74  void setDefinedFont( const QFont &f ) { mDefinedFont = f; }
76  QFont definedFont() { return mDefinedFont; }
77 
79  QFontMetricsF *labelFontMetrics() { return mFontMetrics; }
80 
86  QgsTextDocument document() const;
87 
93  void setDocument( const QgsTextDocument &document );
94 
95  protected:
97  QStringList mClusters;
98 
99  QList< QgsTextCharacterFormat > mCharacterFormats;
100 
102  QFont mDefinedFont;
104  QFontMetricsF *mFontMetrics = nullptr;
106  QMap< QgsPalLayerSettings::Property, QVariant > mDataDefinedValues;
107 
109 
110 };
111 
112 #endif //QGSTEXTLABELFEATURE_H
qgstextdocument.h
QgsTextLabelFeature::setDocument
void setDocument(const QgsTextDocument &document)
Sets the document for the label.
Definition: qgstextlabelfeature.cpp:144
QgsTextLabelFeature::text
QString text(int partId) const
Returns the text component corresponding to a specified label part.
Definition: qgspalgeometry.h:66
QgsTextLabelFeature::dataDefinedValues
const QMap< QgsPalLayerSettings::Property, QVariant > & dataDefinedValues() const
Gets data-defined values.
Definition: qgstextlabelfeature.h:69
QgsTextLabelFeature::hasCharacterFormat
bool hasCharacterFormat(int partId) const
Returns true if the feature contains specific character formatting for the part with matching ID.
Definition: qgstextlabelfeature.cpp:52
QgsTextLabelFeature::labelFontMetrics
QFontMetricsF * labelFontMetrics()
Metrics of the font for rendering.
Definition: qgstextlabelfeature.h:79
QgsTextLabelFeature::~QgsTextLabelFeature
~QgsTextLabelFeature()
Clean up.
Definition: qgspalgeometry.h:55
QgsTextLabelFeature::mFontMetrics
QFontMetricsF * mFontMetrics
Metrics of the font for rendering.
Definition: qgspalgeometry.h:158
QgsTextLabelFeature::characterFormat
QgsTextCharacterFormat characterFormat(int partId) const
Returns the character format corresponding to the specified label part.
Definition: qgstextlabelfeature.cpp:47
QgsTextLabelFeature::mDefinedFont
QFont mDefinedFont
Font for rendering.
Definition: qgspalgeometry.h:156
QgsTextCharacterFormat
Definition: qgstextcharacterformat.h:39
QgsTextLabelFeature::mDataDefinedValues
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues
Stores attribute values for data defined properties.
Definition: qgspalgeometry.h:160
qgslabelfeature.h
QgsTextLabelFeature
Class that adds extra information to QgsLabelFeature for text labels.
Definition: qgspalgeometry.h:30
QgsTextLabelFeature::mClusters
QStringList mClusters
List of graphemes (used for curved labels)
Definition: qgspalgeometry.h:154
geos::unique_ptr
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
QgsTextLabelFeature::mCharacterFormats
QList< QgsTextCharacterFormat > mCharacterFormats
Definition: qgstextlabelfeature.h:99
QgsTextLabelFeature::mDocument
QgsTextDocument mDocument
Definition: qgstextlabelfeature.h:108
QgsTextLabelFeature::setDefinedFont
void setDefinedFont(const QFont &f)
Sets font to be used for rendering.
Definition: qgstextlabelfeature.h:74
QgsTextLabelFeature::calculateInfo
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.
Definition: qgspalgeometry.h:75
QgsTextLabelFeature::definedFont
QFont definedFont()
Font to be used for rendering.
Definition: qgstextlabelfeature.h:76
QgsLabelFeature::size
QSizeF size(double angle=0.0) const
Size of the label (in map units)
Definition: qgslabelfeature.cpp:64
QgsLabelFeature::geometry
GEOSGeometry * geometry() const
Gets access to the associated geometry.
Definition: qgslabelfeature.h:69
QgsMapToPixel
Definition: qgsmaptopixel.h:37
QgsTextDocument
Definition: qgstextdocument.h:37
QgsTextLabelFeature::document
QgsTextDocument document() const
Returns the document for the label.
Definition: qgstextlabelfeature.cpp:139
QgsTextLabelFeature::setDataDefinedValues
void setDataDefinedValues(const QMap< QgsPalLayerSettings::Property, QVariant > &values)
Sets data-defined values.
Definition: qgstextlabelfeature.h:71
QgsLabelFeature
The QgsLabelFeature class describes a feature that should be used within the labeling engine....
Definition: qgslabelfeature.h:56
QgsTextLabelFeature::mDataDefinedValues
QMap< QgsPalLayerSettings::Property, QVariant > mDataDefinedValues
Stores attribute values for data defined properties.
Definition: qgstextlabelfeature.h:106
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QgsTextLabelFeature::QgsTextLabelFeature
QgsTextLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, const QSizeF &size)
Construct text label feature.
Definition: qgspalgeometry.h:47