QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgstextrenderer_p.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstextrenderer.h
3 -----------------
4 begin : September 2015
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSTEXTRENDERER_PRIVATE_H
18#define QGSTEXTRENDERER_PRIVATE_H
19
20#define SIP_NO_FILE
21
22#include "qgis_core.h"
25#include "qgsmapunitscale.h"
26#include "qgis.h"
27#include "qgspainteffect.h"
29#include "qgsstringutils.h"
30#include "qgsmarkersymbol.h"
31#include "qgsfillsymbol.h"
33
34#include <QSharedData>
35#include <QPainter>
36
38
39//
40// W A R N I N G
41// -------------
42//
43// This file is not part of the QGIS API. It exists purely as an
44// implementation detail. This header file may change from version to
45// version without notice, or even be removed.
46//
47
48
49class QgsTextBufferSettingsPrivate : public QSharedData
50{
51 public:
52
53 QgsTextBufferSettingsPrivate()
54 : color( Qt::white )
55 {
56 }
57
58 QgsTextBufferSettingsPrivate( const QgsTextBufferSettingsPrivate &other )
59 : QSharedData( other )
60 , enabled( other.enabled )
61 , size( other.size )
62 , sizeUnit( other.sizeUnit )
63 , sizeMapUnitScale( other.sizeMapUnitScale )
64 , color( other.color )
65 , opacity( other.opacity )
66 , fillBufferInterior( other.fillBufferInterior )
67 , joinStyle( other.joinStyle )
68 , blendMode( other.blendMode )
69 , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
70 {
71 }
72
73 bool enabled = false;
74 double size = 1;
75 Qgis::RenderUnit sizeUnit = Qgis::RenderUnit::Millimeters;
76 QgsMapUnitScale sizeMapUnitScale;
77 QColor color;
78 double opacity = 1.0;
79 bool fillBufferInterior = false;
80 Qt::PenJoinStyle joinStyle = Qt::RoundJoin;
81 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
82 std::unique_ptr< QgsPaintEffect > paintEffect;
83
84 private:
85 QgsTextBufferSettingsPrivate &operator=( const QgsTextBufferSettingsPrivate & ) = delete;
86};
87
88
89class QgsTextBackgroundSettingsPrivate : public QSharedData
90{
91 public:
92
93 QgsTextBackgroundSettingsPrivate()
94 : size( QSizeF( 0.0, 0.0 ) )
95 , offset( QPointF( 0.0, 0.0 ) )
96 , radii( QSizeF( 0.0, 0.0 ) )
97 , fillColor( Qt::white )
98 , strokeColor( Qt::darkGray )
99 {
100 }
101
102 QgsTextBackgroundSettingsPrivate( const QgsTextBackgroundSettingsPrivate &other )
103 : QSharedData( other )
104 , enabled( other.enabled )
105 , type( other.type )
106 , svgFile( other.svgFile )
107 , sizeType( other.sizeType )
108 , size( other.size )
109 , sizeUnits( other.sizeUnits )
110 , sizeMapUnitScale( other.sizeMapUnitScale )
111 , rotationType( other.rotationType )
112 , rotation( other.rotation )
113 , offset( other.offset )
114 , offsetUnits( other.offsetUnits )
115 , offsetMapUnitScale( other.offsetMapUnitScale )
116 , radii( other.radii )
117 , radiiUnits( other.radiiUnits )
118 , radiiMapUnitScale( other.radiiMapUnitScale )
119 , blendMode( other.blendMode )
120 , fillColor( other.fillColor )
121 , strokeColor( other.strokeColor )
122 , opacity( other.opacity )
123 , strokeWidth( other.strokeWidth )
124 , strokeWidthUnits( other.strokeWidthUnits )
125 , strokeWidthMapUnitScale( other.strokeWidthMapUnitScale )
126 , joinStyle( other.joinStyle )
127 , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
128 , markerSymbol( other.markerSymbol ? other.markerSymbol->clone() : nullptr )
129 , fillSymbol( other.fillSymbol ? other.fillSymbol->clone() : nullptr )
130 {
131 }
132
133 bool enabled = false;
135 QString svgFile;
137 QSizeF size;
138 Qgis::RenderUnit sizeUnits = Qgis::RenderUnit::Millimeters;
139 QgsMapUnitScale sizeMapUnitScale;
141 double rotation = 0.0;
142 QPointF offset;
143 Qgis::RenderUnit offsetUnits = Qgis::RenderUnit::Millimeters;
144 QgsMapUnitScale offsetMapUnitScale;
145 QSizeF radii;
146 Qgis::RenderUnit radiiUnits = Qgis::RenderUnit::Millimeters;
147 QgsMapUnitScale radiiMapUnitScale;
148 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
149 QColor fillColor;
150 QColor strokeColor;
151 double opacity = 1.0;
152 double strokeWidth = 0.0;
153 Qgis::RenderUnit strokeWidthUnits = Qgis::RenderUnit::Millimeters;
154 QgsMapUnitScale strokeWidthMapUnitScale;
155 Qt::PenJoinStyle joinStyle = Qt::BevelJoin;
156 std::unique_ptr< QgsPaintEffect > paintEffect;
157 std::unique_ptr< QgsMarkerSymbol > markerSymbol;
158 std::unique_ptr< QgsFillSymbol > fillSymbol;
159
160 private:
161 QgsTextBackgroundSettingsPrivate &operator=( const QgsTextBackgroundSettingsPrivate & ) = delete;
162};
163
164
165
166class QgsTextShadowSettingsPrivate : public QSharedData
167{
168 public:
169
170 QgsTextShadowSettingsPrivate()
171 : color( QColor( 0, 0, 0 ) )
172 {
173
174 }
175
176 QgsTextShadowSettingsPrivate( const QgsTextShadowSettingsPrivate &other )
177 : QSharedData( other )
178 , enabled( other.enabled )
179 , shadowUnder( other.shadowUnder )
180 , offsetAngle( other.offsetAngle )
181 , offsetDist( other.offsetDist )
182 , offsetUnits( other.offsetUnits )
183 , offsetMapUnitScale( other.offsetMapUnitScale )
184 , offsetGlobal( other.offsetGlobal )
185 , radius( other.radius )
186 , radiusUnits( other.radiusUnits )
187 , radiusMapUnitScale( other.radiusMapUnitScale )
188 , radiusAlphaOnly( other.radiusAlphaOnly )
189 , scale( other.scale )
190 , color( other.color )
191 , opacity( other.opacity )
192 , blendMode( other.blendMode )
193 {
194 }
195
196 bool enabled = false;
198 int offsetAngle = 135;
199 double offsetDist = 1.0;
200 Qgis::RenderUnit offsetUnits = Qgis::RenderUnit::Millimeters;
201 QgsMapUnitScale offsetMapUnitScale;
202 bool offsetGlobal = true;
203 double radius = 1.5;
204 Qgis::RenderUnit radiusUnits = Qgis::RenderUnit::Millimeters;
205 QgsMapUnitScale radiusMapUnitScale;
206 bool radiusAlphaOnly = false;
207 int scale = 100;
208 QColor color;
209 double opacity = 0.7;
210 QPainter::CompositionMode blendMode = QPainter::CompositionMode_Multiply;
211
212 private:
213 QgsTextShadowSettingsPrivate &operator=( const QgsTextShadowSettingsPrivate & ) = delete;
214};
215
216
217class QgsTextMaskSettingsPrivate : public QSharedData
218{
219 public:
220
221 QgsTextMaskSettingsPrivate()
222 {
223
224 }
225
226 QgsTextMaskSettingsPrivate( const QgsTextMaskSettingsPrivate &other )
227 : QSharedData( other )
228 , enabled( other.enabled )
229 , type( other.type )
230 , size( other.size )
231 , sizeUnit( other.sizeUnit )
232 , sizeMapUnitScale( other.sizeMapUnitScale )
233 , joinStyle( other.joinStyle )
234 , opacity( other.opacity )
235 , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
236 , maskedSymbolLayers( other.maskedSymbolLayers )
237 {
238 }
239
240 bool enabled = false;
242 double size = 1.5;
243 Qgis::RenderUnit sizeUnit = Qgis::RenderUnit::Millimeters;
244 QgsMapUnitScale sizeMapUnitScale;
245 Qt::PenJoinStyle joinStyle = Qt::RoundJoin;
246 double opacity = 1.0;
247 std::unique_ptr< QgsPaintEffect > paintEffect;
248 QgsSymbolLayerReferenceList maskedSymbolLayers;
249
250 private:
251 QgsTextMaskSettingsPrivate &operator=( const QgsTextMaskSettingsPrivate & ) = delete;
252};
253
254
255class QgsTextSettingsPrivate : public QSharedData
256{
257 public:
258
259 QgsTextSettingsPrivate()
260 : textColor( Qt::black )
261 {
262 }
263
264 QgsTextSettingsPrivate( const QgsTextSettingsPrivate &other )
265 : QSharedData( other )
266 , isValid( other.isValid )
267 , textFont( other.textFont )
268 , families( other.families )
269 , textNamedStyle( other.textNamedStyle )
270 , forcedBold( other.forcedBold )
271 , forcedItalic( other.forcedItalic )
272 , fontSizeUnits( other.fontSizeUnits )
273 , fontSizeMapUnitScale( other.fontSizeMapUnitScale )
274 , fontSize( other.fontSize )
275 , textColor( other.textColor )
276 , opacity( other.opacity )
277 , blendMode( other.blendMode )
278 , multilineHeight( other.multilineHeight )
279 , multilineHeightUnits( other.multilineHeightUnits )
280 , orientation( other.orientation )
281 , previewBackgroundColor( other.previewBackgroundColor )
282 , allowHtmlFormatting( other.allowHtmlFormatting )
283 , capitalization( other.capitalization )
284 , mDataDefinedProperties( other.mDataDefinedProperties )
285 {
286 }
287
288 bool isValid = false;
289 QFont textFont;
290 QStringList families;
291 QString textNamedStyle;
292 bool forcedBold = false;
293 bool forcedItalic = false;
294 Qgis::RenderUnit fontSizeUnits = Qgis::RenderUnit::Points;
295 QgsMapUnitScale fontSizeMapUnitScale;
296 double fontSize = 10 ; //may differ from size in textFont due to units (e.g., size in map units)
297 QColor textColor;
298 double opacity = 1.0;
299 QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
300 double multilineHeight = 1.0;
301 Qgis::RenderUnit multilineHeightUnits = Qgis::RenderUnit::Percentage;
302 Qgis::TextOrientation orientation = Qgis::TextOrientation::Horizontal;
303 QColor previewBackgroundColor = Qt::white;
304 bool allowHtmlFormatting = false;
306
308 QgsPropertyCollection mDataDefinedProperties;
309
310 private:
311 QgsTextSettingsPrivate &operator=( const QgsTextSettingsPrivate & ) = delete;
312};
313
315
316#endif // QGSTEXTRENDERER_PRIVATE_H
Capitalization
String capitalization options.
Definition: qgis.h:2323
@ MixedCase
Mixed case, ie no change.
TextOrientation
Text orientations.
Definition: qgis.h:1944
RenderUnit
Rendering size units.
Definition: qgis.h:3441
Struct for storing maximum and minimum scales for measurements in map units.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
SizeType
Methods for determining the background shape size.
@ SizeBuffer
Shape size is determined by adding a buffer margin around text.
ShapeType
Background shape types.
RotationType
Methods for determining the rotation of the background shape.
@ RotationSync
Shape rotation is synced with text rotation.
MaskType
Mask shape types.
ShadowPlacement
Placement positions for text shadow.
@ ShadowLowest
Draw shadow below all text components.
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList