QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgstextrendererutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextrendererutils.h
3 -----------------
4 begin : May 2020
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSTEXTRENDERERUTILS_H
17#define QGSTEXTRENDERERUTILS_H
18
19#include "qgis_sip.h"
20#include "qgis_core.h"
23#include "qgstextmetrics.h"
24
31class CORE_EXPORT QgsTextRendererUtils
32{
33 public:
34
38 static QgsTextBackgroundSettings::ShapeType decodeShapeType( const QString &string );
39
43 static QgsTextBackgroundSettings::SizeType decodeBackgroundSizeType( const QString &string );
44
48 static QgsTextBackgroundSettings::RotationType decodeBackgroundRotationType( const QString &string );
49
53 static QgsTextShadowSettings::ShadowPlacement decodeShadowPlacementType( const QString &string );
54
60 static QString encodeTextOrientation( Qgis::TextOrientation orientation );
61
69 static Qgis::TextOrientation decodeTextOrientation( const QString &name, bool *ok = nullptr );
70
77 static QgsUnitTypes::RenderUnit convertFromOldLabelUnit( int val ) SIP_SKIP;
78
85 static QColor readColor( QgsVectorLayer *layer, const QString &property, const QColor &defaultColor = Qt::black, bool withAlpha = true ) SIP_SKIP;
86
87#ifndef SIP_RUN
88
97 {
98 public:
99
101 double x = 0;
103 double y = 0;
105 double width = 0;
107 double height = 0;
109 double angle = 0;
111 int graphemeIndex = 0;
112 };
113
122 {
123 public:
124
126 QVector< QgsTextRendererUtils::CurvedGraphemePlacement > graphemePlacement;
128 int upsideDownCharCount = 0;
130 bool labeledLineSegmentIsRightToLeft = false;
132 bool flippedCharacterPlacementToGetUprightLabels = false;
133 };
134
139 {
141 FollowLineDirection
142 };
143
144#if 0
145 // TODO - refine API when used. We probably want to use QPolygonF here instead of QgsLineString!
146 static CurvePlacementProperties *generateCurvedTextPlacement( const QgsPrecalculatedTextMetrics &metrics, const QgsLineString *line, double offsetAlongLine, LabelLineDirection direction = RespectPainterOrientation, double maxConcaveAngle = -1, double maxConvexAngle = -1, bool uprightOnly = true ) SIP_FACTORY;
147#endif
148
166 static CurvePlacementProperties *generateCurvedTextPlacement( const QgsPrecalculatedTextMetrics &metrics, const double *x, const double *y, int numPoints, const std::vector< double> &pathDistances, double offsetAlongLine, LabelLineDirection direction = RespectPainterOrientation, double maxConcaveAngle = -1, double maxConvexAngle = -1, bool uprightOnly = true ) SIP_SKIP;
167#endif
168
169 private:
170
171 static CurvePlacementProperties *generateCurvedTextPlacementPrivate( const QgsPrecalculatedTextMetrics &metrics, const double *x, const double *y, int numPoints, const std::vector< double> &pathDistances, double offsetAlongLine, LabelLineDirection direction, double maxConcaveAngle = -1, double maxConvexAngle = -1, bool uprightOnly = true, bool isSecondAttempt = false ) SIP_SKIP;
172
174 static bool nextCharPosition( double charWidth, double segmentLength, const double *x, const double *y, int numPoints, int &index, double &currentDistanceAlongSegment,
175 double &characterStartX, double &characterStartY, double &characterEndX, double &characterEndY );
176
177 static void findLineCircleIntersection( double cx, double cy, double radius,
178 double x1, double y1, double x2, double y2,
179 double &xRes, double &yRes );
180};
181
182
183#endif // QGSTEXTRENDERERUTILS_H
TextOrientation
Text orientations.
Definition: qgis.h:1430
Line string geometry type, with support for z-dimension and m-values.
Definition: qgslinestring.h:45
Contains precalculated properties regarding text metrics for text to be renderered at a later stage.
SizeType
Methods for determining the background shape size.
ShapeType
Background shape types.
RotationType
Methods for determining the rotation of the background shape.
Contains placement information for a curved text layout.
QVector< QgsTextRendererUtils::CurvedGraphemePlacement > graphemePlacement
Placement information for all graphemes in text.
Contains placement information for a single grapheme in a curved text layout.
Utility functions for text rendering.
LabelLineDirection
Controls behavior of curved text with respect to line directions.
@ RespectPainterOrientation
Curved text will be placed respecting the painter orientation, and the actual line direction will be ...
ShadowPlacement
Placement positions for text shadow.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
Represents a vector layer which manages a vector based data sets.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76