QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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"
23 #include "qgstextshadowsettings.h"
25 #include "qgstextformat.h"
26 #include "qgsmapunitscale.h"
27 #include "qgsunittypes.h"
28 #include "qgsapplication.h"
29 #include "qgspainteffect.h"
31 #include "qgsstringutils.h"
32 
33 #include <QSharedData>
34 #include <QPainter>
35 
37 
38 //
39 // W A R N I N G
40 // -------------
41 //
42 // This file is not part of the QGIS API. It exists purely as an
43 // implementation detail. This header file may change from version to
44 // version without notice, or even be removed.
45 //
46 
47 
48 class QgsTextBufferSettingsPrivate : public QSharedData
49 {
50  public:
51 
52  QgsTextBufferSettingsPrivate()
53  : color( Qt::white )
54  {
55  }
56 
57  QgsTextBufferSettingsPrivate( const QgsTextBufferSettingsPrivate &other )
58  : QSharedData( other )
59  , enabled( other.enabled )
60  , size( other.size )
61  , sizeUnit( other.sizeUnit )
62  , sizeMapUnitScale( other.sizeMapUnitScale )
63  , color( other.color )
64  , opacity( other.opacity )
65  , fillBufferInterior( other.fillBufferInterior )
66  , joinStyle( other.joinStyle )
67  , blendMode( other.blendMode )
68  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
69  {
70  }
71 
72  bool enabled = false;
73  double size = 1;
75  QgsMapUnitScale sizeMapUnitScale;
76  QColor color;
77  double opacity = 1.0;
78  bool fillBufferInterior = false;
79  Qt::PenJoinStyle joinStyle = Qt::RoundJoin;
80  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
81  std::unique_ptr< QgsPaintEffect > paintEffect;
82 
83  private:
84  QgsTextBufferSettingsPrivate &operator=( const QgsTextBufferSettingsPrivate & ) = delete;
85 };
86 
87 
88 class QgsTextBackgroundSettingsPrivate : public QSharedData
89 {
90  public:
91 
92  QgsTextBackgroundSettingsPrivate()
93  : size( QSizeF( 0.0, 0.0 ) )
94  , offset( QPointF( 0.0, 0.0 ) )
95  , radii( QSizeF( 0.0, 0.0 ) )
96  , fillColor( Qt::white )
97  , strokeColor( Qt::darkGray )
98  {
99  }
100 
101  QgsTextBackgroundSettingsPrivate( const QgsTextBackgroundSettingsPrivate &other )
102  : QSharedData( other )
103  , enabled( other.enabled )
104  , type( other.type )
105  , svgFile( other.svgFile )
106  , sizeType( other.sizeType )
107  , size( other.size )
108  , sizeUnits( other.sizeUnits )
109  , sizeMapUnitScale( other.sizeMapUnitScale )
110  , rotationType( other.rotationType )
111  , rotation( other.rotation )
112  , offset( other.offset )
113  , offsetUnits( other.offsetUnits )
114  , offsetMapUnitScale( other.offsetMapUnitScale )
115  , radii( other.radii )
116  , radiiUnits( other.radiiUnits )
117  , radiiMapUnitScale( other.radiiMapUnitScale )
118  , blendMode( other.blendMode )
119  , fillColor( other.fillColor )
120  , strokeColor( other.strokeColor )
121  , opacity( other.opacity )
122  , strokeWidth( other.strokeWidth )
123  , strokeWidthUnits( other.strokeWidthUnits )
124  , strokeWidthMapUnitScale( other.strokeWidthMapUnitScale )
125  , joinStyle( other.joinStyle )
126  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
127  , markerSymbol( other.markerSymbol ? other.markerSymbol->clone() : nullptr )
128  {
129  }
130 
131  bool enabled = false;
133  QString svgFile;
135  QSizeF size;
137  QgsMapUnitScale sizeMapUnitScale;
139  double rotation = 0.0;
140  QPointF offset;
142  QgsMapUnitScale offsetMapUnitScale;
143  QSizeF radii;
145  QgsMapUnitScale radiiMapUnitScale;
146  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
147  QColor fillColor;
148  QColor strokeColor;
149  double opacity = 1.0;
150  double strokeWidth = 0.0;
152  QgsMapUnitScale strokeWidthMapUnitScale;
153  Qt::PenJoinStyle joinStyle = Qt::BevelJoin;
154  std::unique_ptr< QgsPaintEffect > paintEffect;
155  std::unique_ptr< QgsMarkerSymbol > markerSymbol;
156 
157  private:
158  QgsTextBackgroundSettingsPrivate &operator=( const QgsTextBackgroundSettingsPrivate & ) = delete;
159 };
160 
161 
162 
163 class QgsTextShadowSettingsPrivate : public QSharedData
164 {
165  public:
166 
167  QgsTextShadowSettingsPrivate()
168  : color( QColor( 0, 0, 0 ) )
169  {
170 
171  }
172 
173  QgsTextShadowSettingsPrivate( const QgsTextShadowSettingsPrivate &other )
174  : QSharedData( other )
175  , enabled( other.enabled )
176  , shadowUnder( other.shadowUnder )
177  , offsetAngle( other.offsetAngle )
178  , offsetDist( other.offsetDist )
179  , offsetUnits( other.offsetUnits )
180  , offsetMapUnitScale( other.offsetMapUnitScale )
181  , offsetGlobal( other.offsetGlobal )
182  , radius( other.radius )
183  , radiusUnits( other.radiusUnits )
184  , radiusMapUnitScale( other.radiusMapUnitScale )
185  , radiusAlphaOnly( other.radiusAlphaOnly )
186  , scale( other.scale )
187  , color( other.color )
188  , opacity( other.opacity )
189  , blendMode( other.blendMode )
190  {
191  }
192 
193  bool enabled = false;
195  int offsetAngle = 135;
196  double offsetDist = 1.0;
198  QgsMapUnitScale offsetMapUnitScale;
199  bool offsetGlobal = true;
200  double radius = 1.5;
202  QgsMapUnitScale radiusMapUnitScale;
203  bool radiusAlphaOnly = false;
204  int scale = 100;
205  QColor color;
206  double opacity = 0.7;
207  QPainter::CompositionMode blendMode = QPainter::CompositionMode_Multiply;
208 
209  private:
210  QgsTextShadowSettingsPrivate &operator=( const QgsTextShadowSettingsPrivate & ) = delete;
211 };
212 
213 
214 class QgsTextMaskSettingsPrivate : public QSharedData
215 {
216  public:
217 
218  QgsTextMaskSettingsPrivate()
219  {
220 
221  }
222 
223  QgsTextMaskSettingsPrivate( const QgsTextMaskSettingsPrivate &other )
224  : QSharedData( other )
225  , enabled( other.enabled )
226  , type( other.type )
227  , size( other.size )
228  , sizeUnit( other.sizeUnit )
229  , sizeMapUnitScale( other.sizeMapUnitScale )
230  , joinStyle( other.joinStyle )
231  , opacity( other.opacity )
232  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
233  , maskedSymbolLayers( other.maskedSymbolLayers )
234  {
235  }
236 
237  bool enabled = false;
239  double size = 1.5;
241  QgsMapUnitScale sizeMapUnitScale;
242  Qt::PenJoinStyle joinStyle = Qt::RoundJoin;
243  double opacity = 1.0;
244  std::unique_ptr< QgsPaintEffect > paintEffect;
245  QgsSymbolLayerReferenceList maskedSymbolLayers;
246 
247  private:
248  QgsTextMaskSettingsPrivate &operator=( const QgsTextMaskSettingsPrivate & ) = delete;
249 };
250 
251 
252 class QgsTextSettingsPrivate : public QSharedData
253 {
254  public:
255 
256  QgsTextSettingsPrivate()
257  : textColor( Qt::black )
258  {
259  }
260 
261  QgsTextSettingsPrivate( const QgsTextSettingsPrivate &other )
262  : QSharedData( other )
263  , isValid( other.isValid )
264  , textFont( other.textFont )
265  , textNamedStyle( other.textNamedStyle )
266  , fontSizeUnits( other.fontSizeUnits )
267  , fontSizeMapUnitScale( other.fontSizeMapUnitScale )
268  , fontSize( other.fontSize )
269  , textColor( other.textColor )
270  , opacity( other.opacity )
271  , blendMode( other.blendMode )
272  , multilineHeight( other.multilineHeight )
273  , orientation( other.orientation )
274  , previewBackgroundColor( other.previewBackgroundColor )
275  , allowHtmlFormatting( other.allowHtmlFormatting )
276  , capitalization( other.capitalization )
277  , mDataDefinedProperties( other.mDataDefinedProperties )
278  {
279  }
280 
281  bool isValid = false;
282  QFont textFont;
283  QString textNamedStyle;
285  QgsMapUnitScale fontSizeMapUnitScale;
286  double fontSize = 10 ; //may differ from size in textFont due to units (e.g., size in map units)
287  QColor textColor;
288  double opacity = 1.0;
289  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
290  double multilineHeight = 1.0 ; //0.0 to 10.0, leading between lines as multiplyer of line height
292  QColor previewBackgroundColor = Qt::white;
293  bool allowHtmlFormatting = false;
295 
297  QgsPropertyCollection mDataDefinedProperties;
298 
299  private:
300  QgsTextSettingsPrivate &operator=( const QgsTextSettingsPrivate & ) = delete;
301 };
302 
303 
304 
305 
306 
308 
309 #endif // QGSTEXTRENDERER_PRIVATE_H
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.
Capitalization
Capitalization options.
@ MixedCase
Mixed case, ie no change.
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.
TextOrientation
Text orientation.
Definition: qgstextformat.h:46
@ HorizontalOrientation
Vertically oriented text.
Definition: qgstextformat.h:47
MaskType
Mask shape types.
ShadowPlacement
Placement positions for text shadow.
@ ShadowLowest
Draw shadow below all text components.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:172
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList