QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 "qgstextrenderer.h"
24 #include "qgsmapunitscale.h"
25 #include "qgsunittypes.h"
26 #include "qgsapplication.h"
27 #include "qgspainteffect.h"
28 #include <QSharedData>
29 #include <QPainter>
30 
32 
33 //
34 // W A R N I N G
35 // -------------
36 //
37 // This file is not part of the QGIS API. It exists purely as an
38 // implementation detail. This header file may change from version to
39 // version without notice, or even be removed.
40 //
41 
42 
43 class QgsTextBufferSettingsPrivate : public QSharedData
44 {
45  public:
46 
47  QgsTextBufferSettingsPrivate()
48  : color( Qt::white )
49  {
50  }
51 
52  QgsTextBufferSettingsPrivate( const QgsTextBufferSettingsPrivate &other )
53  : QSharedData( other )
54  , enabled( other.enabled )
55  , size( other.size )
56  , sizeUnit( other.sizeUnit )
57  , sizeMapUnitScale( other.sizeMapUnitScale )
58  , color( other.color )
59  , opacity( other.opacity )
60  , fillBufferInterior( other.fillBufferInterior )
61  , joinStyle( other.joinStyle )
62  , blendMode( other.blendMode )
63  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
64  {
65  }
66 
67  ~QgsTextBufferSettingsPrivate()
68  {
69  delete paintEffect;
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  QgsPaintEffect *paintEffect = nullptr;
82 };
83 
84 
85 class QgsTextBackgroundSettingsPrivate : public QSharedData
86 {
87  public:
88 
89  QgsTextBackgroundSettingsPrivate()
90  : size( QSizeF( 0.0, 0.0 ) )
91  , offset( QPointF( 0.0, 0.0 ) )
92  , radii( QSizeF( 0.0, 0.0 ) )
93  , fillColor( Qt::white )
94  , strokeColor( Qt::darkGray )
95  {
96  }
97 
98  QgsTextBackgroundSettingsPrivate( const QgsTextBackgroundSettingsPrivate &other )
99  : QSharedData( other )
100  , enabled( other.enabled )
101  , type( other.type )
102  , svgFile( other.svgFile )
103  , sizeType( other.sizeType )
104  , size( other.size )
105  , sizeUnits( other.sizeUnits )
106  , sizeMapUnitScale( other.sizeMapUnitScale )
107  , rotationType( other.rotationType )
108  , rotation( other.rotation )
109  , offset( other.offset )
110  , offsetUnits( other.offsetUnits )
111  , offsetMapUnitScale( other.offsetMapUnitScale )
112  , radii( other.radii )
113  , radiiUnits( other.radiiUnits )
114  , radiiMapUnitScale( other.radiiMapUnitScale )
115  , blendMode( other.blendMode )
116  , fillColor( other.fillColor )
117  , strokeColor( other.strokeColor )
118  , opacity( other.opacity )
119  , strokeWidth( other.strokeWidth )
120  , strokeWidthUnits( other.strokeWidthUnits )
121  , strokeWidthMapUnitScale( other.strokeWidthMapUnitScale )
122  , joinStyle( other.joinStyle )
123  , paintEffect( other.paintEffect ? other.paintEffect->clone() : nullptr )
124  {
125  }
126 
127  ~QgsTextBackgroundSettingsPrivate()
128  {
129  delete paintEffect;
130  }
131 
132  bool enabled = false;
134  QString svgFile;
136  QSizeF size;
138  QgsMapUnitScale sizeMapUnitScale;
140  double rotation = 0.0;
141  QPointF offset;
143  QgsMapUnitScale offsetMapUnitScale;
144  QSizeF radii;
146  QgsMapUnitScale radiiMapUnitScale;
147  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
148  QColor fillColor;
149  QColor strokeColor;
150  double opacity = 1.0;
151  double strokeWidth = 0.0;
153  QgsMapUnitScale strokeWidthMapUnitScale;
154  Qt::PenJoinStyle joinStyle = Qt::BevelJoin;
155  QgsPaintEffect *paintEffect = nullptr;
156 };
157 
158 
159 
160 class QgsTextShadowSettingsPrivate : public QSharedData
161 {
162  public:
163 
164  QgsTextShadowSettingsPrivate()
165  : color( QColor( 0, 0, 0 ) )
166  {
167 
168  }
169 
170  QgsTextShadowSettingsPrivate( const QgsTextShadowSettingsPrivate &other )
171  : QSharedData( other )
172  , enabled( other.enabled )
173  , shadowUnder( other.shadowUnder )
174  , offsetAngle( other.offsetAngle )
175  , offsetDist( other.offsetDist )
176  , offsetUnits( other.offsetUnits )
177  , offsetMapUnitScale( other.offsetMapUnitScale )
178  , offsetGlobal( other.offsetGlobal )
179  , radius( other.radius )
180  , radiusUnits( other.radiusUnits )
181  , radiusMapUnitScale( other.radiusMapUnitScale )
182  , radiusAlphaOnly( other.radiusAlphaOnly )
183  , scale( other.scale )
184  , color( other.color )
185  , opacity( other.opacity )
186  , blendMode( other.blendMode )
187  {
188  }
189 
190  bool enabled = false;
192  int offsetAngle = 135;
193  double offsetDist = 1.0;
195  QgsMapUnitScale offsetMapUnitScale;
196  bool offsetGlobal = true;
197  double radius = 1.5;
199  QgsMapUnitScale radiusMapUnitScale;
200  bool radiusAlphaOnly = false;
201  int scale = 100;
202  QColor color;
203  double opacity = 0.7;
204  QPainter::CompositionMode blendMode = QPainter::CompositionMode_Multiply;
205 };
206 
207 
208 class QgsTextSettingsPrivate : public QSharedData
209 {
210  public:
211 
212  QgsTextSettingsPrivate()
213  : textColor( Qt::black )
214  {
215  }
216 
217  QgsTextSettingsPrivate( const QgsTextSettingsPrivate &other )
218  : QSharedData( other )
219  , textFont( other.textFont )
220  , textNamedStyle( other.textNamedStyle )
221  , fontSizeUnits( other.fontSizeUnits )
222  , fontSizeMapUnitScale( other.fontSizeMapUnitScale )
223  , fontSize( other.fontSize )
224  , textColor( other.textColor )
225  , opacity( other.opacity )
226  , blendMode( other.blendMode )
227  , multilineHeight( other.multilineHeight )
228  {
229  }
230 
231  QFont textFont;
232  QString textNamedStyle;
234  QgsMapUnitScale fontSizeMapUnitScale;
235  double fontSize = 10 ; //may differ from size in textFont due to units (e.g., size in map units)
236  QColor textColor;
237  double opacity = 1.0;
238  QPainter::CompositionMode blendMode = QPainter::CompositionMode_SourceOver;
239  double multilineHeight = 1.0 ; //0.0 to 10.0, leading between lines as multiplyer of line height
240 
241 };
242 
243 
244 
245 
246 
248 
249 #endif // QGSTEXTRENDERER_PRIVATE_H
Shape size is determined by adding a buffer margin around text.
RotationType
Methods for determining the rotation of the background shape.
ShadowPlacement
Placement positions for text shadow.
Base class for visual effects which can be applied to QPicture drawings.
SizeType
Methods for determining the background shape size.
Draw shadow below all text components.
ShapeType
Background shape types.
Struct for storing maximum and minimum scales for measurements in map units.
Shape rotation is synced with text rotation.
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:110