1 #ifndef QGSPALGEOMETRY_H
2 #define QGSPALGEOMETRY_H
15 qreal ltrSpacing = 0.0, qreal wordSpacing = 0.0,
bool curvedLabeling =
false )
22 , mFontMetrics( NULL )
23 , mLetterSpacing( ltrSpacing )
24 , mWordSpacing( wordSpacing )
25 , mCurvedLabeling( curvedLabeling )
28 mDefinedFont =
QFont();
50 const char*
strId() {
return mStrId.data(); }
63 return mClusters.
at( partId );
74 if ( maxinangle < 20.0 )
76 if ( 60.0 < maxinangle )
78 if ( maxoutangle > -20.0 )
80 if ( -95.0 > maxoutangle )
85 double labelHeight = mapScale * fm->
height() / fontScale;
95 mInfo =
new pal::LabelInfo( mClusters.count(), labelHeight, maxinangle, maxoutangle );
96 for (
int i = 0; i < mClusters.count(); i++ )
103 charWidth = fm->
width( mClusters[i] );
104 if ( mCurvedLabeling )
106 wordSpaceFix = qreal( 0.0 );
107 if ( mClusters[i] ==
QString(
" " ) )
111 wordSpaceFix = ( nxt < mClusters.count() && mClusters[nxt] !=
QString(
" " ) ) ? mWordSpacing : qreal( 0.0 );
115 if ( mClusters[i].length() == 1 &&
119 wordSpaceFix -= mWordSpacing;
122 charWidth = fm->
width(
QString( mClusters[i] ) ) + wordSpaceFix;
125 double labelWidth = mapScale * charWidth / fontScale;
126 mInfo->char_info[i].width = labelWidth;
181 #endif //QGSPALGEOMETRY_H
const GEOSGeometry * getGeosGeometry() override
get the GEOSGeometry of the feature This method is called by Pal each time it needs a geom's coordina...
void addDataDefinedValue(QgsPalLayerSettings::DataDefinedProperties p, QVariant v)
void setDxfLayer(QString dxfLayer)
const QgsAttributes & diagramAttributes()
#define FID_TO_STRING(fid)
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
QString text(int partId) const
Returns the text component corresponding to a specified label part.
void setIsDiagram(bool d)
QFontMetricsF * getLabelFontMetrics()
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
qreal width(const QString &text) const
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > mDataDefinedValues
Stores attribute values for data defined properties.
Perform transforms between map coordinates and device coordinates.
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
void setFeatureId(QgsFeatureId id)
Sets the feature ID for this feature.
optional additional info about label (for curved labels)
double mapUnitsPerPixel() const
Return current map units per pixel.
QgsPalGeometry(QgsFeatureId id, QString text, GEOSGeometry *g, qreal ltrSpacing=0.0, qreal wordSpacing=0.0, bool curvedLabeling=false)
void setDiagramAttributes(const QgsAttributes &attrs)
void releaseGeosGeometry(const GEOSGeometry *) override
Called by Pal when it doesn't need the coordinates anymore.
void setValid(bool validity)
Sets the validity of the feature.
void setDefinedFont(QFont f)
static GEOSContextHandle_t getGEOSHandler()
return GEOS context handle
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 ...
QgsAttributes mDiagramAttributes
Stores attribute values for diagram rendering.
Interface that allows Pal to access user's geometries.
void feature(QgsFeature &feature)
QFontMetricsF * mFontMetrics
pal::LabelInfo * info(QFontMetricsF *fm, const QgsMapToPixel *xform, double fontScale, double maxinangle, double maxoutangle)