QGIS API Documentation
3.0.2-Girona (307d082)
|
The QgsLabelFeature class describes a feature that should be used within the labeling engine. More...
#include <qgslabelfeature.h>
Public Member Functions | |
QgsLabelFeature (QgsFeatureId id, GEOSGeometry *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... | |
pal::LabelInfo * | curvedLabelInfo () const |
Get additional infor required for curved label placement. Returns null if not set. More... | |
double | distLabel () const |
Applies to "around point" placement strategy or linestring features. 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 |
Get 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 | isObstacle () const |
Returns whether the feature will act as an obstacle for labels. More... | |
QString | labelText () const |
Text of the label. More... | |
pal::Layer * | layer () const |
Get PAL layer of the label feature. Should be only used internally in PAL. More... | |
double | obstacleFactor () const |
Returns the obstacle factor for the feature. More... | |
GEOSGeometry * | obstacleGeometry () const |
Returns the label's obstacle geometry, if different to the feature geometry. More... | |
QgsPalLayerSettings::OffsetType | offsetType () const |
Returns the offset type, which determines how offsets and distance to label behaves. 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... | |
QgsPointXY | positionOffset () const |
Applies only to "offset from point" placement strategy. More... | |
QVector< QgsPalLayerSettings::PredefinedPointPosition > | predefinedPositionOrder () const |
Returns the priority ordered list of predefined positions for label candidates. More... | |
double | priority () const |
Returns the feature's labeling priority. More... | |
QgsAbstractLabelProvider * | provider () const |
Return 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) |
Set whether label should be always shown (sets very high label priority) 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 | setFixedAngle (double angle) |
Set angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true) More... | |
void | setFixedPosition (const QgsPointXY &point) |
Set coordinates of the fixed position (relevant only if hasFixedPosition() returns true) More... | |
void | setHasFixedAngle (bool enabled) |
Set whether the label should use a fixed angle instead of using angle from automatic placement. More... | |
void | setHasFixedPosition (bool enabled) |
Set 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 | setIsObstacle (bool enabled) |
Sets whether the feature will act as an obstacle for labels. More... | |
void | setLabelText (const QString &text) |
Set 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 | setObstacleFactor (double factor) |
Sets the obstacle factor for the feature. More... | |
void | setObstacleGeometry (GEOSGeometry *obstacleGeom) |
Sets the label's obstacle geometry, if different to the feature geometry. More... | |
void | setOffsetType (QgsPalLayerSettings::OffsetType type) |
Sets the offset type, which determines how offsets and distance to label behaves. More... | |
void | setPermissibleZone (const QgsGeometry &geometry) |
Sets the label's permissible zone geometry. 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 | 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 () const |
Size of the label (in map units) More... | |
const QSizeF & | symbolSize () const |
Returns the size of the rendered symbol associated with this feature, if applicable. More... | |
const QgsMargins & | visualMargin () const |
Returns the visual margin for the label feature. More... | |
double | zIndex () const |
Returns the label's z-index. More... | |
Protected Attributes | |
bool | mAlwaysShow |
whether to always show label - even in case of collisions More... | |
double | mDistLabel |
distance of label from the feature (only for "around point" placement or linestrings) More... | |
double | mFixedAngle |
fixed rotation for the label (instead of automatic choice) More... | |
QgsPointXY | mFixedPosition |
fixed position for the label (instead of automatic placement) More... | |
GEOSGeometry * | mGeometry = nullptr |
Geometry of the feature to be labelled. More... | |
bool | mHasFixedAngle |
whether mFixedAngle should be respected More... | |
bool | mHasFixedPosition |
whether mFixedPosition should be respected More... | |
bool | mHasFixedQuadrant |
whether mQuadOffset should be respected (only for "around point" placement) More... | |
QgsFeatureId | mId |
Associated ID unique within the parent label provider. More... | |
pal::LabelInfo * | mInfo = nullptr |
extra information for curved labels (may be null) More... | |
bool | mIsObstacle |
whether the feature geometry acts as an obstacle for labels More... | |
QString | mLabelText |
text of the label More... | |
pal::Layer * | mLayer = nullptr |
Pointer to PAL layer (assigned when registered to PAL) More... | |
double | mObstacleFactor |
how strong is the geometry acting as obstacle More... | |
GEOSGeometry * | mObstacleGeometry = nullptr |
Optional geometry to use for label obstacles, if different to mGeometry. More... | |
QgsPalLayerSettings::OffsetType | mOffsetType |
Offset type for certain placement modes. More... | |
QgsGeometry | mPermissibleZone |
Optional geometry to use for label's permissible zone. More... | |
QgsPointXY | mPositionOffset |
offset of label from the feature (only for "offset from point" placement) More... | |
QVector< QgsPalLayerSettings::PredefinedPointPosition > | mPredefinedPositionOrder |
Ordered list of predefined positions for label (only for OrderedPositionsAroundPoint placement) More... | |
double | mPriority |
Priority of the label. More... | |
QPointF | mQuadOffset |
whether the side of the label is fixed (only for "around point" placement) More... | |
double | mRepeatDistance |
distance after which label should be repeated (only for linestrings) 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 |
Z-index of label (higher z-index labels are rendered on top of lower z-index labels) More... | |
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.
Definition at line 52 of file qgslabelfeature.h.
QgsLabelFeature::QgsLabelFeature | ( | QgsFeatureId | id, |
GEOSGeometry * | geometry, | ||
QSizeF | size | ||
) |
Create label feature, takes ownership of the geometry instance.
Definition at line 19 of file qgslabelfeature.cpp.
|
virtual |
Clean up geometry and curved label info (if present)
Definition at line 38 of file qgslabelfeature.cpp.
|
inline |
Whether label should be always shown (sets very high label priority)
Definition at line 301 of file qgslabelfeature.h.
|
inline |
Get additional infor required for curved label placement. Returns null if not set.
Definition at line 347 of file qgslabelfeature.h.
|
inline |
Applies to "around point" placement strategy or linestring features.
Distance of the label from the feature (in map units)
Definition at line 266 of file qgslabelfeature.h.
|
inline |
Angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true)
Definition at line 200 of file qgslabelfeature.h.
|
inline |
Coordinates of the fixed position (relevant only if hasFixedPosition() returns true)
Definition at line 191 of file qgslabelfeature.h.
|
inline |
Get access to the associated geometry.
Definition at line 65 of file qgslabelfeature.h.
|
inline |
Whether the label should use a fixed angle instead of using angle from automatic placement.
Definition at line 196 of file qgslabelfeature.h.
|
inline |
Whether the label should use a fixed position instead of being automatically placed.
Definition at line 187 of file qgslabelfeature.h.
|
inline |
Returns whether the quadrant for the label is fixed.
Applies to "around point" placement strategy.
Definition at line 210 of file qgslabelfeature.h.
|
inline |
Identifier of the label (unique within the parent label provider)
Definition at line 62 of file qgslabelfeature.h.
|
inline |
Returns whether the feature will act as an obstacle for labels.
Definition at line 310 of file qgslabelfeature.h.
|
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 342 of file qgslabelfeature.h.
|
inline |
Get PAL layer of the label feature. Should be only used internally in PAL.
Definition at line 352 of file qgslabelfeature.h.
|
inline |
Returns the obstacle factor for the feature.
The factor controls the penalty for labels overlapping this feature.
Definition at line 324 of file qgslabelfeature.h.
|
inline |
Returns the label's obstacle geometry, if different to the feature geometry.
Definition at line 83 of file qgslabelfeature.h.
|
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.
Definition at line 252 of file qgslabelfeature.h.
|
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.
Definition at line 104 of file qgslabelfeature.h.
|
inline |
Returns a GEOS prepared geometry representing the label's permissibleZone().
Definition at line 112 of file qgslabelfeature.h.
|
inline |
Applies only to "offset from point" placement strategy.
What offset (in map units) to use from the point
Definition at line 238 of file qgslabelfeature.h.
|
inline |
Returns the priority ordered list of predefined positions for label candidates.
This property is only used for OrderedPositionsAroundPoint placements.
Definition at line 279 of file qgslabelfeature.h.
|
inline |
Returns the feature's labeling priority.
Definition at line 158 of file qgslabelfeature.h.
QgsAbstractLabelProvider * QgsLabelFeature::provider | ( | ) | const |
Return provider of this instance.
Definition at line 356 of file qgslabelingengine.cpp.
|
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 226 of file qgslabelfeature.h.
|
inline |
Applies only to linestring features - after what distance (in map units) the labels should be repeated (0 = no repetitions)
Definition at line 292 of file qgslabelfeature.h.
|
inline |
Set whether label should be always shown (sets very high label priority)
Definition at line 303 of file qgslabelfeature.h.
|
inline |
takes ownership of the instance
Definition at line 349 of file qgslabelfeature.h.
|
inline |
Applies to "around point" placement strategy or linestring features.
Set distance of the label from the feature (in map units)
Definition at line 272 of file qgslabelfeature.h.
|
inline |
Set angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true)
Definition at line 202 of file qgslabelfeature.h.
|
inline |
Set coordinates of the fixed position (relevant only if hasFixedPosition() returns true)
Definition at line 193 of file qgslabelfeature.h.
|
inline |
Set whether the label should use a fixed angle instead of using angle from automatic placement.
Definition at line 198 of file qgslabelfeature.h.
|
inline |
Set whether the label should use a fixed position instead of being automatically placed.
Definition at line 189 of file qgslabelfeature.h.
|
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.
Definition at line 218 of file qgslabelfeature.h.
|
inline |
Sets whether the feature will act as an obstacle for labels.
enabled | whether feature will act as an obstacle |
Definition at line 317 of file qgslabelfeature.h.
|
inline |
Set text of the label.
Definition at line 344 of file qgslabelfeature.h.
|
inline |
Assign PAL layer to the label feature. Should be only used internally in PAL.
Definition at line 354 of file qgslabelfeature.h.
|
inline |
Sets the obstacle factor for the feature.
The factor controls the penalty for labels overlapping this feature.
factor | larger factors ( > 1.0 ) will result in labels which are less likely to cover this feature, smaller factors ( < 1.0 ) mean labels are more likely to cover this feature (where required) |
Definition at line 334 of file qgslabelfeature.h.
void QgsLabelFeature::setObstacleGeometry | ( | GEOSGeometry * | obstacleGeom | ) |
Sets the label's obstacle geometry, if different to the feature geometry.
This can be used to override the shape of the feature for obstacle detection, e.g., to buffer around a point geometry to prevent labels being placed too close to the point itself. It not set, the feature's geometry is used for obstacle detection. Ownership of obstacle geometry is transferred.
Definition at line 55 of file qgslabelfeature.cpp.
|
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.
Definition at line 260 of file qgslabelfeature.h.
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.
geometry | permissible zone geometry. If an invalid QgsGeometry is passed then no zone limit will be applied to the label candidates (this is the default behavior). |
Definition at line 63 of file qgslabelfeature.cpp.
|
inline |
Applies only to "offset from point" placement strategy.
Set what offset (in map units) to use from the point
Definition at line 244 of file qgslabelfeature.h.
|
inline |
Sets the priority ordered list of predefined positions for label candidates.
This property is only used for OrderedPositionsAroundPoint placements.
Definition at line 286 of file qgslabelfeature.h.
|
inline |
Sets the priority for labeling the feature.
priority | feature'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. |
Definition at line 167 of file qgslabelfeature.h.
|
inline |
Set which side of the point to use.
Definition at line 232 of file qgslabelfeature.h.
|
inline |
Applies only to linestring features - set after what distance (in map units) the labels should be repeated (0 = no repetitions)
Definition at line 298 of file qgslabelfeature.h.
|
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.
Definition at line 141 of file qgslabelfeature.h.
|
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.
margin | visual margins for label |
Definition at line 127 of file qgslabelfeature.h.
|
inline |
Sets the label's z-index.
Higher z-index labels are rendered on top of lower z-index labels.
zIndex | z-index for label |
Definition at line 184 of file qgslabelfeature.h.
|
inline |
Size of the label (in map units)
Definition at line 115 of file qgslabelfeature.h.
|
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.
Definition at line 150 of file qgslabelfeature.h.
|
inline |
Returns the visual margin for the label feature.
Definition at line 133 of file qgslabelfeature.h.
|
inline |
Returns the label's z-index.
Higher z-index labels are rendered on top of lower z-index labels.
Definition at line 175 of file qgslabelfeature.h.
|
protected |
whether to always show label - even in case of collisions
Definition at line 404 of file qgslabelfeature.h.
|
protected |
distance of label from the feature (only for "around point" placement or linestrings)
Definition at line 396 of file qgslabelfeature.h.
|
protected |
fixed rotation for the label (instead of automatic choice)
Definition at line 388 of file qgslabelfeature.h.
|
protected |
fixed position for the label (instead of automatic placement)
Definition at line 384 of file qgslabelfeature.h.
|
protected |
Geometry of the feature to be labelled.
Definition at line 366 of file qgslabelfeature.h.
|
protected |
whether mFixedAngle should be respected
Definition at line 386 of file qgslabelfeature.h.
|
protected |
whether mFixedPosition should be respected
Definition at line 382 of file qgslabelfeature.h.
|
protected |
whether mQuadOffset should be respected (only for "around point" placement)
Definition at line 390 of file qgslabelfeature.h.
|
protected |
Associated ID unique within the parent label provider.
Definition at line 364 of file qgslabelfeature.h.
|
protected |
extra information for curved labels (may be null)
Definition at line 412 of file qgslabelfeature.h.
|
protected |
whether the feature geometry acts as an obstacle for labels
Definition at line 406 of file qgslabelfeature.h.
|
protected |
text of the label
Definition at line 410 of file qgslabelfeature.h.
|
protected |
Pointer to PAL layer (assigned when registered to PAL)
Definition at line 361 of file qgslabelfeature.h.
|
protected |
how strong is the geometry acting as obstacle
Definition at line 408 of file qgslabelfeature.h.
|
protected |
Optional geometry to use for label obstacles, if different to mGeometry.
Definition at line 368 of file qgslabelfeature.h.
|
protected |
Offset type for certain placement modes.
Definition at line 398 of file qgslabelfeature.h.
|
protected |
Optional geometry to use for label's permissible zone.
Definition at line 370 of file qgslabelfeature.h.
|
protected |
offset of label from the feature (only for "offset from point" placement)
Definition at line 394 of file qgslabelfeature.h.
|
protected |
Ordered list of predefined positions for label (only for OrderedPositionsAroundPoint placement)
Definition at line 400 of file qgslabelfeature.h.
|
protected |
Priority of the label.
Definition at line 378 of file qgslabelfeature.h.
|
protected |
whether the side of the label is fixed (only for "around point" placement)
Definition at line 392 of file qgslabelfeature.h.
|
protected |
distance after which label should be repeated (only for linestrings)
Definition at line 402 of file qgslabelfeature.h.
|
protected |
Width and height of the label.
Definition at line 372 of file qgslabelfeature.h.
|
protected |
Size of associated rendered symbol, if applicable.
Definition at line 376 of file qgslabelfeature.h.
|
protected |
Visual margin of label contents.
Definition at line 374 of file qgslabelfeature.h.
|
protected |
Z-index of label (higher z-index labels are rendered on top of lower z-index labels)
Definition at line 380 of file qgslabelfeature.h.