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