QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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  , forcedBold( other.forcedBold )
273  , forcedItalic( other.forcedItalic )
274  , fontSizeUnits( other.fontSizeUnits )
275  , fontSizeMapUnitScale( other.fontSizeMapUnitScale )
276  , fontSize( other.fontSize )
277  , textColor( other.textColor )
278  , opacity( other.opacity )
279  , blendMode( other.blendMode )
280  , multilineHeight( other.multilineHeight )
281  , orientation( other.orientation )
282  , previewBackgroundColor( other.previewBackgroundColor )
283  , allowHtmlFormatting( other.allowHtmlFormatting )
284  , capitalization( other.capitalization )
285  , mDataDefinedProperties( other.mDataDefinedProperties )
286  {
287  }
288 
289  bool isValid = false;
290  QFont textFont;
291  QStringList families;
292  QString textNamedStyle;
293  bool forcedBold = false;
294  bool forcedItalic = false;
296  QgsMapUnitScale fontSizeMapUnitScale;
297  double fontSize = 10 ; //may differ from size in textFont due to units (e.g., size in map units)
298  QColor textColor;
299  double opacity = 1.0;
300  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
301  double multilineHeight = 1.0 ; //0.0 to 10.0, leading between lines as multiplyer of line height
303  QColor previewBackgroundColor = Qt::white;
304  bool allowHtmlFormatting = false;
306 
308  QgsPropertyCollection mDataDefinedProperties;
309 
310  private:
311  QgsTextSettingsPrivate &operator=( const QgsTextSettingsPrivate & ) = delete;
312 };
313 
314 
315 
316 
317 
319 
320 #endif // QGSTEXTRENDERER_PRIVATE_H
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
qgsstringutils.h
QgsUnitTypes::RenderPoints
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
QgsTextMaskSettings::MaskType
MaskType
Mask shape types.
Definition: qgstextmasksettings.h:48
qgstextshadowsettings.h
qgstextbackgroundsettings.h
QgsTextBackgroundSettings::SizeType
SizeType
Methods for determining the background shape size.
Definition: qgstextbackgroundsettings.h:66
qgsunittypes.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsTextBackgroundSettings::RotationSync
@ RotationSync
Shape rotation is synced with text rotation.
Definition: qgstextbackgroundsettings.h:78
qgspainteffect.h
qgssymbollayerreference.h
qgsapplication.h
QgsTextBackgroundSettings::RotationType
RotationType
Methods for determining the rotation of the background shape.
Definition: qgstextbackgroundsettings.h:76
QgsTextShadowSettings::ShadowPlacement
ShadowPlacement
Placement positions for text shadow.
Definition: qgstextshadowsettings.h:44
QgsTextBackgroundSettings::ShapeRectangle
@ ShapeRectangle
Rectangle.
Definition: qgstextbackgroundsettings.h:55
QgsTextShadowSettings::ShadowLowest
@ ShadowLowest
Draw shadow below all text components.
Definition: qgstextshadowsettings.h:46
Qgis::Capitalization::MixedCase
@ MixedCase
Mixed case, ie no change.
QgsTextBackgroundSettings::SizeBuffer
@ SizeBuffer
Shape size is determined by adding a buffer margin around text.
Definition: qgstextbackgroundsettings.h:68
Qgis::Capitalization
Capitalization
String capitalization options.
Definition: qgis.h:1592
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
QgsTextMaskSettings::MaskBuffer
@ MaskBuffer
Buffer.
Definition: qgstextmasksettings.h:50
QgsSymbolLayerReferenceList
QList< QgsSymbolLayerReference > QgsSymbolLayerReferenceList
Definition: qgssymbollayerreference.h:190
qgsmarkersymbol.h
QgsTextBackgroundSettings::ShapeType
ShapeType
Background shape types.
Definition: qgstextbackgroundsettings.h:53
qgspropertycollection.h
qgsmapunitscale.h
qgstextformat.h
QgsTextFormat::HorizontalOrientation
@ HorizontalOrientation
Vertically oriented text.
Definition: qgstextformat.h:47
qgsfillsymbol.h
QgsTextFormat::TextOrientation
TextOrientation
Text orientation.
Definition: qgstextformat.h:45