QGIS API Documentation
3.0.2-Girona (307d082)
|
#include <qgspallabeling.h>
Public Member Functions | |
QgsPalLayerSettings () | |
QgsPalLayerSettings (const QgsPalLayerSettings &s) | |
~QgsPalLayerSettings () | |
void | calculateLabelSize (const QFontMetricsF *fm, QString text, double &labelX, double &labelY, QgsFeature *f=nullptr, QgsRenderContext *context=nullptr) |
QgsPropertyCollection & | dataDefinedProperties () |
Returns a reference to the label's property collection, used for data defined overrides. More... | |
const QgsPropertyCollection & | dataDefinedProperties () const |
Returns a reference to the label's property collection, used for data defined overrides. More... | |
const QgsTextFormat & | format () const |
Returns the label text formatting settings, e.g., font settings, buffer settings, etc. More... | |
QgsExpression * | getLabelExpression () |
Returns the QgsExpression for this label settings. More... | |
QgsPalLayerSettings & | operator= (const QgsPalLayerSettings &s) |
copy operator - only copies the permanent members More... | |
void | readXml (QDomElement &elem, const QgsReadWriteContext &context) |
Read settings from a DOM element. More... | |
void | registerFeature (QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **labelFeature=nullptr, QgsGeometry obstacleGeometry=QgsGeometry()) |
Register a feature for labeling. More... | |
void | setDataDefinedProperties (const QgsPropertyCollection &collection) |
Sets the label's property collection, used for data defined overrides. More... | |
void | setFormat (const QgsTextFormat &format) |
Sets the label text formatting settings, e.g., font settings, buffer settings, etc. More... | |
QDomElement | writeXml (QDomDocument &doc, const QgsReadWriteContext &context) |
Write settings into a DOM element. More... | |
Static Public Member Functions | |
static const QgsPropertiesDefinition & | propertyDefinitions () |
Returns the labeling property definitions. More... | |
Public Attributes | |
bool | addDirectionSymbol |
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be automatically added to the label text, pointing in the direction of the line or polygon ring. More... | |
double | angleOffset |
Label rotation, in degrees clockwise. More... | |
bool | centroidInside |
True if centroid positioned labels must be placed inside their corresponding feature polygon, or false if centroids which fall outside the polygon are permitted. More... | |
bool | centroidWhole |
True if feature centroid should be calculated from the whole feature, or false if only the visible part of the feature should be considered. More... | |
QgsCoordinateTransform | ct |
int | decimals |
Number of decimal places to show for numeric labels. More... | |
bool | displayAll |
If true, all features will be labelled even when overlaps occur. More... | |
double | dist |
Distance from feature to the label. More... | |
QgsMapUnitScale | distMapUnitScale |
Map unit scale for label feature distance. More... | |
QgsUnitTypes::RenderUnit | distUnits |
Units the distance from feature to the label. More... | |
bool | drawLabels |
Whether to draw labels for this layer. More... | |
QgsGeometry | extentGeom |
int | fieldIndex |
QString | fieldName |
Name of field (or an expression) to use for label text. More... | |
bool | fitInPolygonOnly |
True if only labels which completely fit within a polygon are allowed. More... | |
bool | fontLimitPixelSize |
True if label sizes should be limited by pixel size. More... | |
int | fontMaxPixelSize |
Maximum pixel size for showing rendered map unit labels (1 - 10000). More... | |
int | fontMinPixelSize |
Minimum pixel size for showing rendered map unit labels (1 - 1000). More... | |
bool | formatNumbers |
Set to true to format numeric label text as numbers (e.g. More... | |
bool | isExpression |
True if this label is made from a expression string, e.g., FieldName || 'mm'. More... | |
QgsMapUnitScale | labelOffsetMapUnitScale |
Map unit scale for label offset. More... | |
bool | labelPerPart |
True if every part of a multi-part feature should be labeled. More... | |
QString | leftDirectionSymbol |
String to use for left direction arrows. More... | |
bool | limitNumLabels |
True if the number of labels drawn should be limited. More... | |
double | maxCurvedCharAngleIn |
Maximum angle between inside curved label characters (valid range 20.0 to 60.0). More... | |
double | maxCurvedCharAngleOut |
Maximum angle between outside curved label characters (valid range -20.0 to -95.0) More... | |
double | maximumScale |
The maximum map scale (i.e. More... | |
int | maxNumLabels |
The maximum number of labels which should be drawn for this layer. More... | |
QgsFeature * | mCurFeat = nullptr |
QgsFields | mCurFields |
bool | mergeLines |
True if connected line features with identical label text should be merged prior to generating label positions. More... | |
int | mFeatsRegPal = 0 |
int | mFeatsSendingToPal = 0 |
int | mFeaturesToLabel = 0 |
double | minFeatureSize |
Minimum feature size (in millimeters) for a feature to be labelled. More... | |
double | minimumScale |
The minimum map scale (i.e. More... | |
MultiLineAlign | multilineAlign |
Horizontal alignment of multi-line labels. More... | |
bool | obstacle |
True if features for layer are obstacles to labels of other layers. More... | |
double | obstacleFactor |
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, More... | |
ObstacleType | obstacleType |
Controls how features act as obstacles for labels. More... | |
OffsetType | offsetType |
Offset type for layer (only applies in certain placement modes) More... | |
QgsUnitTypes::RenderUnit | offsetUnits |
Units for offsets of label. More... | |
DirectionSymbols | placeDirectionSymbol |
Placement option for direction symbols. More... | |
Placement | placement |
unsigned int | placementFlags |
bool | plusSign |
Whether '+' signs should be prepended to positive numeric labels. More... | |
QVector< PredefinedPointPosition > | predefinedPositionOrder |
Ordered list of predefined label positions for points. More... | |
bool | preserveRotation |
True if label rotation should be preserved during label pin/unpin operations. More... | |
QColor | previewBkgrdColor |
int | priority |
Label priority. More... | |
QgsPointXY | ptOne |
QgsPointXY | ptZero |
QuadrantPosition | quadOffset |
Sets the quadrant in which to offset labels from feature. More... | |
double | repeatDistance |
Distance for repeating labels for a single feature. More... | |
QgsMapUnitScale | repeatDistanceMapUnitScale |
Map unit scale for repeating labels for a single feature. More... | |
QgsUnitTypes::RenderUnit | repeatDistanceUnit |
Units for repeating labels for a single feature. More... | |
bool | reverseDirectionSymbol |
True if direction symbols should be reversed. More... | |
QString | rightDirectionSymbol |
String to use for right direction arrows. More... | |
bool | scaleVisibility |
Set to true to limit label visibility to a range of scales. More... | |
QgsStringReplacementCollection | substitutions |
Substitution collection for automatic text substitution with labels. More... | |
UpsideDownLabels | upsidedownLabels = Upright |
Controls whether upside down labels are displayed and how they are handled. More... | |
bool | useSubstitutions |
True if substitutions should be applied. More... | |
QString | wrapChar |
Wrapping character string. More... | |
const QgsMapToPixel * | xform = nullptr |
double | xOffset |
Horizontal offset of label. More... | |
double | yOffset |
Vertical offset of label. More... | |
double | zIndex |
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-index. More... | |
Friends | |
class | QgsVectorLayer |
Definition at line 123 of file qgspallabeling.h.
Enumerator | |
---|---|
SymbolLeftRight | Place direction symbols on left/right of label. |
SymbolAbove | Place direction symbols on above label. |
SymbolBelow | Place direction symbols on below label. |
Definition at line 217 of file qgspallabeling.h.
Line placement flags, which control how candidates are generated for a linear feature.
Definition at line 183 of file qgspallabeling.h.
Enumerator | |
---|---|
MultiLeft | |
MultiCenter | |
MultiRight | |
MultiFollowPlacement | Alignment follows placement of label, e.g., labels to the left of a feature will be drawn with right alignment |
Definition at line 224 of file qgspallabeling.h.
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
Definition at line 238 of file qgspallabeling.h.
Behavior modifier for label offset and distance, only applies in some label placement modes.
Enumerator | |
---|---|
FromPoint | Offset distance applies from point geometry. |
FromSymbolBounds | Offset distance applies from rendered symbol bounds. |
Definition at line 172 of file qgspallabeling.h.
Placement modes which determine how label candidates are generated for a feature.
Definition at line 137 of file qgspallabeling.h.
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode.
Definition at line 151 of file qgspallabeling.h.
Data definable properties.
Definition at line 251 of file qgspallabeling.h.
Enumerator | |
---|---|
QuadrantAboveLeft | |
QuadrantAbove | |
QuadrantAboveRight | |
QuadrantLeft | |
QuadrantOver | |
QuadrantRight | |
QuadrantBelowLeft | |
QuadrantBelow | |
QuadrantBelowRight |
Definition at line 197 of file qgspallabeling.h.
Definition at line 210 of file qgspallabeling.h.
QgsPalLayerSettings::QgsPalLayerSettings | ( | ) |
Definition at line 233 of file qgspallabeling.cpp.
QgsPalLayerSettings::QgsPalLayerSettings | ( | const QgsPalLayerSettings & | s | ) |
Definition at line 298 of file qgspallabeling.cpp.
QgsPalLayerSettings::~QgsPalLayerSettings | ( | ) |
Definition at line 385 of file qgspallabeling.cpp.
void QgsPalLayerSettings::calculateLabelSize | ( | const QFontMetricsF * | fm, |
QString | text, | ||
double & | labelX, | ||
double & | labelY, | ||
QgsFeature * | f = nullptr , |
||
QgsRenderContext * | context = nullptr |
||
) |
Definition at line 1030 of file qgspallabeling.cpp.
|
inline |
Returns a reference to the label's property collection, used for data defined overrides.
Definition at line 769 of file qgspallabeling.h.
|
inline |
Returns a reference to the label's property collection, used for data defined overrides.
Definition at line 777 of file qgspallabeling.h.
|
inline |
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
Definition at line 792 of file qgspallabeling.h.
QgsExpression * QgsPalLayerSettings::getLabelExpression | ( | ) |
Returns the QgsExpression for this label settings.
May be nullptr if isExpression is false.
Definition at line 399 of file qgspallabeling.cpp.
QgsPalLayerSettings & QgsPalLayerSettings::operator= | ( | const QgsPalLayerSettings & | s | ) |
copy operator - only copies the permanent members
Definition at line 305 of file qgspallabeling.cpp.
|
static |
Returns the labeling property definitions.
Definition at line 393 of file qgspallabeling.cpp.
void QgsPalLayerSettings::readXml | ( | QDomElement & | elem, |
const QgsReadWriteContext & | context | ||
) |
void QgsPalLayerSettings::registerFeature | ( | QgsFeature & | f, |
QgsRenderContext & | context, | ||
QgsLabelFeature ** | labelFeature = nullptr , |
||
QgsGeometry | obstacleGeometry = QgsGeometry() |
||
) |
Register a feature for labeling.
f | feature to label |
context | render context. The QgsExpressionContext contained within the render context must have already had the feature and fields sets prior to calling this method. |
labelFeature | if using QgsLabelingEngine, this will receive the label feature. Not available in Python bindings. |
obstacleGeometry | optional obstacle geometry, if a different geometry to the feature's geometry should be used as an obstacle for labels (e.g., if the feature has been rendered with an offset point symbol, the obstacle geometry should represent the bounds of the offset symbol). If not set, the feature's original geometry will be used as an obstacle for labels. Not available in Python bindings. |
Definition at line 1169 of file qgspallabeling.cpp.
|
inline |
Sets the label's property collection, used for data defined overrides.
collection | property collection. Existing properties will be replaced. |
Definition at line 785 of file qgspallabeling.h.
|
inline |
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
format | label text format |
Definition at line 800 of file qgspallabeling.h.
QDomElement QgsPalLayerSettings::writeXml | ( | QDomDocument & | doc, |
const QgsReadWriteContext & | context | ||
) |
Write settings into a DOM element.
Definition at line 939 of file qgspallabeling.cpp.
|
friend |
Definition at line 818 of file qgspallabeling.h.
bool QgsPalLayerSettings::addDirectionSymbol |
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be automatically added to the label text, pointing in the direction of the line or polygon ring.
This setting only affects line or perimeter based labels.
Definition at line 433 of file qgspallabeling.h.
double QgsPalLayerSettings::angleOffset |
Label rotation, in degrees clockwise.
Definition at line 594 of file qgspallabeling.h.
bool QgsPalLayerSettings::centroidInside |
True if centroid positioned labels must be placed inside their corresponding feature polygon, or false if centroids which fall outside the polygon are permitted.
Definition at line 496 of file qgspallabeling.h.
bool QgsPalLayerSettings::centroidWhole |
True if feature centroid should be calculated from the whole feature, or false if only the visible part of the feature should be considered.
Definition at line 489 of file qgspallabeling.h.
QgsCoordinateTransform QgsPalLayerSettings::ct |
Definition at line 807 of file qgspallabeling.h.
int QgsPalLayerSettings::decimals |
Number of decimal places to show for numeric labels.
formatNumbers must be true for this setting to have an effect.
Definition at line 471 of file qgspallabeling.h.
bool QgsPalLayerSettings::displayAll |
If true, all features will be labelled even when overlaps occur.
Definition at line 672 of file qgspallabeling.h.
double QgsPalLayerSettings::dist |
Distance from feature to the label.
Units are specified via distUnits.
Definition at line 516 of file qgspallabeling.h.
QgsMapUnitScale QgsPalLayerSettings::distMapUnitScale |
Map unit scale for label feature distance.
Definition at line 530 of file qgspallabeling.h.
QgsUnitTypes::RenderUnit QgsPalLayerSettings::distUnits |
Units the distance from feature to the label.
Definition at line 523 of file qgspallabeling.h.
bool QgsPalLayerSettings::drawLabels |
Whether to draw labels for this layer.
For some layers it may be desirable to register their features as obstacles for other labels without requiring labels to be drawn for the layer itself. In this case drawLabels can be set to false and obstacle set to true, which will result in the layer acting as an obstacle but having no labels of its own.
Definition at line 383 of file qgspallabeling.h.
QgsGeometry QgsPalLayerSettings::extentGeom |
Definition at line 811 of file qgspallabeling.h.
int QgsPalLayerSettings::fieldIndex |
Definition at line 805 of file qgspallabeling.h.
QString QgsPalLayerSettings::fieldName |
Name of field (or an expression) to use for label text.
If fieldName is an expression, then isExpression should be set to true.
Definition at line 392 of file qgspallabeling.h.
bool QgsPalLayerSettings::fitInPolygonOnly |
True if only labels which completely fit within a polygon are allowed.
Definition at line 509 of file qgspallabeling.h.
bool QgsPalLayerSettings::fontLimitPixelSize |
True if label sizes should be limited by pixel size.
Definition at line 655 of file qgspallabeling.h.
int QgsPalLayerSettings::fontMaxPixelSize |
Maximum pixel size for showing rendered map unit labels (1 - 10000).
Definition at line 669 of file qgspallabeling.h.
int QgsPalLayerSettings::fontMinPixelSize |
Minimum pixel size for showing rendered map unit labels (1 - 1000).
Definition at line 662 of file qgspallabeling.h.
bool QgsPalLayerSettings::formatNumbers |
Set to true to format numeric label text as numbers (e.g.
inserting thousand separators and fixed number of decimal places).
Definition at line 464 of file qgspallabeling.h.
bool QgsPalLayerSettings::isExpression |
True if this label is made from a expression string, e.g., FieldName || 'mm'.
Definition at line 398 of file qgspallabeling.h.
QgsMapUnitScale QgsPalLayerSettings::labelOffsetMapUnitScale |
Map unit scale for label offset.
Definition at line 591 of file qgspallabeling.h.
bool QgsPalLayerSettings::labelPerPart |
True if every part of a multi-part feature should be labeled.
If false, only the largest part will be labeled.
Definition at line 681 of file qgspallabeling.h.
QString QgsPalLayerSettings::leftDirectionSymbol |
String to use for left direction arrows.
Definition at line 440 of file qgspallabeling.h.
bool QgsPalLayerSettings::limitNumLabels |
True if the number of labels drawn should be limited.
Definition at line 693 of file qgspallabeling.h.
double QgsPalLayerSettings::maxCurvedCharAngleIn |
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
Definition at line 603 of file qgspallabeling.h.
double QgsPalLayerSettings::maxCurvedCharAngleOut |
Maximum angle between outside curved label characters (valid range -20.0 to -95.0)
Definition at line 609 of file qgspallabeling.h.
double QgsPalLayerSettings::maximumScale |
The maximum map scale (i.e.
most "zoomed in" scale) at which the labels will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.
This setting is only considered if scaleVisibility is true.
Definition at line 636 of file qgspallabeling.h.
int QgsPalLayerSettings::maxNumLabels |
The maximum number of labels which should be drawn for this layer.
This only has an effect if limitNumLabels is true.
Definition at line 700 of file qgspallabeling.h.
QgsFeature* QgsPalLayerSettings::mCurFeat = nullptr |
Definition at line 803 of file qgspallabeling.h.
QgsFields QgsPalLayerSettings::mCurFields |
Definition at line 804 of file qgspallabeling.h.
bool QgsPalLayerSettings::mergeLines |
True if connected line features with identical label text should be merged prior to generating label positions.
Definition at line 687 of file qgspallabeling.h.
int QgsPalLayerSettings::mFeatsRegPal = 0 |
Definition at line 814 of file qgspallabeling.h.
int QgsPalLayerSettings::mFeatsSendingToPal = 0 |
Definition at line 813 of file qgspallabeling.h.
int QgsPalLayerSettings::mFeaturesToLabel = 0 |
Definition at line 812 of file qgspallabeling.h.
double QgsPalLayerSettings::minFeatureSize |
Minimum feature size (in millimeters) for a feature to be labelled.
Definition at line 705 of file qgspallabeling.h.
double QgsPalLayerSettings::minimumScale |
The minimum map scale (i.e.
most "zoomed out" scale) at which the labels will be visible. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.
This setting is only considered if scaleVisibility is true.
Definition at line 648 of file qgspallabeling.h.
MultiLineAlign QgsPalLayerSettings::multilineAlign |
Horizontal alignment of multi-line labels.
Definition at line 421 of file qgspallabeling.h.
bool QgsPalLayerSettings::obstacle |
True if features for layer are obstacles to labels of other layers.
Definition at line 712 of file qgspallabeling.h.
double QgsPalLayerSettings::obstacleFactor |
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels,
1.0 less likely to be covered
Definition at line 720 of file qgspallabeling.h.
ObstacleType QgsPalLayerSettings::obstacleType |
Controls how features act as obstacles for labels.
Definition at line 727 of file qgspallabeling.h.
OffsetType QgsPalLayerSettings::offsetType |
Offset type for layer (only applies in certain placement modes)
Definition at line 533 of file qgspallabeling.h.
QgsUnitTypes::RenderUnit QgsPalLayerSettings::offsetUnits |
Units for offsets of label.
Definition at line 583 of file qgspallabeling.h.
DirectionSymbols QgsPalLayerSettings::placeDirectionSymbol |
Placement option for direction symbols.
Controls whether to place symbols to the left/right, above or below label.
Definition at line 453 of file qgspallabeling.h.
Placement QgsPalLayerSettings::placement |
Definition at line 482 of file qgspallabeling.h.
unsigned int QgsPalLayerSettings::placementFlags |
Definition at line 483 of file qgspallabeling.h.
bool QgsPalLayerSettings::plusSign |
Whether '+' signs should be prepended to positive numeric labels.
formatNumbers must be true for this setting to have an effect.
Definition at line 478 of file qgspallabeling.h.
QVector< PredefinedPointPosition > QgsPalLayerSettings::predefinedPositionOrder |
Ordered list of predefined label positions for points.
Positions earlier in the list will be prioritized over later positions. Only used when the placement is set to QgsPalLayerSettings::OrderedPositionsAroundPoint.
Definition at line 504 of file qgspallabeling.h.
bool QgsPalLayerSettings::preserveRotation |
True if label rotation should be preserved during label pin/unpin operations.
Definition at line 597 of file qgspallabeling.h.
QColor QgsPalLayerSettings::previewBkgrdColor |
Definition at line 405 of file qgspallabeling.h.
int QgsPalLayerSettings::priority |
Label priority.
Valid ranges are from 0 to 10, where 0 = lowest priority and 10 = highest priority.
Definition at line 615 of file qgspallabeling.h.
QgsPointXY QgsPalLayerSettings::ptOne |
Definition at line 810 of file qgspallabeling.h.
QgsPointXY QgsPalLayerSettings::ptZero |
Definition at line 809 of file qgspallabeling.h.
QuadrantPosition QgsPalLayerSettings::quadOffset |
Sets the quadrant in which to offset labels from feature.
Definition at line 559 of file qgspallabeling.h.
double QgsPalLayerSettings::repeatDistance |
Distance for repeating labels for a single feature.
Definition at line 540 of file qgspallabeling.h.
QgsMapUnitScale QgsPalLayerSettings::repeatDistanceMapUnitScale |
Map unit scale for repeating labels for a single feature.
Definition at line 554 of file qgspallabeling.h.
QgsUnitTypes::RenderUnit QgsPalLayerSettings::repeatDistanceUnit |
Units for repeating labels for a single feature.
Definition at line 547 of file qgspallabeling.h.
bool QgsPalLayerSettings::reverseDirectionSymbol |
True if direction symbols should be reversed.
Definition at line 456 of file qgspallabeling.h.
QString QgsPalLayerSettings::rightDirectionSymbol |
String to use for right direction arrows.
Definition at line 447 of file qgspallabeling.h.
bool QgsPalLayerSettings::scaleVisibility |
Set to true to limit label visibility to a range of scales.
Definition at line 624 of file qgspallabeling.h.
QgsStringReplacementCollection QgsPalLayerSettings::substitutions |
Substitution collection for automatic text substitution with labels.
Definition at line 408 of file qgspallabeling.h.
UpsideDownLabels QgsPalLayerSettings::upsidedownLabels = Upright |
Controls whether upside down labels are displayed and how they are handled.
Definition at line 675 of file qgspallabeling.h.
bool QgsPalLayerSettings::useSubstitutions |
True if substitutions should be applied.
Definition at line 410 of file qgspallabeling.h.
QString QgsPalLayerSettings::wrapChar |
Wrapping character string.
If set, any occurrences of this string in the calculated label text will be replaced with new line characters.
Definition at line 418 of file qgspallabeling.h.
const QgsMapToPixel* QgsPalLayerSettings::xform = nullptr |
Definition at line 806 of file qgspallabeling.h.
double QgsPalLayerSettings::xOffset |
Horizontal offset of label.
Units are specified via offsetUnits.
Definition at line 567 of file qgspallabeling.h.
double QgsPalLayerSettings::yOffset |
Vertical offset of label.
Units are specified via offsetUnits.
Definition at line 575 of file qgspallabeling.h.
double QgsPalLayerSettings::zIndex |
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-index.
Definition at line 730 of file qgspallabeling.h.