QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
21 #ifndef QGSPALLABELING_H
22 #define QGSPALLABELING_H
24 #include "qgis_core.h"
28 #include <QFontDatabase>
107 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(),
111 , cornerPoints( corners )
113 , labelGeometry( labelGeometry )
117 , labelText( labeltext )
118 , labelFont( labelfont )
119 , upsideDown( upside_down )
120 , isDiagram( diagram )
122 , providerID( providerId )
123 , isUnplaced( isUnplaced )
176 bool upsideDown =
false;
181 bool isDiagram =
false;
186 bool isPinned =
false;
198 bool isUnplaced =
false;
352 FontLetterSpacing = 28,
353 FontWordSpacing = 29,
357 MultiLineWrapChar = 31,
358 AutoWrapLength = 101,
359 MultiLineHeight = 32,
360 MultiLineAlignment = 33,
361 TextOrientation = 104,
365 DirSymbPlacement = 37,
378 BufferJoinStyle = 44,
379 BufferBlendMode = 45,
383 MaskBufferSize = 105,
384 MaskBufferUnit = 106,
396 ShapeRotationType = 52,
399 ShapeOffsetUnits = 55,
401 ShapeRadiiUnits = 57,
402 ShapeTransparency = 63,
406 ShapeStrokeColor = 59,
407 ShapeStrokeWidth = 60,
408 ShapeStrokeWidthUnits = 61,
414 ShadowOffsetAngle = 67,
415 ShadowOffsetDist = 68,
416 ShadowOffsetUnits = 69,
418 ShadowRadiusUnits = 71,
419 ShadowTransparency = 72,
423 ShadowBlendMode = 75,
433 CurvedCharAngleInOut = 83,
442 RepeatDistanceUnit = 86,
444 PredefinedPositionOrder = 91,
445 LinePlacementOptions = 99,
446 OverrunDistance = 102,
448 PolygonLabelOutside = 109,
451 ScaleVisibility = 23,
522 bool drawLabels =
true;
537 bool isExpression =
false;
547 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
552 bool useSubstitutions =
false;
569 int autoWrapLength = 0;
581 bool useMaxLineLengthForAutoWrap =
true;
596 bool addDirectionSymbol =
false;
603 QString leftDirectionSymbol = QString(
'<' );
610 QString rightDirectionSymbol = QString(
'>' );
619 bool reverseDirectionSymbol =
false;
627 bool formatNumbers =
false;
641 bool plusSign =
false;
648 unsigned int placementFlags = AboveLine | MapOrientation;
650 unsigned int placementFlags;
673 bool centroidWhole =
false;
680 bool centroidInside =
false;
688 QVector< PredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
693 bool fitInPolygonOnly =
false;
724 double repeatDistance = 0;
746 double overrunDistance = 0;
802 double angleOffset = 0;
805 bool preserveRotation =
true;
811 double maxCurvedCharAngleIn = 25.0;
817 double maxCurvedCharAngleOut = -25.0;
832 bool scaleVisibility =
false;
844 double maximumScale = 0;
856 double minimumScale = 0;
863 bool fontLimitPixelSize =
false;
870 int fontMinPixelSize = 0;
877 int fontMaxPixelSize = 10000;
880 bool displayAll =
false;
889 bool labelPerPart =
false;
895 bool mergeLines =
false;
900 SIP_PROPERTY( name = limitNumLabels, get = _limitNumLabels, set = _setLimitNumLabels )
901 SIP_PROPERTY( name = maxNumLabels, get = _maxNumLabels, set = _setMaxNumLabels )
902 SIP_PROPERTY( name = minFeatureSize, get = _minFeatureSize, set = _setMinFeatureSize )
903 SIP_PROPERTY( name = obstacle, get = _getIsObstacle, set = _setIsObstacle )
904 SIP_PROPERTY( name = obstacleFactor, get = _getObstacleFactor, set = _setObstacleFactor )
905 SIP_PROPERTY( name = obstacleType, get = _getObstacleType, set = _setObstacleType )
909 bool _limitNumLabels()
const {
return mThinningSettings.limitNumberOfLabelsEnabled(); }
910 void _setLimitNumLabels(
bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
911 int _maxNumLabels()
const {
return mThinningSettings.maximumNumberLabels(); }
912 void _setMaxNumLabels(
int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
913 double _minFeatureSize()
const {
return mThinningSettings.minimumFeatureSize(); }
914 void _setMinFeatureSize(
double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
915 bool _getIsObstacle()
const {
return mObstacleSettings.isObstacle(); }
916 void _setIsObstacle(
bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
917 double _getObstacleFactor()
const {
return mObstacleSettings.factor(); }
918 void _setObstacleFactor(
double factor ) { mObstacleSettings.setFactor( factor ); }
919 ObstacleType _getObstacleType()
const {
return static_cast< ObstacleType
>( mObstacleSettings.type() ); }
934 bool geometryGeneratorEnabled =
false;
949 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,
952 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 );
1097 static QPixmap labelSettingsPreviewPixmap(
const QgsPalLayerSettings &settings, QSize size,
const QString &previewText = QString(),
int padding = 0 );
1109 int mFeaturesToLabel = 0;
1110 int mFeatsSendingToPal = 0;
1111 int mFeatsRegPal = 0;
1125 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1132 enum DataDefinedValueType
1151 bool dataDefinedValEval( DataDefinedValueType valType,
1153 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1155 void parseTextStyle( QFont &labelFont,
1179 QMap<Property, QVariant> dataDefinedValues;
1186 QFontDatabase mFontDB;
1190 std::unique_ptr< QgsCallout > mCallout;
1195 QgsLabeling::PolygonPlacementFlags mPolygonPlacementFlags = QgsLabeling::PolygonPlacementFlag::AllowPlacementInsideOfPolygon;
1199 bool mRenderStarted =
false;
1201 static void initPropertyDefinitions();
1236 QList<QgsLabelPosition> labelsAtPosition(
const QgsPointXY &p )
const;
1238 QList<QgsLabelPosition> labelsWithinRect(
const QgsRectangle &r )
const;
1251 std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1311 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1321 static QStringList splitToGraphemes(
const QString &text );
1326 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1330 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1334 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1338 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1342 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1346 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1365 #endif // QGSPALLABELING_H
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsCoordinateTransform ct
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
RenderUnit
Rendering size units.
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
QgsLabelCandidate(const QRectF &r, double c)
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
Abstract base class for callout renderers.
void setPolygonPlacementFlags(QgsLabeling::PolygonPlacementFlags flags)
Sets the polygon placement flags, which dictate how polygon labels can be placed.
const QgsCoordinateReferenceSystem & crs
LabelPosition is a candidate feature label position.
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine....
@ FromPoint
Offset distance applies from point geometry.
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
@ MiddleRight
Label on right of point.
@ TopRight
Label on top-right of point.
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
@ RenderMillimeters
Millimeters.
QFont labelFont
Font which the label is rendered using.
QgsMapUnitScale overrunDistanceMapUnitScale
Map unit scale for label overrun distance.
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
Class that adds extra information to QgsLabelFeature for text labels.
@ TopSlightlyRight
Label on top of point, slightly right of center.
@ SymbolLeftRight
Place direction symbols on left/right of label.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers....
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
LinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
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.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
@ TopMiddle
Label directly above point.
void setThinningSettings(const QgsLabelThinningSettings &settings)
Sets the label thinning settings.
QString providerID
ID of the associated label provider.
@ BottomMiddle
Label directly below point.
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Placement
Placement modes which determine how label candidates are generated for a feature.
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
@ SymbolAbove
Place direction symbols on above label.
QString wrapChar
Wrapping character string.
@ TopSlightlyLeft
Label on top of point, slightly left of center.
@ BottomSlightlyLeft
Label below point, slightly left of center.
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning settings.
Stores the settings for rendering of all diagrams for a layer.
@ Upright
Upside-down labels (90 <= angle < 270) are shown upright.
@ MiddleLeft
Label on left of point.
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode.
@ ShowDefined
Show upside down when rotation is layer- or data-defined.
Struct for storing maximum and minimum scales for measurements in map units.
QString labelText
String shown in label.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
A collection of string replacements (specified using QgsStringReplacement objects).
QString layerID
ID of associated map layer.
@ BottomSlightlyRight
Label below point, slightly right of center.
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
The QgsLabelingEngine class provides map labeling functionality. The input for the engine is a list o...
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
@ TopLeft
Label on top-left of point.
QString fieldName
Name of field (or an expression) to use for label text.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
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
QString geometryGenerator
The geometry generator expression. Null if disabled.
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only....
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
@ BottomRight
Label on bottom right of point.
#define SIP_PROPERTY(name, getter, setter)
QgsGeometry labelGeometry
A polygon geometry representing the label's bounds in map coordinates.
Property
Data definable properties.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
The QgsLabelFeature class describes a feature that should be used within the labeling engine....
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
QgsLabeling::PolygonPlacementFlags polygonPlacementFlags() const
Returns the polygon placement flags, which dictate how polygon labels can be placed.
QVector< QgsPointXY > cornerPoints
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings.
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
@ BottomLeft
Label on bottom-left of point.