QGIS API Documentation  3.21.0-Master (5b68dc587e)
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 #include "qgsmarkersymbol.h"
33 #include "qgsfillsymbol.h"
34 #include "qgspropertycollection.h"
35 
36 #include <QSharedData>
37 #include <QPainter>
38 
40 
41 //
42 // W A R N I N G
43 // -------------
44 //
45 // This file is not part of the QGIS API. It exists purely as an
46 // implementation detail. This header file may change from version to
47 // version without notice, or even be removed.
48 //
49 
50 
51 class QgsTextBufferSettingsPrivate : public QSharedData
52 {
53  public:
54 
55  QgsTextBufferSettingsPrivate()
56  : color( Qt::white )
57  {
58  }
59 
60  QgsTextBufferSettingsPrivate( const QgsTextBufferSettingsPrivate &other )
61  : QSharedData( other )
62  , enabled( other.enabled )
63  , size( other.size )
64  , sizeUnit( other.sizeUnit )
65  , sizeMapUnitScale( other.sizeMapUnitScale )
66  , color( other.color )
67  , opacity( other.opacity )
68  , fillBufferInterior( other.fillBufferInterior )
69  , joinStyle( other.joinStyle )
70  , blendMode( other.blendMode )
71  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
72  {
73  }
74 
75  bool enabled = false;
76  double size = 1;
78  QgsMapUnitScale sizeMapUnitScale;
79  QColor color;
80  double opacity = 1.0;
81  bool fillBufferInterior = false;
82  Qt::PenJoinStyle joinStyle = Qt::RoundJoin;
83  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
84  std::unique_ptr< QgsPaintEffect > paintEffect;
85 
86  private:
87  QgsTextBufferSettingsPrivate &operator=( const QgsTextBufferSettingsPrivate & ) = delete;
88 };
89 
90 
91 class QgsTextBackgroundSettingsPrivate : public QSharedData
92 {
93  public:
94 
95  QgsTextBackgroundSettingsPrivate()
96  : size( QSizeF( 0.0, 0.0 ) )
97  , offset( QPointF( 0.0, 0.0 ) )
98  , radii( QSizeF( 0.0, 0.0 ) )
99  , fillColor( Qt::white )
100  , strokeColor( Qt::darkGray )
101  {
102  }
103 
104  QgsTextBackgroundSettingsPrivate( const QgsTextBackgroundSettingsPrivate &other )
105  : QSharedData( other )
106  , enabled( other.enabled )
107  , type( other.type )
108  , svgFile( other.svgFile )
109  , sizeType( other.sizeType )
110  , size( other.size )
111  , sizeUnits( other.sizeUnits )
112  , sizeMapUnitScale( other.sizeMapUnitScale )
113  , rotationType( other.rotationType )
114  , rotation( other.rotation )
115  , offset( other.offset )
116  , offsetUnits( other.offsetUnits )
117  , offsetMapUnitScale( other.offsetMapUnitScale )
118  , radii( other.radii )
119  , radiiUnits( other.radiiUnits )
120  , radiiMapUnitScale( other.radiiMapUnitScale )
121  , blendMode( other.blendMode )
122  , fillColor( other.fillColor )
123  , strokeColor( other.strokeColor )
124  , opacity( other.opacity )
125  , strokeWidth( other.strokeWidth )
126  , strokeWidthUnits( other.strokeWidthUnits )
127  , strokeWidthMapUnitScale( other.strokeWidthMapUnitScale )
128  , joinStyle( other.joinStyle )
129  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
130  , markerSymbol( other.markerSymbol ? other.markerSymbol->clone() : nullptr )
131  , fillSymbol( other.fillSymbol ? other.fillSymbol->clone() : nullptr )
132  {
133  }
134 
135  bool enabled = false;
137  QString svgFile;
139  QSizeF size;
141  QgsMapUnitScale sizeMapUnitScale;
143  double rotation = 0.0;
144  QPointF offset;
146  QgsMapUnitScale offsetMapUnitScale;
147  QSizeF radii;
149  QgsMapUnitScale radiiMapUnitScale;
150  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
151  QColor fillColor;
152  QColor strokeColor;
153  double opacity = 1.0;
154  double strokeWidth = 0.0;
156  QgsMapUnitScale strokeWidthMapUnitScale;
157  Qt::PenJoinStyle joinStyle = Qt::BevelJoin;
158  std::unique_ptr< QgsPaintEffect > paintEffect;
159  std::unique_ptr< QgsMarkerSymbol > markerSymbol;
160  std::unique_ptr< QgsFillSymbol > fillSymbol;
161 
162  private:
163  QgsTextBackgroundSettingsPrivate &operator=( const QgsTextBackgroundSettingsPrivate & ) = delete;
164 };
165 
166 
167 
168 class QgsTextShadowSettingsPrivate : public QSharedData
169 {
170  public:
171 
172  QgsTextShadowSettingsPrivate()
173  : color( QColor( 0, 0, 0 ) )
174  {
175 
176  }
177 
178  QgsTextShadowSettingsPrivate( const QgsTextShadowSettingsPrivate &other )
179  : QSharedData( other )
180  , enabled( other.enabled )
181  , shadowUnder( other.shadowUnder )
182  , offsetAngle( other.offsetAngle )
183  , offsetDist( other.offsetDist )
184  , offsetUnits( other.offsetUnits )
185  , offsetMapUnitScale( other.offsetMapUnitScale )
186  , offsetGlobal( other.offsetGlobal )
187  , radius( other.radius )
188  , radiusUnits( other.radiusUnits )
189  , radiusMapUnitScale( other.radiusMapUnitScale )
190  , radiusAlphaOnly( other.radiusAlphaOnly )
191  , scale( other.scale )
192  , color( other.color )
193  , opacity( other.opacity )
194  , blendMode( other.blendMode )
195  {
196  }
197 
198  bool enabled = false;
200  int offsetAngle = 135;
201  double offsetDist = 1.0;
203  QgsMapUnitScale offsetMapUnitScale;
204  bool offsetGlobal = true;
205  double radius = 1.5;
207  QgsMapUnitScale radiusMapUnitScale;
208  bool radiusAlphaOnly = false;
209  int scale = 100;
210  QColor color;
211  double opacity = 0.7;
212  QPainter::CompositionMode blendMode = QPainter::CompositionMode_Multiply;
213 
214  private:
215  QgsTextShadowSettingsPrivate &operator=( const QgsTextShadowSettingsPrivate & ) = delete;
216 };
217 
218 
219 class QgsTextMaskSettingsPrivate : public QSharedData
220 {
221  public:
222 
223  QgsTextMaskSettingsPrivate()
224  {
225 
226  }
227 
228  QgsTextMaskSettingsPrivate( const QgsTextMaskSettingsPrivate &other )
229  : QSharedData( other )
230  , enabled( other.enabled )
231  , type( other.type )
232  , size( other.size )
233  , sizeUnit( other.sizeUnit )
234  , sizeMapUnitScale( other.sizeMapUnitScale )
235  , joinStyle( other.joinStyle )
236  , opacity( other.opacity )
237  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
238  , maskedSymbolLayers( other.maskedSymbolLayers )
239  {
240  }
241 
242  bool enabled = false;
244  double size = 1.5;
246  QgsMapUnitScale sizeMapUnitScale;
247  Qt::PenJoinStyle joinStyle = Qt::RoundJoin;
248  double opacity = 1.0;
249  std::unique_ptr< QgsPaintEffect > paintEffect;
250  QgsSymbolLayerReferenceList maskedSymbolLayers;
251 
252  private:
253  QgsTextMaskSettingsPrivate &operator=( const QgsTextMaskSettingsPrivate & ) = delete;
254 };
255 
256 
257 class QgsTextSettingsPrivate : public QSharedData
258 {
259  public:
260 
261  QgsTextSettingsPrivate()
262  : textColor( Qt::black )
263  {
264  }
265 
266  QgsTextSettingsPrivate( const QgsTextSettingsPrivate &other )
267  : QSharedData( other )
268  , isValid( other.isValid )
269  , textFont( other.textFont )
270  , families( other.families )
271  , textNamedStyle( other.textNamedStyle )
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  , orientation( other.orientation )
280  , previewBackgroundColor( other.previewBackgroundColor )
281  , allowHtmlFormatting( other.allowHtmlFormatting )
282  , capitalization( other.capitalization )
283  , mDataDefinedProperties( other.mDataDefinedProperties )
284  {
285  }
286 
287  bool isValid = false;
288  QFont textFont;
289  QStringList families;
290  QString textNamedStyle;
292  QgsMapUnitScale fontSizeMapUnitScale;
293  double fontSize = 10 ; //may differ from size in textFont due to units (e.g., size in map units)
294  QColor textColor;
295  double opacity = 1.0;
296  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
297  double multilineHeight = 1.0 ; //0.0 to 10.0, leading between lines as multiplyer of line height
299  QColor previewBackgroundColor = Qt::white;
300  bool allowHtmlFormatting = false;
302 
304  QgsPropertyCollection mDataDefinedProperties;
305 
306  private:
307  QgsTextSettingsPrivate &operator=( const QgsTextSettingsPrivate & ) = delete;
308 };
309 
310 
311 
312 
313 
315 
316 #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:168
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList