21 #ifndef QGSPALLABELING_H 22 #define QGSPALLABELING_H 24 #include "qgis_core.h" 28 #include <QFontDatabase> 100 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(),
104 , cornerPoints( corners )
106 , labelGeometry( labelGeometry )
110 , labelText( labeltext )
111 , labelFont( labelfont )
112 , upsideDown( upside_down )
113 , isDiagram( diagram )
115 , providerID( providerId )
168 bool upsideDown =
false;
173 bool isDiagram =
false;
178 bool isPinned =
false;
339 FontLetterSpacing = 28,
340 FontWordSpacing = 29,
344 MultiLineWrapChar = 31,
345 AutoWrapLength = 101,
346 MultiLineHeight = 32,
347 MultiLineAlignment = 33,
351 DirSymbPlacement = 37,
364 BufferJoinStyle = 44,
365 BufferBlendMode = 45,
375 ShapeRotationType = 52,
378 ShapeOffsetUnits = 55,
380 ShapeRadiiUnits = 57,
381 ShapeTransparency = 63,
385 ShapeStrokeColor = 59,
386 ShapeStrokeWidth = 60,
387 ShapeStrokeWidthUnits = 61,
393 ShadowOffsetAngle = 67,
394 ShadowOffsetDist = 68,
395 ShadowOffsetUnits = 69,
397 ShadowRadiusUnits = 71,
398 ShadowTransparency = 72,
402 ShadowBlendMode = 75,
412 CurvedCharAngleInOut = 83,
421 RepeatDistanceUnit = 86,
423 PredefinedPositionOrder = 91,
424 LinePlacementOptions = 99,
427 ScaleVisibility = 23,
516 int autoWrapLength = 0;
528 bool useMaxLineLengthForAutoWrap =
true;
614 QVector< PredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
849 bool geometryGeneratorEnabled =
false;
855 void calculateLabelSize(
const QFontMetricsF *fm,
const QString &text,
double &labelX,
double &labelY,
const QgsFeature *f =
nullptr,
QgsRenderContext *context =
nullptr );
936 int mFeaturesToLabel = 0;
937 int mFeatsSendingToPal = 0;
938 int mFeatsRegPal = 0;
952 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
959 enum DataDefinedValueType
978 bool dataDefinedValEval( DataDefinedValueType valType,
982 void parseTextStyle( QFont &labelFont,
1004 QMap<Property, QVariant> dataDefinedValues;
1011 QFontDatabase mFontDB;
1017 static const QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
1019 static void initPropertyDefinitions();
1058 QList<QgsLabelPosition> labelsAtPosition(
const QgsPointXY &p )
const;
1060 QList<QgsLabelPosition> labelsWithinRect(
const QgsRectangle &r )
const;
1073 std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1133 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1143 static QStringList splitToGraphemes(
const QString &text );
1148 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1152 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1156 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1160 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1164 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1182 #endif // QGSPALLABELING_H Label on bottom right of point.
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 geometryGenerator
The geometry generator expression. Null if disabled.
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) ...
double maximumScale
The maximum map scale (i.e.
QString leftDirectionSymbol
String to use for left direction arrows.
Label on top of point, slightly left of center.
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)
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
Arranges candidates following the curvature of a line feature. Applies to line layers only...
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-right of point.
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.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsCoordinateReferenceSystem & crs
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 horizontal candidates scattered throughout a polygon feature. Applies to polygon 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.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
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...
Label below point, slightly right of center.
Offset distance applies from rendered symbol bounds.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
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.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
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 parallel to a generalised line representing the feature or parallel to a polygon'...
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...
Label below point, slightly left of center.
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.
Label on top of point, slightly right of center.
bool useSubstitutions
True if substitutions should be applied.
This class represents a coordinate reference system (CRS).
Label directly below point.
QFont labelFont
Font which the label is rendered using.
LabelPosition is a candidate feature label position.
Label directly above point.
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.
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only...
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...