21 #ifndef QGSPALLABELING_H 22 #define QGSPALLABELING_H 24 #include "qgis_core.h" 28 #include <QFontDatabase> 102 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(),
106 , cornerPoints( corners )
108 , labelGeometry( labelGeometry )
112 , labelText( labeltext )
113 , labelFont( labelfont )
114 , upsideDown( upside_down )
115 , isDiagram( diagram )
117 , providerID( providerId )
118 , isUnplaced( isUnplaced )
171 bool upsideDown =
false;
176 bool isDiagram =
false;
181 bool isPinned =
false;
193 bool isUnplaced =
false;
348 FontLetterSpacing = 28,
349 FontWordSpacing = 29,
353 MultiLineWrapChar = 31,
354 AutoWrapLength = 101,
355 MultiLineHeight = 32,
356 MultiLineAlignment = 33,
357 TextOrientation = 104,
361 DirSymbPlacement = 37,
374 BufferJoinStyle = 44,
375 BufferBlendMode = 45,
385 ShapeRotationType = 52,
388 ShapeOffsetUnits = 55,
390 ShapeRadiiUnits = 57,
391 ShapeTransparency = 63,
395 ShapeStrokeColor = 59,
396 ShapeStrokeWidth = 60,
397 ShapeStrokeWidthUnits = 61,
403 ShadowOffsetAngle = 67,
404 ShadowOffsetDist = 68,
405 ShadowOffsetUnits = 69,
407 ShadowRadiusUnits = 71,
408 ShadowTransparency = 72,
412 ShadowBlendMode = 75,
422 CurvedCharAngleInOut = 83,
431 RepeatDistanceUnit = 86,
433 PredefinedPositionOrder = 91,
434 LinePlacementOptions = 99,
435 OverrunDistance = 102,
439 ScaleVisibility = 23,
529 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
551 int autoWrapLength = 0;
563 bool useMaxLineLengthForAutoWrap =
true;
649 QVector< PredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
707 double overrunDistance = 0;
908 bool geometryGeneratorEnabled =
false;
922 void calculateLabelSize(
const QFontMetricsF *fm,
const QString &text,
double &labelX,
double &labelY,
const QgsFeature *f =
nullptr,
QgsRenderContext *context =
nullptr,
double *rotatedLabelX
SIP_OUT =
nullptr,
double *rotatedLabelY
SIP_OUT =
nullptr );
1022 static QPixmap labelSettingsPreviewPixmap(
const QgsPalLayerSettings &settings, QSize size,
const QString &previewText = QString(),
int padding = 0 );
1034 int mFeaturesToLabel = 0;
1035 int mFeatsSendingToPal = 0;
1036 int mFeatsRegPal = 0;
1050 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1057 enum DataDefinedValueType
1076 bool dataDefinedValEval( DataDefinedValueType valType,
1078 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1080 void parseTextStyle( QFont &labelFont,
1102 QMap<Property, QVariant> dataDefinedValues;
1109 QFontDatabase mFontDB;
1113 std::unique_ptr< QgsCallout > mCallout;
1117 bool mRenderStarted =
false;
1119 static const QVector< PredefinedPointPosition > DEFAULT_PLACEMENT_ORDER;
1121 static void initPropertyDefinitions();
1160 QList<QgsLabelPosition> labelsAtPosition(
const QgsPointXY &p )
const;
1162 QList<QgsLabelPosition> labelsWithinRect(
const QgsRectangle &r )
const;
1175 std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1235 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1245 static QStringList splitToGraphemes(
const QString &text );
1250 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1254 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1258 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1262 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1266 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1284 #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.
Abstract base class for callout renderers.
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.
QgsMapUnitScale overrunDistanceMapUnitScale
Map unit scale for label overrun distance.
Abstract base class for all rendered symbols.
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.
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.
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
bool isExpression
true if this label is made from a expression string, e.g., FieldName || 'mm'
Class that stores computed placement from labeling engine.
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(), bool isUnplaced=false)
Constructor for QgsLabelPosition.
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...