QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
QgsPalLayerSettings Class Reference

#include <qgspallabeling.h>

Public Types

enum  DataDefinedProperties {
  Size = 0, Bold = 1, Italic = 2, Underline = 3,
  Color = 4, Strikeout = 5, Family = 6, FontStyle = 21,
  FontSizeUnit = 22, FontTransp = 18, FontCase = 27, FontLetterSpacing = 28,
  FontWordSpacing = 29, FontBlendMode = 30, MultiLineWrapChar = 31, MultiLineHeight = 32,
  MultiLineAlignment = 33, DirSymbDraw = 34, DirSymbLeft = 35, DirSymbRight = 36,
  DirSymbPlacement = 37, DirSymbReverse = 38, NumFormat = 39, NumDecimals = 40,
  NumPlusSign = 41, BufferDraw = 42, BufferSize = 7, BufferUnit = 43,
  BufferColor = 8, BufferTransp = 19, BufferJoinStyle = 44, BufferBlendMode = 45,
  ShapeDraw = 46, ShapeKind = 47, ShapeSVGFile = 48, ShapeSizeType = 49,
  ShapeSizeX = 50, ShapeSizeY = 85, ShapeSizeUnits = 51, ShapeRotationType = 52,
  ShapeRotation = 53, ShapeOffset = 54, ShapeOffsetUnits = 55, ShapeRadii = 56,
  ShapeRadiiUnits = 57, ShapeTransparency = 63, ShapeBlendMode = 64, ShapeFillColor = 58,
  ShapeBorderColor = 59, ShapeBorderWidth = 60, ShapeBorderWidthUnits = 61, ShapeJoinStyle = 62,
  ShadowDraw = 65, ShadowUnder = 66, ShadowOffsetAngle = 67, ShadowOffsetDist = 68,
  ShadowOffsetUnits = 69, ShadowRadius = 70, ShadowRadiusUnits = 71, ShadowTransparency = 72,
  ShadowScale = 73, ShadowColor = 74, ShadowBlendMode = 75, CentroidWhole = 76,
  OffsetQuad = 77, OffsetXY = 78, OffsetUnits = 80, LabelDistance = 13,
  DistanceUnits = 81, OffsetRotation = 82, CurvedCharAngleInOut = 83, PositionX = 9,
  PositionY = 10, Hali = 11, Vali = 12, Rotation = 14,
  RepeatDistance = 84, RepeatDistanceUnit = 86, Priority = 87, PredefinedPositionOrder = 91,
  ScaleVisibility = 23, MinScale = 16, MaxScale = 17, FontLimitPixel = 24,
  FontMinPixel = 25, FontMaxPixel = 26, IsObstacle = 88, ObstacleFactor = 89,
  ZIndex = 90, Show = 15, AlwaysShow = 20
}
 
enum  DirectionSymbols { SymbolLeftRight, SymbolAbove, SymbolBelow }
 
enum  LinePlacementFlags { OnLine = 1, AboveLine = 2, BelowLine = 4, MapOrientation = 8 }
 Line placement flags, which control how candidates are generated for a linear feature. More...
 
enum  MultiLineAlign { MultiLeft = 0, MultiCenter, MultiRight, MultiFollowPlacement }
 
enum  ObstacleType { PolygonInterior, PolygonBoundary, PolygonWhole }
 Valid obstacle types, which affect how features within the layer will act as obstacles for labels. More...
 
enum  OffsetType { FromPoint, FromSymbolBounds }
 Behaviour modifier for label offset and distance, only applies in some label placement modes. More...
 
enum  Placement {
  AroundPoint, OverPoint, Line, Curved,
  Horizontal, Free, OrderedPositionsAroundPoint, PerimeterCurved
}
 Placement modes which determine how label candidates are generated for a feature. More...
 
enum  PredefinedPointPosition {
  TopLeft, TopSlightlyLeft, TopMiddle, TopSlightlyRight,
  TopRight, MiddleLeft, MiddleRight, BottomLeft,
  BottomSlightlyLeft, BottomMiddle, BottomSlightlyRight, BottomRight
}
 Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode. More...
 
enum  QuadrantPosition {
  QuadrantAboveLeft, QuadrantAbove, QuadrantAboveRight, QuadrantLeft,
  QuadrantOver, QuadrantRight, QuadrantBelowLeft, QuadrantBelow,
  QuadrantBelowRight
}
 
enum  RotationType { RotationSync = 0, RotationOffset, RotationFixed }
 
enum  ShadowType { ShadowLowest = 0, ShadowText, ShadowBuffer, ShadowShape }
 
enum  ShapeType {
  ShapeRectangle = 0, ShapeSquare, ShapeEllipse, ShapeCircle,
  ShapeSVG
}
 
enum  SizeType { SizeBuffer = 0, SizeFixed, SizePercent }
 
enum  SizeUnit { Points = 0, MM, MapUnits, Percent }
 Units used for option sizes, before being converted to rendered sizes. More...
 
enum  UpsideDownLabels { Upright, ShowDefined, ShowAll }
 

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)
 
bool dataDefinedEvaluate (QgsPalLayerSettings::DataDefinedProperties p, QVariant &exprVal, QgsExpressionContext *context=nullptr, const QVariant &originalValue=QVariant()) const
 Get data defined property value from expression string or attribute field name. More...
 
bool dataDefinedIsActive (QgsPalLayerSettings::DataDefinedProperties p) const
 Whether data definition is active. More...
 
QMap< QString, QStringdataDefinedMap (QgsPalLayerSettings::DataDefinedProperties p) const
 Get property value as separate values split into Qmap. More...
 
QMap< QgsPalLayerSettings::DataDefinedProperties, QPair< QString, int > > dataDefinedNames () const
 Map of data defined enum to names and old-style indecies The QPair contains a new string for layer property key, and a reference to old-style numeric key (< QGIS 2.0) More...
 
QgsDataDefineddataDefinedProperty (QgsPalLayerSettings::DataDefinedProperties p)
 Get a data defined property pointer. More...
 
bool dataDefinedUseExpression (QgsPalLayerSettings::DataDefinedProperties p) const
 Whether data definition is set to use an expression. More...
 
QVariant dataDefinedValue (QgsPalLayerSettings::DataDefinedProperties p, QgsFeature &f, const QgsFields &fields, const QgsExpressionContext *context=nullptr) const
 Get data defined property value from expression string or attribute field name. More...
 
QgsExpressiongetLabelExpression ()
 Returns the QgsExpression for this label settings. More...
 
QgsPalLayerSettingsoperator= (const QgsPalLayerSettings &s)
 copy operator - only copies the permanent members More...
 
void readFromLayer (QgsVectorLayer *layer)
 
void readXml (QDomElement &elem)
 Read settings from a DOM element. More...
 
void registerFeature (QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **labelFeature=nullptr, QgsGeometry *obstacleGeometry=nullptr)
 Register a feature for labelling. More...
 
void removeAllDataDefinedProperties ()
 Clear all data-defined properties. More...
 
void removeDataDefinedProperty (QgsPalLayerSettings::DataDefinedProperties p)
 Set a property to static instead data defined. More...
 
double scaleToPixelContext (double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale()) const
 Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling) More...
 
void setDataDefinedProperty (QgsPalLayerSettings::DataDefinedProperties p, bool active, bool useExpr, const QString &expr, const QString &field)
 Set a property as data defined. More...
 
int sizeToPixel (double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale()) const
 Calculates pixel size (considering output size should be in pixel or map units, scale factors and optionally oversampling) More...
 
QString updateDataDefinedString (const QString &value)
 Convert old property value to new one as delimited values. More...
 
void writeToLayer (QgsVectorLayer *layer)
 
QDomElement writeXml (QDomDocument &doc)
 Write settings into a DOM element. More...
 

Static Public Member Functions

static QgsPalLayerSettings fromLayer (QgsVectorLayer *layer)
 

Public Attributes

bool addDirectionSymbol
 
double angleOffset
 
QPainter::CompositionMode blendMode
 
QPainter::CompositionMode bufferBlendMode
 
QColor bufferColor
 
bool bufferDraw
 
Qt::PenJoinStyle bufferJoinStyle
 
bool bufferNoFill
 
double bufferSize
 
bool bufferSizeInMapUnits
 
QgsMapUnitScale bufferSizeMapUnitScale
 
int bufferTransp
 
bool centroidInside
 
bool centroidWhole
 
const QgsCoordinateTransformct
 
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined *> dataDefinedProperties
 Map of current data defined properties. More...
 
int decimals
 
bool displayAll
 
double dist
 
bool distInMapUnits
 
QgsMapUnitScale distMapUnitScale
 
bool drawLabels
 Whether to draw labels for this layer. More...
 
bool enabled
 
QgsGeometryextentGeom
 
int fieldIndex
 
QString fieldName
 
bool fitInPolygonOnly
 True if only labels which completely fit within a polygon are allowed. More...
 
bool fontLimitPixelSize
 
int fontMaxPixelSize
 
int fontMinPixelSize
 
bool fontSizeInMapUnits
 
QgsMapUnitScale fontSizeMapUnitScale
 
bool formatNumbers
 
bool isExpression
 Is this label made from a expression string eg FieldName || 'mm'. More...
 
bool labelOffsetInMapUnits
 
QgsMapUnitScale labelOffsetMapUnitScale
 
bool labelPerPart
 
QString leftDirectionSymbol
 
bool limitNumLabels
 
double maxCurvedCharAngleIn
 
double maxCurvedCharAngleOut
 
int maxNumLabels
 
QgsFeaturemCurFeat
 
QgsFields mCurFields
 
bool mergeLines
 
int mFeatsRegPal
 
int mFeatsSendingToPal
 
int mFeaturesToLabel
 
double minFeatureSize
 
QString mTextFontFamily
 
bool mTextFontFound
 
MultiLineAlign multilineAlign
 
double multilineHeight
 
bool obstacle
 
double obstacleFactor
 Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels,

1.0 less likely to be covered

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...
 
DirectionSymbols placeDirectionSymbol
 
Placement placement
 
unsigned int placementFlags
 
bool plusSign
 
QVector< PredefinedPointPositionpredefinedPositionOrder
 Ordered list of predefined label positions for points. More...
 
bool preserveRotation
 
QColor previewBkgrdColor
 
int priority
 
QgsPoint ptOne
 
QgsPoint ptZero
 
QuadrantPosition quadOffset
 
double rasterCompressFactor
 
double repeatDistance
 
QgsMapUnitScale repeatDistanceMapUnitScale
 
SizeUnit repeatDistanceUnit
 
bool reverseDirectionSymbol
 
QString rightDirectionSymbol
 
int scaleMax
 
int scaleMin
 
bool scaleVisibility
 
QPainter::CompositionMode shadowBlendMode
 
QColor shadowColor
 
bool shadowDraw
 
int shadowOffsetAngle
 
double shadowOffsetDist
 
bool shadowOffsetGlobal
 
QgsMapUnitScale shadowOffsetMapUnitScale
 
SizeUnit shadowOffsetUnits
 
double shadowRadius
 
bool shadowRadiusAlphaOnly
 
QgsMapUnitScale shadowRadiusMapUnitScale
 
SizeUnit shadowRadiusUnits
 
int shadowScale
 
int shadowTransparency
 
ShadowType shadowUnder
 
QPainter::CompositionMode shapeBlendMode
 
QColor shapeBorderColor
 
double shapeBorderWidth
 
QgsMapUnitScale shapeBorderWidthMapUnitScale
 
SizeUnit shapeBorderWidthUnits
 
bool shapeDraw
 
QColor shapeFillColor
 
Qt::PenJoinStyle shapeJoinStyle
 
QPointF shapeOffset
 
QgsMapUnitScale shapeOffsetMapUnitScale
 
SizeUnit shapeOffsetUnits
 
QPointF shapeRadii
 
QgsMapUnitScale shapeRadiiMapUnitScale
 
SizeUnit shapeRadiiUnits
 
double shapeRotation
 
RotationType shapeRotationType
 
QPointF shapeSize
 
QgsMapUnitScale shapeSizeMapUnitScale
 
SizeType shapeSizeType
 
SizeUnit shapeSizeUnits
 
QString shapeSVGFile
 
int shapeTransparency
 
ShapeType shapeType
 
bool showingShadowRects
 
QgsStringReplacementCollection substitutions
 Substitution collection for automatic text substitution with labels. More...
 
QColor textColor
 
QFont textFont
 
QString textNamedStyle
 
int textTransp
 
UpsideDownLabels upsidedownLabels
 
bool useSubstitutions
 True if substitutions should be applied. More...
 
double vectorScaleFactor
 
QString wrapChar
 
const QgsMapToPixelxform
 
double xOffset
 
double yOffset
 
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...
 

Detailed Description

Definition at line 68 of file qgspallabeling.h.

Member Enumeration Documentation

◆ DataDefinedProperties

Enumerator
Size 
Bold 
Italic 
Underline 
Color 
Strikeout 
Family 
FontStyle 
FontSizeUnit 
FontTransp 
FontCase 
FontLetterSpacing 
FontWordSpacing 
FontBlendMode 
MultiLineWrapChar 
MultiLineHeight 
MultiLineAlignment 
DirSymbDraw 
DirSymbLeft 
DirSymbRight 
DirSymbPlacement 
DirSymbReverse 
NumFormat 
NumDecimals 
NumPlusSign 
BufferDraw 
BufferSize 
BufferUnit 
BufferColor 
BufferTransp 
BufferJoinStyle 
BufferBlendMode 
ShapeDraw 
ShapeKind 
ShapeSVGFile 
ShapeSizeType 
ShapeSizeX 
ShapeSizeY 
ShapeSizeUnits 
ShapeRotationType 
ShapeRotation 
ShapeOffset 
ShapeOffsetUnits 
ShapeRadii 
ShapeRadiiUnits 
ShapeTransparency 
ShapeBlendMode 
ShapeFillColor 
ShapeBorderColor 
ShapeBorderWidth 
ShapeBorderWidthUnits 
ShapeJoinStyle 
ShadowDraw 
ShadowUnder 
ShadowOffsetAngle 
ShadowOffsetDist 
ShadowOffsetUnits 
ShadowRadius 
ShadowRadiusUnits 
ShadowTransparency 
ShadowScale 
ShadowColor 
ShadowBlendMode 
CentroidWhole 
OffsetQuad 
OffsetXY 
OffsetUnits 
LabelDistance 
DistanceUnits 
OffsetRotation 
CurvedCharAngleInOut 
PositionX 
PositionY 
Hali 
Vali 
Rotation 
RepeatDistance 
RepeatDistanceUnit 
Priority 
PredefinedPositionOrder 
ScaleVisibility 
MinScale 
MaxScale 
FontLimitPixel 
FontMinPixel 
FontMaxPixel 
IsObstacle 
ObstacleFactor 
ZIndex 
Show 
AlwaysShow 

Definition at line 234 of file qgspallabeling.h.

◆ DirectionSymbols

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 161 of file qgspallabeling.h.

◆ LinePlacementFlags

Line placement flags, which control how candidates are generated for a linear feature.

Enumerator
OnLine 

Labels can be placed directly over a line feature.

AboveLine 

Labels can be placed above a line feature.

Unless MapOrientation is also specified this mode respects the direction of the line feature, so a line from right to left labels will have labels placed placed below the line feature.

BelowLine 

Labels can be placed below a line feature.

Unless MapOrientation is also specified this mode respects the direction of the line feature, so a line from right to left labels will have labels placed placed above the line feature.

MapOrientation 

Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather than the feature's orientation.

Eg, AboveLine will always result in label's being placed above a line, regardless of the line's direction.

Definition at line 127 of file qgspallabeling.h.

◆ MultiLineAlign

Enumerator
MultiLeft 
MultiCenter 
MultiRight 
MultiFollowPlacement 

Alignment follows placement of label, eg labels to the left of a feature will be drawn with right alignment

Definition at line 168 of file qgspallabeling.h.

◆ ObstacleType

Valid obstacle types, which affect how features within the layer will act as obstacles for labels.

Enumerator
PolygonInterior 

avoid placing labels over interior of polygon (prefer placing labels totally outside or just slightly inside polygon)

PolygonBoundary 

avoid placing labels over boundary of polygon (prefer placing outside or completely inside polygon)

PolygonWhole 

avoid placing labels over ANY part of polygon. Where PolygonInterior will prefer to place labels with the smallest area of intersection between the label and the polygon, PolygonWhole will penalise any label which intersects with the polygon by an equal amount, so that placing labels over any part of the polygon is avoided.

Definition at line 181 of file qgspallabeling.h.

◆ OffsetType

Behaviour 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 117 of file qgspallabeling.h.

◆ Placement

Placement modes which determine how label candidates are generated for a feature.

Enumerator
AroundPoint 

Arranges candidates in a circle around a point (or centroid of a polygon).

Applies to point or polygon layers only.

OverPoint 
Line 

Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point.

Applies to point or polygon layers only. Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon's perimeter. Applies to line or polygon layers only.

Curved 
Horizontal 

Arranges candidates following the curvature of a line feature.

Applies to line layers only. Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only.

Free 

Arranges candidates scattered throughout a polygon feature.

Candidates are rotated to respect the polygon's orientation. Applies to polygon layers only.

OrderedPositionsAroundPoint 

Candidates are placed in predefined positions around a point.

Peference is given to positions with greatest cartographic appeal, eg top right, bottom right, etc. Applies to point layers only.

PerimeterCurved 

Definition at line 84 of file qgspallabeling.h.

◆ PredefinedPointPosition

Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode.

Enumerator
TopLeft 

Label on top-left of point.

TopSlightlyLeft 
TopMiddle 

Label on top of point, slightly left of center.

Label directly above point

TopSlightlyRight 
TopRight 

Label on top of point, slightly right of center.

Label on top-right of point

MiddleLeft 

Label on left of point.

MiddleRight 

Label on right of point.

BottomLeft 

Label on bottom-left of point.

BottomSlightlyLeft 
BottomMiddle 

Label below point, slightly left of center.

Label directly below point

BottomSlightlyRight 
BottomRight 

Label below point, slightly right of center.

Label on bottom right of point

Definition at line 98 of file qgspallabeling.h.

◆ QuadrantPosition

Enumerator
QuadrantAboveLeft 
QuadrantAbove 
QuadrantAboveRight 
QuadrantLeft 
QuadrantOver 
QuadrantRight 
QuadrantBelowLeft 
QuadrantBelow 
QuadrantBelowRight 

Definition at line 141 of file qgspallabeling.h.

◆ RotationType

Enumerator
RotationSync 
RotationOffset 
RotationFixed 

Definition at line 209 of file qgspallabeling.h.

◆ ShadowType

Enumerator
ShadowLowest 
ShadowText 
ShadowBuffer 
ShadowShape 

Definition at line 225 of file qgspallabeling.h.

◆ ShapeType

Enumerator
ShapeRectangle 
ShapeSquare 
ShapeEllipse 
ShapeCircle 
ShapeSVG 

Definition at line 193 of file qgspallabeling.h.

◆ SizeType

Enumerator
SizeBuffer 
SizeFixed 
SizePercent 

Definition at line 202 of file qgspallabeling.h.

◆ SizeUnit

Units used for option sizes, before being converted to rendered sizes.

Enumerator
Points 
MM 
MapUnits 
Percent 

Definition at line 217 of file qgspallabeling.h.

◆ UpsideDownLabels

Enumerator
Upright 

upside-down labels (90 <= angle < 270) are shown upright

ShowDefined 

show upside down when rotation is layer- or data-defined

ShowAll 

show upside down for all labels, including dynamic ones

Definition at line 154 of file qgspallabeling.h.

Constructor & Destructor Documentation

◆ QgsPalLayerSettings() [1/2]

QgsPalLayerSettings::QgsPalLayerSettings ( )

Definition at line 106 of file qgspallabeling.cpp.

◆ QgsPalLayerSettings() [2/2]

QgsPalLayerSettings::QgsPalLayerSettings ( const QgsPalLayerSettings s)

Definition at line 354 of file qgspallabeling.cpp.

◆ ~QgsPalLayerSettings()

QgsPalLayerSettings::~QgsPalLayerSettings ( )

Definition at line 523 of file qgspallabeling.cpp.

Member Function Documentation

◆ calculateLabelSize()

void QgsPalLayerSettings::calculateLabelSize ( const QFontMetricsF fm,
QString  text,
double &  labelX,
double &  labelY,
QgsFeature f = nullptr,
QgsRenderContext context = nullptr 
)

Definition at line 1942 of file qgspallabeling.cpp.

◆ dataDefinedEvaluate()

bool QgsPalLayerSettings::dataDefinedEvaluate ( QgsPalLayerSettings::DataDefinedProperties  p,
QVariant exprVal,
QgsExpressionContext context = nullptr,
const QVariant originalValue = QVariant() 
) const

Get data defined property value from expression string or attribute field name.

Returns
true/false whether result is null or invalid
Note
not available in python bindings

Definition at line 1875 of file qgspallabeling.cpp.

◆ dataDefinedIsActive()

bool QgsPalLayerSettings::dataDefinedIsActive ( QgsPalLayerSettings::DataDefinedProperties  p) const

Whether data definition is active.

Definition at line 1906 of file qgspallabeling.cpp.

◆ dataDefinedMap()

QMap< QString, QString > QgsPalLayerSettings::dataDefinedMap ( QgsPalLayerSettings::DataDefinedProperties  p) const

Get property value as separate values split into Qmap.

Note
not available in python bindings

Definition at line 1797 of file qgspallabeling.cpp.

◆ dataDefinedNames()

QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > QgsPalLayerSettings::dataDefinedNames ( ) const
inline

Map of data defined enum to names and old-style indecies The QPair contains a new string for layer property key, and a reference to old-style numeric key (< QGIS 2.0)

Note
not available in python bindings;

Definition at line 651 of file qgspallabeling.h.

◆ dataDefinedProperty()

QgsDataDefined * QgsPalLayerSettings::dataDefinedProperty ( QgsPalLayerSettings::DataDefinedProperties  p)

Get a data defined property pointer.

Note
helpful for Python access

Definition at line 1784 of file qgspallabeling.cpp.

◆ dataDefinedUseExpression()

bool QgsPalLayerSettings::dataDefinedUseExpression ( QgsPalLayerSettings::DataDefinedProperties  p) const

Whether data definition is set to use an expression.

Definition at line 1922 of file qgspallabeling.cpp.

◆ dataDefinedValue()

QVariant QgsPalLayerSettings::dataDefinedValue ( QgsPalLayerSettings::DataDefinedProperties  p,
QgsFeature f,
const QgsFields fields,
const QgsExpressionContext context = nullptr 
) const

Get data defined property value from expression string or attribute field name.

Returns
value inside QVariant
Note
not available in python bindings

Definition at line 1808 of file qgspallabeling.cpp.

◆ fromLayer()

QgsPalLayerSettings QgsPalLayerSettings::fromLayer ( QgsVectorLayer layer)
static
Note
added in 2.4

Definition at line 536 of file qgspallabeling.cpp.

◆ getLabelExpression()

QgsExpression * QgsPalLayerSettings::getLabelExpression ( )

Returns the QgsExpression for this label settings.

Definition at line 544 of file qgspallabeling.cpp.

◆ operator=()

QgsPalLayerSettings & QgsPalLayerSettings::operator= ( const QgsPalLayerSettings s)

copy operator - only copies the permanent members

Definition at line 369 of file qgspallabeling.cpp.

◆ readFromLayer()

void QgsPalLayerSettings::readFromLayer ( QgsVectorLayer layer)

Definition at line 791 of file qgspallabeling.cpp.

◆ readXml()

void QgsPalLayerSettings::readXml ( QDomElement elem)

Read settings from a DOM element.

Note
added in 2.12

Definition at line 1268 of file qgspallabeling.cpp.

◆ registerFeature()

void QgsPalLayerSettings::registerFeature ( QgsFeature f,
QgsRenderContext context,
QgsLabelFeature **  labelFeature = nullptr,
QgsGeometry obstacleGeometry = nullptr 
)

Register a feature for labelling.

Parameters
ffeature to label
contextrender context. The QgsExpressionContext contained within the render context must have already had the feature and fields sets prior to calling this method.
labelFeatureif using QgsLabelingEngineV2, this will receive the label feature. Not available in Python bindings.
obstacleGeometryoptional obstacle geometry, if a different geometry to the feature's geometry should be used as an obstacle for labels (eg, 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 2119 of file qgspallabeling.cpp.

◆ removeAllDataDefinedProperties()

void QgsPalLayerSettings::removeAllDataDefinedProperties ( )

Clear all data-defined properties.

Note
added in QGIS 2.12

Definition at line 1761 of file qgspallabeling.cpp.

◆ removeDataDefinedProperty()

void QgsPalLayerSettings::removeDataDefinedProperty ( QgsPalLayerSettings::DataDefinedProperties  p)

Set a property to static instead data defined.

Definition at line 1751 of file qgspallabeling.cpp.

◆ scaleToPixelContext()

double QgsPalLayerSettings::scaleToPixelContext ( double  size,
const QgsRenderContext c,
SizeUnit  unit,
bool  rasterfactor = false,
const QgsMapUnitScale mapUnitScale = QgsMapUnitScale() 
) const

Calculates size (considering output size should be in pixel or map units, scale factors and optionally oversampling)

Parameters
sizesize to convert
crendercontext
unitSizeUnit enum value of size
rasterfactorwhether to consider oversampling
mapUnitScalea mapUnitScale clamper
Returns
size that will render, as double

Definition at line 3926 of file qgspallabeling.cpp.

◆ setDataDefinedProperty()

void QgsPalLayerSettings::setDataDefinedProperty ( QgsPalLayerSettings::DataDefinedProperties  p,
bool  active,
bool  useExpr,
const QString expr,
const QString field 
)

Set a property as data defined.

Note
helpful for Python access

Definition at line 1727 of file qgspallabeling.cpp.

◆ sizeToPixel()

int QgsPalLayerSettings::sizeToPixel ( double  size,
const QgsRenderContext c,
SizeUnit  unit,
bool  rasterfactor = false,
const QgsMapUnitScale mapUnitScale = QgsMapUnitScale() 
) const

Calculates pixel size (considering output size should be in pixel or map units, scale factors and optionally oversampling)

Parameters
sizesize to convert
crendercontext
unitSizeUnit enum value of size
rasterfactorwhether to consider oversampling
mapUnitScalea mapUnitScale clamper
Returns
font pixel size

Definition at line 3921 of file qgspallabeling.cpp.

◆ updateDataDefinedString()

QString QgsPalLayerSettings::updateDataDefinedString ( const QString value)

Convert old property value to new one as delimited values.

Note
not available in python bindings; as temporary solution until refactoring of project settings

Definition at line 1767 of file qgspallabeling.cpp.

◆ writeToLayer()

void QgsPalLayerSettings::writeToLayer ( QgsVectorLayer layer)

Definition at line 1114 of file qgspallabeling.cpp.

◆ writeXml()

QDomElement QgsPalLayerSettings::writeXml ( QDomDocument doc)

Write settings into a DOM element.

Note
added in 2.12

Definition at line 1563 of file qgspallabeling.cpp.

Member Data Documentation

◆ addDirectionSymbol

bool QgsPalLayerSettings::addDirectionSymbol

Definition at line 392 of file qgspallabeling.h.

◆ angleOffset

double QgsPalLayerSettings::angleOffset

Definition at line 494 of file qgspallabeling.h.

◆ blendMode

QPainter::CompositionMode QgsPalLayerSettings::blendMode

Definition at line 375 of file qgspallabeling.h.

◆ bufferBlendMode

QPainter::CompositionMode QgsPalLayerSettings::bufferBlendMode

Definition at line 412 of file qgspallabeling.h.

◆ bufferColor

QColor QgsPalLayerSettings::bufferColor

Definition at line 408 of file qgspallabeling.h.

◆ bufferDraw

bool QgsPalLayerSettings::bufferDraw

Definition at line 404 of file qgspallabeling.h.

◆ bufferJoinStyle

Qt::PenJoinStyle QgsPalLayerSettings::bufferJoinStyle

Definition at line 411 of file qgspallabeling.h.

◆ bufferNoFill

bool QgsPalLayerSettings::bufferNoFill

Definition at line 409 of file qgspallabeling.h.

◆ bufferSize

double QgsPalLayerSettings::bufferSize

Definition at line 405 of file qgspallabeling.h.

◆ bufferSizeInMapUnits

bool QgsPalLayerSettings::bufferSizeInMapUnits

Definition at line 406 of file qgspallabeling.h.

◆ bufferSizeMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::bufferSizeMapUnitScale

Definition at line 407 of file qgspallabeling.h.

◆ bufferTransp

int QgsPalLayerSettings::bufferTransp

Definition at line 410 of file qgspallabeling.h.

◆ centroidInside

bool QgsPalLayerSettings::centroidInside

Definition at line 464 of file qgspallabeling.h.

◆ centroidWhole

bool QgsPalLayerSettings::centroidWhole

Definition at line 463 of file qgspallabeling.h.

◆ ct

const QgsCoordinateTransform* QgsPalLayerSettings::ct

Definition at line 658 of file qgspallabeling.h.

◆ dataDefinedProperties

QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* > QgsPalLayerSettings::dataDefinedProperties

Map of current data defined properties.

Pointers to QgsDataDefined should never be null, the pointers are owned by this class

Definition at line 624 of file qgspallabeling.h.

◆ decimals

int QgsPalLayerSettings::decimals

Definition at line 399 of file qgspallabeling.h.

◆ displayAll

bool QgsPalLayerSettings::displayAll

Definition at line 512 of file qgspallabeling.h.

◆ dist

double QgsPalLayerSettings::dist

Definition at line 476 of file qgspallabeling.h.

◆ distInMapUnits

bool QgsPalLayerSettings::distInMapUnits

Definition at line 477 of file qgspallabeling.h.

◆ distMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::distMapUnitScale

Definition at line 478 of file qgspallabeling.h.

◆ drawLabels

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.

Note
added in QGIS 2.12

Definition at line 355 of file qgspallabeling.h.

◆ enabled

bool QgsPalLayerSettings::enabled

Definition at line 346 of file qgspallabeling.h.

◆ extentGeom

QgsGeometry* QgsPalLayerSettings::extentGeom

Definition at line 662 of file qgspallabeling.h.

◆ fieldIndex

int QgsPalLayerSettings::fieldIndex

Definition at line 656 of file qgspallabeling.h.

◆ fieldName

QString QgsPalLayerSettings::fieldName

Definition at line 359 of file qgspallabeling.h.

◆ fitInPolygonOnly

bool QgsPalLayerSettings::fitInPolygonOnly

True if only labels which completely fit within a polygon are allowed.

Definition at line 475 of file qgspallabeling.h.

◆ fontLimitPixelSize

bool QgsPalLayerSettings::fontLimitPixelSize

Definition at line 508 of file qgspallabeling.h.

◆ fontMaxPixelSize

int QgsPalLayerSettings::fontMaxPixelSize

Definition at line 510 of file qgspallabeling.h.

◆ fontMinPixelSize

int QgsPalLayerSettings::fontMinPixelSize

Definition at line 509 of file qgspallabeling.h.

◆ fontSizeInMapUnits

bool QgsPalLayerSettings::fontSizeInMapUnits

Definition at line 371 of file qgspallabeling.h.

◆ fontSizeMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::fontSizeMapUnitScale

Definition at line 372 of file qgspallabeling.h.

◆ formatNumbers

bool QgsPalLayerSettings::formatNumbers

Definition at line 398 of file qgspallabeling.h.

◆ isExpression

bool QgsPalLayerSettings::isExpression

Is this label made from a expression string eg FieldName || 'mm'.

Definition at line 363 of file qgspallabeling.h.

◆ labelOffsetInMapUnits

bool QgsPalLayerSettings::labelOffsetInMapUnits

Definition at line 492 of file qgspallabeling.h.

◆ labelOffsetMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::labelOffsetMapUnitScale

Definition at line 493 of file qgspallabeling.h.

◆ labelPerPart

bool QgsPalLayerSettings::labelPerPart

Definition at line 515 of file qgspallabeling.h.

◆ leftDirectionSymbol

QString QgsPalLayerSettings::leftDirectionSymbol

Definition at line 393 of file qgspallabeling.h.

◆ limitNumLabels

bool QgsPalLayerSettings::limitNumLabels

Definition at line 518 of file qgspallabeling.h.

◆ maxCurvedCharAngleIn

double QgsPalLayerSettings::maxCurvedCharAngleIn

Definition at line 497 of file qgspallabeling.h.

◆ maxCurvedCharAngleOut

double QgsPalLayerSettings::maxCurvedCharAngleOut

Definition at line 498 of file qgspallabeling.h.

◆ maxNumLabels

int QgsPalLayerSettings::maxNumLabels

Definition at line 519 of file qgspallabeling.h.

◆ mCurFeat

QgsFeature* QgsPalLayerSettings::mCurFeat

Definition at line 654 of file qgspallabeling.h.

◆ mCurFields

QgsFields QgsPalLayerSettings::mCurFields

Definition at line 655 of file qgspallabeling.h.

◆ mergeLines

bool QgsPalLayerSettings::mergeLines

Definition at line 516 of file qgspallabeling.h.

◆ mFeatsRegPal

int QgsPalLayerSettings::mFeatsRegPal

Definition at line 665 of file qgspallabeling.h.

◆ mFeatsSendingToPal

int QgsPalLayerSettings::mFeatsSendingToPal

Definition at line 664 of file qgspallabeling.h.

◆ mFeaturesToLabel

int QgsPalLayerSettings::mFeaturesToLabel

Definition at line 663 of file qgspallabeling.h.

◆ minFeatureSize

double QgsPalLayerSettings::minFeatureSize

Definition at line 521 of file qgspallabeling.h.

◆ mTextFontFamily

QString QgsPalLayerSettings::mTextFontFamily

Definition at line 667 of file qgspallabeling.h.

◆ mTextFontFound

bool QgsPalLayerSettings::mTextFontFound

Definition at line 668 of file qgspallabeling.h.

◆ multilineAlign

MultiLineAlign QgsPalLayerSettings::multilineAlign

Definition at line 387 of file qgspallabeling.h.

◆ multilineHeight

double QgsPalLayerSettings::multilineHeight

Definition at line 386 of file qgspallabeling.h.

◆ obstacle

bool QgsPalLayerSettings::obstacle

Definition at line 522 of file qgspallabeling.h.

◆ obstacleFactor

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 527 of file qgspallabeling.h.

◆ obstacleType

ObstacleType QgsPalLayerSettings::obstacleType

Controls how features act as obstacles for labels.

Definition at line 531 of file qgspallabeling.h.

◆ offsetType

OffsetType QgsPalLayerSettings::offsetType

Offset type for layer (only applies in certain placement modes)

Definition at line 480 of file qgspallabeling.h.

◆ placeDirectionSymbol

DirectionSymbols QgsPalLayerSettings::placeDirectionSymbol

Definition at line 395 of file qgspallabeling.h.

◆ placement

Placement QgsPalLayerSettings::placement

Definition at line 460 of file qgspallabeling.h.

◆ placementFlags

unsigned int QgsPalLayerSettings::placementFlags

Definition at line 461 of file qgspallabeling.h.

◆ plusSign

bool QgsPalLayerSettings::plusSign

Definition at line 400 of file qgspallabeling.h.

◆ predefinedPositionOrder

QVector< PredefinedPointPosition > QgsPalLayerSettings::predefinedPositionOrder

Ordered list of predefined label positions for points.

Positions earlier in the list will be prioritised over later positions. Only used when the placement is set to QgsPalLayerSettings::OrderedPositionsAroundPoint.

Note
not available in Python bindings

Definition at line 471 of file qgspallabeling.h.

◆ preserveRotation

bool QgsPalLayerSettings::preserveRotation

Definition at line 495 of file qgspallabeling.h.

◆ previewBkgrdColor

QColor QgsPalLayerSettings::previewBkgrdColor

Definition at line 376 of file qgspallabeling.h.

◆ priority

int QgsPalLayerSettings::priority

Definition at line 500 of file qgspallabeling.h.

◆ ptOne

QgsPoint QgsPalLayerSettings::ptOne

Definition at line 661 of file qgspallabeling.h.

◆ ptZero

QgsPoint QgsPalLayerSettings::ptZero

Definition at line 660 of file qgspallabeling.h.

◆ quadOffset

QuadrantPosition QgsPalLayerSettings::quadOffset

Definition at line 488 of file qgspallabeling.h.

◆ rasterCompressFactor

double QgsPalLayerSettings::rasterCompressFactor

Definition at line 538 of file qgspallabeling.h.

◆ repeatDistance

double QgsPalLayerSettings::repeatDistance

Definition at line 482 of file qgspallabeling.h.

◆ repeatDistanceMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::repeatDistanceMapUnitScale

Definition at line 484 of file qgspallabeling.h.

◆ repeatDistanceUnit

SizeUnit QgsPalLayerSettings::repeatDistanceUnit

Definition at line 483 of file qgspallabeling.h.

◆ reverseDirectionSymbol

bool QgsPalLayerSettings::reverseDirectionSymbol

Definition at line 396 of file qgspallabeling.h.

◆ rightDirectionSymbol

QString QgsPalLayerSettings::rightDirectionSymbol

Definition at line 394 of file qgspallabeling.h.

◆ scaleMax

int QgsPalLayerSettings::scaleMax

Definition at line 506 of file qgspallabeling.h.

◆ scaleMin

int QgsPalLayerSettings::scaleMin

Definition at line 505 of file qgspallabeling.h.

◆ scaleVisibility

bool QgsPalLayerSettings::scaleVisibility

Definition at line 504 of file qgspallabeling.h.

◆ shadowBlendMode

QPainter::CompositionMode QgsPalLayerSettings::shadowBlendMode

Definition at line 456 of file qgspallabeling.h.

◆ shadowColor

QColor QgsPalLayerSettings::shadowColor

Definition at line 455 of file qgspallabeling.h.

◆ shadowDraw

bool QgsPalLayerSettings::shadowDraw

Definition at line 442 of file qgspallabeling.h.

◆ shadowOffsetAngle

int QgsPalLayerSettings::shadowOffsetAngle

Definition at line 444 of file qgspallabeling.h.

◆ shadowOffsetDist

double QgsPalLayerSettings::shadowOffsetDist

Definition at line 445 of file qgspallabeling.h.

◆ shadowOffsetGlobal

bool QgsPalLayerSettings::shadowOffsetGlobal

Definition at line 448 of file qgspallabeling.h.

◆ shadowOffsetMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::shadowOffsetMapUnitScale

Definition at line 447 of file qgspallabeling.h.

◆ shadowOffsetUnits

SizeUnit QgsPalLayerSettings::shadowOffsetUnits

Definition at line 446 of file qgspallabeling.h.

◆ shadowRadius

double QgsPalLayerSettings::shadowRadius

Definition at line 449 of file qgspallabeling.h.

◆ shadowRadiusAlphaOnly

bool QgsPalLayerSettings::shadowRadiusAlphaOnly

Definition at line 452 of file qgspallabeling.h.

◆ shadowRadiusMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::shadowRadiusMapUnitScale

Definition at line 451 of file qgspallabeling.h.

◆ shadowRadiusUnits

SizeUnit QgsPalLayerSettings::shadowRadiusUnits

Definition at line 450 of file qgspallabeling.h.

◆ shadowScale

int QgsPalLayerSettings::shadowScale

Definition at line 454 of file qgspallabeling.h.

◆ shadowTransparency

int QgsPalLayerSettings::shadowTransparency

Definition at line 453 of file qgspallabeling.h.

◆ shadowUnder

ShadowType QgsPalLayerSettings::shadowUnder

Definition at line 443 of file qgspallabeling.h.

◆ shapeBlendMode

QPainter::CompositionMode QgsPalLayerSettings::shapeBlendMode

Definition at line 432 of file qgspallabeling.h.

◆ shapeBorderColor

QColor QgsPalLayerSettings::shapeBorderColor

Definition at line 434 of file qgspallabeling.h.

◆ shapeBorderWidth

double QgsPalLayerSettings::shapeBorderWidth

Definition at line 435 of file qgspallabeling.h.

◆ shapeBorderWidthMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::shapeBorderWidthMapUnitScale

Definition at line 437 of file qgspallabeling.h.

◆ shapeBorderWidthUnits

SizeUnit QgsPalLayerSettings::shapeBorderWidthUnits

Definition at line 436 of file qgspallabeling.h.

◆ shapeDraw

bool QgsPalLayerSettings::shapeDraw

Definition at line 416 of file qgspallabeling.h.

◆ shapeFillColor

QColor QgsPalLayerSettings::shapeFillColor

Definition at line 433 of file qgspallabeling.h.

◆ shapeJoinStyle

Qt::PenJoinStyle QgsPalLayerSettings::shapeJoinStyle

Definition at line 438 of file qgspallabeling.h.

◆ shapeOffset

QPointF QgsPalLayerSettings::shapeOffset

Definition at line 425 of file qgspallabeling.h.

◆ shapeOffsetMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::shapeOffsetMapUnitScale

Definition at line 427 of file qgspallabeling.h.

◆ shapeOffsetUnits

SizeUnit QgsPalLayerSettings::shapeOffsetUnits

Definition at line 426 of file qgspallabeling.h.

◆ shapeRadii

QPointF QgsPalLayerSettings::shapeRadii

Definition at line 428 of file qgspallabeling.h.

◆ shapeRadiiMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::shapeRadiiMapUnitScale

Definition at line 430 of file qgspallabeling.h.

◆ shapeRadiiUnits

SizeUnit QgsPalLayerSettings::shapeRadiiUnits

Definition at line 429 of file qgspallabeling.h.

◆ shapeRotation

double QgsPalLayerSettings::shapeRotation

Definition at line 424 of file qgspallabeling.h.

◆ shapeRotationType

RotationType QgsPalLayerSettings::shapeRotationType

Definition at line 423 of file qgspallabeling.h.

◆ shapeSize

QPointF QgsPalLayerSettings::shapeSize

Definition at line 420 of file qgspallabeling.h.

◆ shapeSizeMapUnitScale

QgsMapUnitScale QgsPalLayerSettings::shapeSizeMapUnitScale

Definition at line 422 of file qgspallabeling.h.

◆ shapeSizeType

SizeType QgsPalLayerSettings::shapeSizeType

Definition at line 419 of file qgspallabeling.h.

◆ shapeSizeUnits

SizeUnit QgsPalLayerSettings::shapeSizeUnits

Definition at line 421 of file qgspallabeling.h.

◆ shapeSVGFile

QString QgsPalLayerSettings::shapeSVGFile

Definition at line 418 of file qgspallabeling.h.

◆ shapeTransparency

int QgsPalLayerSettings::shapeTransparency

Definition at line 431 of file qgspallabeling.h.

◆ shapeType

ShapeType QgsPalLayerSettings::shapeType

Definition at line 417 of file qgspallabeling.h.

◆ showingShadowRects

bool QgsPalLayerSettings::showingShadowRects

Definition at line 670 of file qgspallabeling.h.

◆ substitutions

QgsStringReplacementCollection QgsPalLayerSettings::substitutions

Substitution collection for automatic text substitution with labels.

Definition at line 379 of file qgspallabeling.h.

◆ textColor

QColor QgsPalLayerSettings::textColor

Definition at line 373 of file qgspallabeling.h.

◆ textFont

QFont QgsPalLayerSettings::textFont

Definition at line 369 of file qgspallabeling.h.

◆ textNamedStyle

QString QgsPalLayerSettings::textNamedStyle

Definition at line 370 of file qgspallabeling.h.

◆ textTransp

int QgsPalLayerSettings::textTransp

Definition at line 374 of file qgspallabeling.h.

◆ upsidedownLabels

UpsideDownLabels QgsPalLayerSettings::upsidedownLabels

Definition at line 513 of file qgspallabeling.h.

◆ useSubstitutions

bool QgsPalLayerSettings::useSubstitutions

True if substitutions should be applied.

Definition at line 381 of file qgspallabeling.h.

◆ vectorScaleFactor

double QgsPalLayerSettings::vectorScaleFactor

Definition at line 537 of file qgspallabeling.h.

◆ wrapChar

QString QgsPalLayerSettings::wrapChar

Definition at line 385 of file qgspallabeling.h.

◆ xform

const QgsMapToPixel* QgsPalLayerSettings::xform

Definition at line 657 of file qgspallabeling.h.

◆ xOffset

double QgsPalLayerSettings::xOffset

Definition at line 490 of file qgspallabeling.h.

◆ yOffset

double QgsPalLayerSettings::yOffset

Definition at line 491 of file qgspallabeling.h.

◆ zIndex

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 534 of file qgspallabeling.h.


The documentation for this class was generated from the following files: