21 #ifndef QGSPALLABELING_H 22 #define QGSPALLABELING_H 24 #include "qgis_core.h" 28 #include <QFontDatabase> 104 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(),
108 , cornerPoints( corners )
110 , labelGeometry( labelGeometry )
114 , labelText( labeltext )
115 , labelFont( labelfont )
116 , upsideDown( upside_down )
117 , isDiagram( diagram )
119 , providerID( providerId )
120 , isUnplaced( isUnplaced )
173 bool upsideDown =
false;
178 bool isDiagram =
false;
183 bool isPinned =
false;
195 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,
379 MaskBufferSize = 105,
380 MaskBufferUnit = 106,
392 ShapeRotationType = 52,
395 ShapeOffsetUnits = 55,
397 ShapeRadiiUnits = 57,
398 ShapeTransparency = 63,
402 ShapeStrokeColor = 59,
403 ShapeStrokeWidth = 60,
404 ShapeStrokeWidthUnits = 61,
410 ShadowOffsetAngle = 67,
411 ShadowOffsetDist = 68,
412 ShadowOffsetUnits = 69,
414 ShadowRadiusUnits = 71,
415 ShadowTransparency = 72,
419 ShadowBlendMode = 75,
429 CurvedCharAngleInOut = 83,
438 RepeatDistanceUnit = 86,
440 PredefinedPositionOrder = 91,
441 LinePlacementOptions = 99,
442 OverrunDistance = 102,
446 ScaleVisibility = 23,
511 bool drawLabels =
true;
526 bool isExpression =
false;
536 Q_DECL_DEPRECATED QColor previewBkgrdColor = Qt::white;
541 bool useSubstitutions =
false;
558 int autoWrapLength = 0;
570 bool useMaxLineLengthForAutoWrap =
true;
585 bool addDirectionSymbol =
false;
592 QString leftDirectionSymbol = QString(
'<' );
599 QString rightDirectionSymbol = QString(
'>' );
608 bool reverseDirectionSymbol =
false;
616 bool formatNumbers =
false;
630 bool plusSign =
false;
637 unsigned int placementFlags = AboveLine | MapOrientation;
639 unsigned int placementFlags;
646 bool centroidWhole =
false;
653 bool centroidInside =
false;
661 QVector< PredefinedPointPosition > predefinedPositionOrder
SIP_SKIP;
666 bool fitInPolygonOnly =
false;
697 double repeatDistance = 0;
719 double overrunDistance = 0;
775 double angleOffset = 0;
778 bool preserveRotation =
true;
784 double maxCurvedCharAngleIn = 25.0;
790 double maxCurvedCharAngleOut = -25.0;
805 bool scaleVisibility =
false;
817 double maximumScale = 0;
829 double minimumScale = 0;
836 bool fontLimitPixelSize =
false;
843 int fontMinPixelSize = 0;
850 int fontMaxPixelSize = 10000;
853 bool displayAll =
false;
862 bool labelPerPart =
false;
868 bool mergeLines =
false;
873 SIP_PROPERTY( name = limitNumLabels,
get = _limitNumLabels,
set = _setLimitNumLabels )
874 SIP_PROPERTY( name = maxNumLabels,
get = _maxNumLabels,
set = _setMaxNumLabels )
875 SIP_PROPERTY( name = minFeatureSize,
get = _minFeatureSize,
set = _setMinFeatureSize )
876 SIP_PROPERTY( name = obstacle,
get = _getIsObstacle,
set = _setIsObstacle )
877 SIP_PROPERTY( name = obstacleFactor,
get = _getObstacleFactor,
set = _setObstacleFactor )
878 SIP_PROPERTY( name = obstacleType,
get = _getObstacleType,
set = _setObstacleType )
882 bool _limitNumLabels()
const {
return mThinningSettings.limitNumberOfLabelsEnabled(); }
883 void _setLimitNumLabels(
bool limit ) { mThinningSettings.setLimitNumberLabelsEnabled( limit ); }
884 int _maxNumLabels()
const {
return mThinningSettings.maximumNumberLabels(); }
885 void _setMaxNumLabels(
int max ) { mThinningSettings.setMaximumNumberLabels( max ); }
886 double _minFeatureSize()
const {
return mThinningSettings.minimumFeatureSize(); }
887 void _setMinFeatureSize(
double size ) { mThinningSettings.setMinimumFeatureSize( size ); }
888 bool _getIsObstacle()
const {
return mObstacleSettings.isObstacle(); }
889 void _setIsObstacle(
bool obstacle ) { mObstacleSettings.setIsObstacle( obstacle ); }
890 double _getObstacleFactor()
const {
return mObstacleSettings.factor(); }
891 void _setObstacleFactor(
double factor ) { mObstacleSettings.setFactor( factor ); }
893 void _setObstacleType(
ObstacleType type ) { mObstacleSettings.setType( static_cast< QgsLabelObstacleSettings::ObstacleType>( type ) ); }
907 bool geometryGeneratorEnabled =
false;
921 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 );
1065 static QPixmap labelSettingsPreviewPixmap(
const QgsPalLayerSettings &settings, QSize size,
const QString &previewText = QString(),
int padding = 0 );
1077 int mFeaturesToLabel = 0;
1078 int mFeatsSendingToPal = 0;
1079 int mFeatsRegPal = 0;
1093 void readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem );
1100 enum DataDefinedValueType
1119 bool dataDefinedValEval( DataDefinedValueType valType,
1121 QVariant &exprVal,
QgsExpressionContext &context,
const QVariant &originalValue = QVariant() );
1123 void parseTextStyle( QFont &labelFont,
1147 QMap<Property, QVariant> dataDefinedValues;
1154 QFontDatabase mFontDB;
1158 std::unique_ptr< QgsCallout > mCallout;
1165 bool mRenderStarted =
false;
1167 static void initPropertyDefinitions();
1202 QList<QgsLabelPosition> labelsAtPosition(
const QgsPointXY &p )
const;
1204 QList<QgsLabelPosition> labelsWithinRect(
const QgsRectangle &r )
const;
1217 std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
1277 static QStringList splitToLines(
const QString &text,
const QString &wrapCharacter,
int autoWrapLength = 0,
bool useMaxLineLengthWhenAutoWrapping =
true );
1287 static QStringList splitToGraphemes(
const QString &text );
1292 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1296 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1300 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1304 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1308 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1312 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues );
1331 #endif // QGSPALLABELING_H Label on bottom right of point.
Class for parsing and evaluation of expressions (formerly called "search strings").
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.
Abstract base class for callout renderers.
#define SIP_PROPERTY(name, getter, setter)
Label on top of point, slightly left of center.
void setThinningSettings(const QgsLabelThinningSettings &settings)
Sets the label thinning settings.
QgsMapUnitScale overrunDistanceMapUnitScale
Map unit scale for label overrun distance.
Abstract base class for all rendered symbols.
A class to query the labeling structure at a given point (small wrapper around pal RTree class) ...
Label on top-left of point.
Contains settings related to how the label engine removes candidate label positions and reduces the n...
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.
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
Class that adds extra information to QgsLabelFeature for text labels.
QgsLabelObstacleSettings & obstacleSettings()
Returns the label obstacle settings.
Container of fields for a vector layer.
Label on top-right of point.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
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.
QgsCoordinateTransform ct
Contains settings related to how the label engine treats features as obstacles.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
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.
QgsLabelThinningSettings & thinningSettings()
Returns the label thinning settings.
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.
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the label's property collection, used for data defined overrides.
Offset distance applies from point geometry.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
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.
void setObstacleSettings(const QgsLabelObstacleSettings &settings)
Sets the label obstacle settings.
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.
Place direction symbols on above label.
Stores the settings for rendering of all diagrams for a layer.
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. ...
The QgsLabelingEngine class provides map labeling functionality.
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
Contains information about the context of a rendering operation.
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.
A collection of string replacements (specified using QgsStringReplacement objects).
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
Label on top of point, slightly right of center.
const QgsLabelThinningSettings & thinningSettings() const
Returns the label thinning settings.
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.
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
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.
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...
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.
QString fieldName
Name of field (or an expression) to use for label text.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...