1 #ifndef QGSPALGEOMETRY_H
2 #define QGSPALGEOMETRY_H
23 , mFontMetrics( NULL )
25 mDefinedFont =
QFont();
44 return mClusters.
at( partId );
55 qreal letterSpacing = mDefinedFont.letterSpacing();
56 qreal wordSpacing = mDefinedFont.wordSpacing();
59 if ( maxinangle < 20.0 )
61 if ( 60.0 < maxinangle )
63 if ( maxoutangle > -20.0 )
65 if ( -95.0 > maxoutangle )
70 double labelHeight = mapScale * fm->
height() / fontScale;
80 mInfo =
new pal::LabelInfo( mClusters.count(), labelHeight, maxinangle, maxoutangle );
81 for (
int i = 0; i < mClusters.count(); i++ )
85 charWidth = fm->
width( mClusters[i] );
88 wordSpaceFix = qreal( 0.0 );
93 wordSpaceFix = ( nxt < mClusters.count() && mClusters[nxt] !=
QLatin1String(
" " ) ) ? wordSpacing : qreal( 0.0 );
97 if ( mClusters[i].length() == 1 &&
101 wordSpaceFix -= wordSpacing;
104 charWidth = fm->
width(
QString( mClusters[i] ) ) + wordSpaceFix;
107 double labelWidth = mapScale * charWidth / fontScale;
108 mInfo->char_info[i].width = labelWidth;
137 #endif //QGSPALGEOMETRY_H
QgsTextLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, const QSizeF &size)
Construct text label feature.
QStringList mClusters
List of graphemes (used for curved labels)
~QgsTextLabelFeature()
Clean up.
Class that adds extra information to QgsLabelFeature for text labels.
void setDefinedFont(const QFont &f)
Set font to be used for rendering.
qreal width(const QString &text) const
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Perform transforms between map coordinates and device coordinates.
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues
Stores attribute values for data defined properties.
void setDataDefinedValues(const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &values)
Set data-defined values.
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Get data-defined values.
Optional additional info about label (for curved labels)
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.
double mapUnitsPerPixel() const
Return current map units per pixel.
QFontMetricsF * mFontMetrics
Metrics of the font for rendering.
QFont definedFont()
Font to be used for rendering.
QString text(int partId) const
Returns the text component corresponding to a specified label part.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
const QChar at(int position) const
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...
QFont mDefinedFont
Font for rendering.
QFontMetricsF * labelFontMetrics()
Metrics of the font for rendering.