21 #ifndef QGSPALLABELING_H 22 #define QGSPALLABELING_H 24 #include "qgis_core.h" 29 #include <QFontDatabase> 101 QgsLabelPosition(
QgsFeatureId id,
double r,
const QVector< QgsPointXY > &corners,
const QgsRectangle &rect,
double w,
double h,
const QString &layer,
const QString &labeltext,
const QFont &labelfont,
bool upside_down,
bool diagram =
false,
bool pinned =
false,
const QString &providerId = QString(),
105 , cornerPoints( corners )
107 , labelGeometry( labelGeometry )
111 , labelText( labeltext )
112 , labelFont( labelfont )
113 , upsideDown( upside_down )
114 , isDiagram( diagram )
116 , providerID( providerId )
169 bool upsideDown =
false;
174 bool isDiagram =
false;
179 bool isPinned =
false;
336 FontLetterSpacing = 28,
337 FontWordSpacing = 29,
341 MultiLineWrapChar = 31,
342 AutoWrapLength = 101,
343 MultiLineHeight = 32,
344 MultiLineAlignment = 33,
348 DirSymbPlacement = 37,
361 BufferJoinStyle = 44,
362 BufferBlendMode = 45,
372 ShapeRotationType = 52,
375 ShapeOffsetUnits = 55,
377 ShapeRadiiUnits = 57,
378 ShapeTransparency = 63,
382 ShapeStrokeColor = 59,
383 ShapeStrokeWidth = 60,
384 ShapeStrokeWidthUnits = 61,
390 ShadowOffsetAngle = 67,
391 ShadowOffsetDist = 68,
392 ShadowOffsetUnits = 69,
394 ShadowRadiusUnits = 71,
395 ShadowTransparency = 72,
399 ShadowBlendMode = 75,
409 CurvedCharAngleInOut = 83,
418 RepeatDistanceUnit = 86,
420 PredefinedPositionOrder = 91,
421 LinePlacementOptions = 99,
424 ScaleVisibility = 23,
499 int autoWrapLength = 0;
511 bool useMaxLineLengthForAutoWrap =
true;
597 QVector< PredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
826 void calculateLabelSize(
const QFontMetricsF *fm, QString text,
double &labelX,
double &labelY,
QgsFeature *f =
nullptr,
QgsRenderContext *context =
nullptr );
907 int mFeaturesToLabel = 0;
908 int mFeatsSendingToPal = 0;
909 int mFeatsRegPal = 0;
924 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
931 enum DataDefinedValueType
950 bool dataDefinedValEval( DataDefinedValueType valType,
954 void parseTextStyle( QFont &labelFont,
976 QMap<Property, QVariant> dataDefinedValues;
983 QFontDatabase mFontDB;
987 static const QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
989 static void initPropertyDefinitions();
1028 QList<QgsLabelPosition> labelsAtPosition(
const QgsPointXY &p )
const;
1030 QList<QgsLabelPosition> labelsWithinRect(
const QgsRectangle &r )
const;
1043 std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1103 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1113 static QStringList splitToGraphemes(
const QString &text );
1118 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1122 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1126 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1130 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1134 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1152 #endif // QGSPALLABELING_H Label below point, slightly right of center.
Class for parsing and evaluation of expressions (formerly called "search strings").
double xOffset
Horizontal offset of label.
The class is used as a container of context for various read/write operations on other objects...
QString labelText
String shown in label.
A rectangle specified with double values.
Label on bottom-left of point.
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0) ...
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
double maximumScale
The maximum map scale (i.e.
QString leftDirectionSymbol
String to use for left direction arrows.
QgsUnitTypes::RenderUnit repeatDistanceUnit
Units for repeating labels for a single feature.
double angleOffset
Label rotation, in degrees clockwise.
bool formatNumbers
Set to true to format numeric label text as numbers (e.g.
A class to query the labeling structure at a given point (small wrapper around pal RTree class) ...
double obstacleFactor
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, 1.0 less likely to be covered
Label on top-left of point.
QgsLabelCandidate(const QRectF &r, double c)
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode...
A class to represent a 2D point.
QString layerID
ID of associated map layer.
bool obstacle
True if features for layer are obstacles to labels of other layers.
int decimals
Number of decimal places to show for numeric labels.
double repeatDistance
Distance for repeating labels for a single feature.
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
QuadrantPosition quadOffset
Sets the quadrant in which to offset labels from feature.
QgsUnitTypes::RenderUnit offsetUnits
Units for offsets of label.
double yOffset
Vertical offset of label.
Class that adds extra information to QgsLabelFeature for text labels.
Container of fields for a vector layer.
Label on top of point, slightly right of center.
bool addDirectionSymbol
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be ...
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
bool drawLabels
Whether to draw labels for this layer.
bool mergeLines
True if connected line features with identical label text should be merged prior to generating label ...
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsGeometry labelGeometry
A polygon geometry representing the label's bounds in map coordinates.
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
QgsCoordinateTransform ct
bool reverseDirectionSymbol
True if direction symbols should be reversed.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
Arranges candidates following the curvature of a line feature. Applies to line layers only...
The QgsMapSettings class contains configuration for rendering of the map.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Place direction symbols on left/right of label.
Perform transforms between map coordinates and device coordinates.
Property
Data definable properties.
ObstacleType obstacleType
Controls how features act as obstacles for labels.
bool displayAll
If true, all features will be labelled even when overlaps occur.
Offset distance applies from point geometry.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
int fontMaxPixelSize
Maximum pixel size for showing rendered map unit labels (1 - 10000).
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QVector< QgsPointXY > cornerPoints
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
Upside-down labels (90 <= angle < 270) are shown upright.
QgsLabelPosition(QgsFeatureId id, double r, const QVector< QgsPointXY > &corners, const QgsRectangle &rect, double w, double h, const QString &layer, const QString &labeltext, const QFont &labelfont, bool upside_down, bool diagram=false, bool pinned=false, const QString &providerId=QString(), const QgsGeometry &labelGeometry=QgsGeometry())
Constructor for QgsLabelPosition.
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes...
Offset distance applies from rendered symbol bounds.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
int maxNumLabels
The maximum number of labels which should be drawn for this layer.
Place direction symbols on above label.
Stores the settings for rendering of all diagrams for a layer.
bool plusSign
Whether '+' signs should be prepended to positive numeric labels.
unsigned int placementFlags
QString wrapChar
Wrapping character string.
Placement
Placement modes which determine how label candidates are generated for a feature. ...
QString rightDirectionSymbol
String to use for right direction arrows.
The QgsLabelingEngine class provides map labeling functionality.
bool preserveRotation
True if label rotation should be preserved during label pin/unpin operations.
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
Contains information about the context of a rendering operation.
bool centroidWhole
True if feature centroid should be calculated from the whole feature, or false if only the visible pa...
bool scaleVisibility
Set to true to limit label visibility to a range of scales.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
Struct for storing maximum and minimum scales for measurements in map units.
bool fitInPolygonOnly
True if only labels which completely fit within a polygon are allowed.
A collection of string replacements (specified using QgsStringReplacement objects).
OffsetType offsetType
Offset type for layer (only applies in certain placement modes)
double dist
Distance from feature to the label.
bool useSubstitutions
True if substitutions should be applied.
Label below point, slightly left of center.
QFont labelFont
Font which the label is rendered using.
LabelPosition is a candidate feature label position.
Label on top of point, slightly left of center.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
bool limitNumLabels
True if the number of labels drawn should be limited.
bool isExpression
True if this label is made from a expression string, e.g., FieldName || 'mm'.
Class that stores computed placement from labeling engine.
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
Show upside down when rotation is layer- or data-defined.
QString providerID
ID of the associated label provider.
Container for all settings relating to text rendering.
bool centroidInside
True if centroid positioned labels must be placed inside their corresponding feature polygon...
Represents a vector layer which manages a vector based data sets.
double minFeatureSize
Minimum feature size (in millimeters) for a feature to be labelled.
int fontMinPixelSize
Minimum pixel size for showing rendered map unit labels (1 - 1000).
int priority
Label priority.
bool labelPerPart
True if every part of a multi-part feature should be labeled.
QgsUnitTypes::RenderUnit distUnits
Units the distance from feature to the label.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
RenderUnit
Rendering size units.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
double minimumScale
The minimum map scale (i.e.
QString fieldName
Name of field (or an expression) to use for label text.
bool fontLimitPixelSize
True if label sizes should be limited by pixel size.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol
Placement option for direction symbols.
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...