QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgstextshadowsettings.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgstextshadowsettings.cpp
3  -----------------
4  begin : May 2020
5  copyright : (C) Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgstextshadowsettings.h"
17 #include "qgstextrenderer_p.h"
18 #include "qgsvectorlayer.h"
19 #include "qgssymbollayerutils.h"
20 #include "qgspainting.h"
21 #include "qgspallabeling.h"
22 #include "qgstextrendererutils.h"
23 
25 {
26  d = new QgsTextShadowSettingsPrivate();
27 }
28 
30  : d( other.d )
31 {
32 
33 }
34 
36 {
37  d = other.d;
38  return *this;
39 }
40 
42 {
43 
44 }
45 
47 {
48  return d->enabled;
49 }
50 
52 {
53  d->enabled = enabled;
54 }
55 
57 {
58  return d->shadowUnder;
59 }
60 
62 {
63  d->shadowUnder = placement;
64 }
65 
67 {
68  return d->offsetAngle;
69 }
70 
72 {
73  d->offsetAngle = angle;
74 }
75 
77 {
78  return d->offsetDist;
79 }
80 
82 {
83  d->offsetDist = distance;
84 }
85 
87 {
88  return d->offsetUnits;
89 }
90 
92 {
93  d->offsetUnits = units;
94 }
95 
97 {
98  return d->offsetMapUnitScale;
99 }
100 
102 {
103  d->offsetMapUnitScale = scale;
104 }
105 
107 {
108  return d->offsetGlobal;
109 }
110 
112 {
113  d->offsetGlobal = global;
114 }
115 
117 {
118  return d->radius;
119 }
120 
122 {
123  d->radius = radius;
124 }
125 
127 {
128  return d->radiusUnits;
129 }
130 
132 {
133  d->radiusUnits = units;
134 }
135 
137 {
138  return d->radiusMapUnitScale;
139 }
140 
142 {
143  d->radiusMapUnitScale = scale;
144 }
145 
147 {
148  return d->radiusAlphaOnly;
149 }
150 
152 {
153  d->radiusAlphaOnly = alphaOnly;
154 }
155 
157 {
158  return d->opacity;
159 }
160 
161 void QgsTextShadowSettings::setOpacity( double opacity )
162 {
163  d->opacity = opacity;
164 }
165 
167 {
168  return d->scale;
169 }
170 
172 {
173  d->scale = scale;
174 }
175 
177 {
178  return d->color;
179 }
180 
181 void QgsTextShadowSettings::setColor( const QColor &color )
182 {
183  d->color = color;
184 }
185 
186 QPainter::CompositionMode QgsTextShadowSettings::blendMode() const
187 {
188  return d->blendMode;
189 }
190 
191 void QgsTextShadowSettings::setBlendMode( QPainter::CompositionMode mode )
192 {
193  d->blendMode = mode;
194 }
195 
197 {
198  d->enabled = layer->customProperty( QStringLiteral( "labeling/shadowDraw" ), QVariant( false ) ).toBool();
199  d->shadowUnder = static_cast< ShadowPlacement >( layer->customProperty( QStringLiteral( "labeling/shadowUnder" ), QVariant( ShadowLowest ) ).toUInt() );//ShadowLowest;
200  d->offsetAngle = layer->customProperty( QStringLiteral( "labeling/shadowOffsetAngle" ), QVariant( 135 ) ).toInt();
201  d->offsetDist = layer->customProperty( QStringLiteral( "labeling/shadowOffsetDist" ), QVariant( 1.0 ) ).toDouble();
202 
203  if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString().isEmpty() )
204  {
205  d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnits" ), 0 ).toUInt() );
206  }
207  else
208  {
209  d->offsetUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString() );
210  }
211  if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString().isEmpty() )
212  {
213  //fallback to older property
214  double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMinScale" ), 0.0 ).toDouble();
215  d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
216  double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
217  d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
218  }
219  else
220  {
221  d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString() );
222  }
223  d->offsetGlobal = layer->customProperty( QStringLiteral( "labeling/shadowOffsetGlobal" ), QVariant( true ) ).toBool();
224  d->radius = layer->customProperty( QStringLiteral( "labeling/shadowRadius" ), QVariant( 1.5 ) ).toDouble();
225 
226  if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString().isEmpty() )
227  {
228  d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnits" ), 0 ).toUInt() );
229  }
230  else
231  {
232  d->radiusUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString() );
233  }
234  if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString().isEmpty() )
235  {
236  //fallback to older property
237  double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMinScale" ), 0.0 ).toDouble();
238  d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
239  double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMaxScale" ), 0.0 ).toDouble();
240  d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
241  }
242  else
243  {
244  d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString() );
245  }
246  d->radiusAlphaOnly = layer->customProperty( QStringLiteral( "labeling/shadowRadiusAlphaOnly" ), QVariant( false ) ).toBool();
247 
248  if ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toString().isEmpty() )
249  {
250  d->opacity = ( 1 - layer->customProperty( QStringLiteral( "labeling/shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
251  }
252  else
253  {
254  d->opacity = ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toDouble() );
255  }
256  d->scale = layer->customProperty( QStringLiteral( "labeling/shadowScale" ), QVariant( 100 ) ).toInt();
257  d->color = QgsTextRendererUtils::readColor( layer, QStringLiteral( "labeling/shadowColor" ), Qt::black, false );
258  d->blendMode = QgsPainting::getCompositionMode(
259  static_cast< QgsPainting::BlendMode >( layer->customProperty( QStringLiteral( "labeling/shadowBlendMode" ), QVariant( QgsPainting::BlendMultiply ) ).toUInt() ) );
260 }
261 
262 void QgsTextShadowSettings::readXml( const QDomElement &elem )
263 {
264  QDomElement shadowElem = elem.firstChildElement( QStringLiteral( "shadow" ) );
265  d->enabled = shadowElem.attribute( QStringLiteral( "shadowDraw" ), QStringLiteral( "0" ) ).toInt();
266  d->shadowUnder = static_cast< ShadowPlacement >( shadowElem.attribute( QStringLiteral( "shadowUnder" ), QString::number( ShadowLowest ) ).toUInt() );//ShadowLowest;
267  d->offsetAngle = shadowElem.attribute( QStringLiteral( "shadowOffsetAngle" ), QStringLiteral( "135" ) ).toInt();
268  d->offsetDist = shadowElem.attribute( QStringLiteral( "shadowOffsetDist" ), QStringLiteral( "1" ) ).toDouble();
269 
270  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetUnit" ) ) )
271  {
272  d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnits" ) ).toUInt() );
273  }
274  else
275  {
276  d->offsetUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnit" ) ) );
277  }
278 
279  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) )
280  {
281  //fallback to older property
282  double oldMin = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
283  d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
284  double oldMax = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
285  d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
286  }
287  else
288  {
289  d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) );
290  }
291  d->offsetGlobal = shadowElem.attribute( QStringLiteral( "shadowOffsetGlobal" ), QStringLiteral( "1" ) ).toInt();
292  d->radius = shadowElem.attribute( QStringLiteral( "shadowRadius" ), QStringLiteral( "1.5" ) ).toDouble();
293 
294  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusUnit" ) ) )
295  {
296  d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnits" ) ).toUInt() );
297  }
298  else
299  {
300  d->radiusUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnit" ) ) );
301  }
302  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) )
303  {
304  //fallback to older property
305  double oldMin = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
306  d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
307  double oldMax = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
308  d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
309  }
310  else
311  {
312  d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) );
313  }
314  d->radiusAlphaOnly = shadowElem.attribute( QStringLiteral( "shadowRadiusAlphaOnly" ), QStringLiteral( "0" ) ).toInt();
315 
316  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOpacity" ) ) )
317  {
318  d->opacity = ( 1 - shadowElem.attribute( QStringLiteral( "shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
319  }
320  else
321  {
322  d->opacity = ( shadowElem.attribute( QStringLiteral( "shadowOpacity" ) ).toDouble() );
323  }
324  d->scale = shadowElem.attribute( QStringLiteral( "shadowScale" ), QStringLiteral( "100" ) ).toInt();
325  d->color = QgsSymbolLayerUtils::decodeColor( shadowElem.attribute( QStringLiteral( "shadowColor" ), QgsSymbolLayerUtils::encodeColor( Qt::black ) ) );
326  d->blendMode = QgsPainting::getCompositionMode(
327  static_cast< QgsPainting::BlendMode >( shadowElem.attribute( QStringLiteral( "shadowBlendMode" ), QString::number( QgsPainting::BlendMultiply ) ).toUInt() ) );
328 }
329 
330 QDomElement QgsTextShadowSettings::writeXml( QDomDocument &doc ) const
331 {
332  QDomElement shadowElem = doc.createElement( QStringLiteral( "shadow" ) );
333  shadowElem.setAttribute( QStringLiteral( "shadowDraw" ), d->enabled );
334  shadowElem.setAttribute( QStringLiteral( "shadowUnder" ), static_cast< unsigned int >( d->shadowUnder ) );
335  shadowElem.setAttribute( QStringLiteral( "shadowOffsetAngle" ), d->offsetAngle );
336  shadowElem.setAttribute( QStringLiteral( "shadowOffsetDist" ), d->offsetDist );
337  shadowElem.setAttribute( QStringLiteral( "shadowOffsetUnit" ), QgsUnitTypes::encodeUnit( d->offsetUnits ) );
338  shadowElem.setAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->offsetMapUnitScale ) );
339  shadowElem.setAttribute( QStringLiteral( "shadowOffsetGlobal" ), d->offsetGlobal );
340  shadowElem.setAttribute( QStringLiteral( "shadowRadius" ), d->radius );
341  shadowElem.setAttribute( QStringLiteral( "shadowRadiusUnit" ), QgsUnitTypes::encodeUnit( d->radiusUnits ) );
342  shadowElem.setAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->radiusMapUnitScale ) );
343  shadowElem.setAttribute( QStringLiteral( "shadowRadiusAlphaOnly" ), d->radiusAlphaOnly );
344  shadowElem.setAttribute( QStringLiteral( "shadowOpacity" ), d->opacity );
345  shadowElem.setAttribute( QStringLiteral( "shadowScale" ), d->scale );
346  shadowElem.setAttribute( QStringLiteral( "shadowColor" ), QgsSymbolLayerUtils::encodeColor( d->color ) );
347  shadowElem.setAttribute( QStringLiteral( "shadowBlendMode" ), QgsPainting::getBlendModeEnum( d->blendMode ) );
348  return shadowElem;
349 }
350 
352 {
353  if ( properties.isActive( QgsPalLayerSettings::ShadowDraw ) )
354  {
355  context.expressionContext().setOriginalValueVariable( d->enabled );
356  d->enabled = properties.valueAsBool( QgsPalLayerSettings::ShadowDraw, context.expressionContext(), d->enabled );
357  }
358 
359  // data defined shadow under type?
360  QVariant exprVal = properties.value( QgsPalLayerSettings::ShadowUnder, context.expressionContext() );
361  if ( exprVal.isValid() )
362  {
363  QString str = exprVal.toString().trimmed();
364  if ( !str.isEmpty() )
365  {
366  d->shadowUnder = QgsTextRendererUtils::decodeShadowPlacementType( str );
367  }
368  }
369 
371  {
372  context.expressionContext().setOriginalValueVariable( d->offsetAngle );
373  d->offsetAngle = properties.valueAsInt( QgsPalLayerSettings::ShadowOffsetAngle, context.expressionContext(), d->offsetAngle );
374  }
376  {
377  context.expressionContext().setOriginalValueVariable( d->offsetDist );
378  d->offsetDist = properties.valueAsDouble( QgsPalLayerSettings::ShadowOffsetDist, context.expressionContext(), d->offsetDist );
379  }
380 
381  exprVal = properties.value( QgsPalLayerSettings::ShadowOffsetUnits, context.expressionContext() );
382  if ( exprVal.isValid() )
383  {
384  QString units = exprVal.toString();
385  if ( !units.isEmpty() )
386  {
387  bool ok;
389  if ( ok )
390  d->offsetUnits = res;
391  }
392  }
393 
394  if ( properties.isActive( QgsPalLayerSettings::ShadowRadius ) )
395  {
396  context.expressionContext().setOriginalValueVariable( d->radius );
397  d->radius = properties.valueAsDouble( QgsPalLayerSettings::ShadowRadius, context.expressionContext(), d->radius );
398  }
399 
400  exprVal = properties.value( QgsPalLayerSettings::ShadowRadiusUnits, context.expressionContext() );
401  if ( exprVal.isValid() )
402  {
403  QString units = exprVal.toString();
404  if ( !units.isEmpty() )
405  {
406  bool ok;
408  if ( ok )
409  d->radiusUnits = res;
410  }
411  }
412 
413  if ( properties.isActive( QgsPalLayerSettings::ShadowOpacity ) )
414  {
415  context.expressionContext().setOriginalValueVariable( d->opacity * 100 );
416  d->opacity = properties.value( QgsPalLayerSettings::ShadowOpacity, context.expressionContext(), d->opacity * 100 ).toDouble() / 100.0;
417  }
418 
419  if ( properties.isActive( QgsPalLayerSettings::ShadowScale ) )
420  {
421  context.expressionContext().setOriginalValueVariable( d->scale );
422  d->scale = properties.valueAsInt( QgsPalLayerSettings::ShadowScale, context.expressionContext(), d->scale );
423  }
424 
425  if ( properties.isActive( QgsPalLayerSettings::ShadowColor ) )
426  {
428  d->color = properties.valueAsColor( QgsPalLayerSettings::ShadowColor, context.expressionContext(), d->color );
429  }
430 
432  {
433  exprVal = properties.value( QgsPalLayerSettings::ShadowBlendMode, context.expressionContext() );
434  QString blendstr = exprVal.toString().trimmed();
435  if ( !blendstr.isEmpty() )
436  d->blendMode = QgsSymbolLayerUtils::decodeBlendMode( blendstr );
437  }
438 }
439 
441 {
442  return QSet< QString >(); // nothing for now
443 }
QgsPalLayerSettings::ShadowBlendMode
@ ShadowBlendMode
Definition: qgspallabeling.h:423
QgsPalLayerSettings::ShadowRadius
@ ShadowRadius
Definition: qgspallabeling.h:417
QgsTextShadowSettings::readFromLayer
void readFromLayer(QgsVectorLayer *layer)
Reads settings from a layer's custom properties (for QGIS 2.x projects).
Definition: qgstextshadowsettings.cpp:196
QgsAbstractPropertyCollection::valueAsDouble
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
Definition: qgspropertycollection.cpp:66
QgsSymbolLayerUtils::encodeColor
static QString encodeColor(const QColor &color)
Definition: qgssymbollayerutils.cpp:52
QgsTextShadowSettings::setOpacity
void setOpacity(double opacity)
Sets the shadow's opacity.
Definition: qgstextshadowsettings.cpp:161
qgspallabeling.h
QgsSymbolLayerUtils::decodeBlendMode
static QPainter::CompositionMode decodeBlendMode(const QString &s)
Definition: qgssymbollayerutils.cpp:745
QgsTextShadowSettings::offsetDistance
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:76
QgsTextShadowSettings::setEnabled
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
Definition: qgstextshadowsettings.cpp:51
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:166
QgsAbstractPropertyCollection::valueAsInt
int valueAsInt(int key, const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an integer.
Definition: qgspropertycollection.cpp:77
QgsRenderContext::expressionContext
QgsExpressionContext & expressionContext()
Gets the expression context.
Definition: qgsrendercontext.h:580
QgsPainting::BlendMode
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Definition: qgspainting.h:49
QgsTextShadowSettings::blurRadiusMapUnitScale
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
Definition: qgstextshadowsettings.cpp:136
QgsSymbolLayerUtils::encodeMapUnitScale
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Definition: qgssymbollayerutils.cpp:558
qgstextrenderer_p.h
QgsTextShadowSettings::offsetUnit
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
Definition: qgstextshadowsettings.cpp:86
QgsExpressionContext::setOriginalValueVariable
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
Definition: qgsexpressioncontext.cpp:566
qgssymbollayerutils.h
QgsTextShadowSettings::readXml
void readXml(const QDomElement &elem)
Read settings from a DOM element.
Definition: qgstextshadowsettings.cpp:262
qgstextshadowsettings.h
QgsTextShadowSettings::scale
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
Definition: qgstextshadowsettings.cpp:166
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsTextShadowSettings::setOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
Definition: qgstextshadowsettings.cpp:101
QgsTextRendererUtils::readColor
static QColor readColor(QgsVectorLayer *layer, const QString &property, const QColor &defaultColor=Qt::black, bool withAlpha=true)
Converts an encoded color value from a layer property.
Definition: qgstextrendererutils.cpp:145
QgsPalLayerSettings::ShadowOffsetUnits
@ ShadowOffsetUnits
Definition: qgspallabeling.h:416
QgsTextShadowSettings::~QgsTextShadowSettings
~QgsTextShadowSettings()
Definition: qgstextshadowsettings.cpp:41
QgsTextShadowSettings::blurRadius
double blurRadius() const
Returns the blur radius for the shadow.
Definition: qgstextshadowsettings.cpp:116
QgsSymbolLayerUtils::decodeColor
static QColor decodeColor(const QString &str)
Definition: qgssymbollayerutils.cpp:57
QgsTextShadowSettings::operator=
QgsTextShadowSettings & operator=(const QgsTextShadowSettings &other)
Definition: qgstextshadowsettings.cpp:35
QgsTextShadowSettings::setOffsetDistance
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:81
QgsTextShadowSettings::setOffsetAngle
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:71
QgsTextShadowSettings::enabled
bool enabled() const
Returns whether the shadow is enabled.
Definition: qgstextshadowsettings.cpp:46
QgsTextShadowSettings::writeXml
QDomElement writeXml(QDomDocument &doc) const
Write settings into a DOM element.
Definition: qgstextshadowsettings.cpp:330
QgsUnitTypes::decodeRenderUnit
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
Definition: qgsunittypes.cpp:2900
QgsPainting::getBlendModeEnum
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
QgsTextShadowSettings::blurAlphaOnly
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
Definition: qgstextshadowsettings.cpp:146
qgstextrendererutils.h
QgsTextShadowSettings::blendMode
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
Definition: qgstextshadowsettings.cpp:186
QgsTextShadowSettings::ShadowPlacement
ShadowPlacement
Placement positions for text shadow.
Definition: qgstextshadowsettings.h:44
QgsTextShadowSettings::updateDataDefinedProperties
void updateDataDefinedProperties(QgsRenderContext &context, const QgsPropertyCollection &properties)
Updates the format by evaluating current values of data defined properties.
Definition: qgstextshadowsettings.cpp:351
QgsUnitTypes::encodeUnit
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
Definition: qgsunittypes.cpp:122
QgsTextRendererUtils::decodeShadowPlacementType
static QgsTextShadowSettings::ShadowPlacement decodeShadowPlacementType(const QString &string)
Decodes a string representation of a shadow placement type to a type.
Definition: qgstextrendererutils.cpp:77
QgsPalLayerSettings::ShadowUnder
@ ShadowUnder
Definition: qgspallabeling.h:413
QgsTextShadowSettings::setColor
void setColor(const QColor &color)
Sets the color for the drop shadow.
Definition: qgstextshadowsettings.cpp:181
QgsTextShadowSettings::ShadowLowest
@ ShadowLowest
Draw shadow below all text components.
Definition: qgstextshadowsettings.h:46
QgsPainting::getCompositionMode
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
QgsTextShadowSettings::offsetMapUnitScale
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
Definition: qgstextshadowsettings.cpp:96
QgsTextShadowSettings::color
QColor color() const
Returns the color of the drop shadow.
Definition: qgstextshadowsettings.cpp:176
QgsTextShadowSettings::setBlurRadius
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
Definition: qgstextshadowsettings.cpp:121
qgspainting.h
QgsTextShadowSettings::setShadowPlacement
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:61
QgsTextShadowSettings::offsetGlobal
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
Definition: qgstextshadowsettings.cpp:106
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:37
QgsTextShadowSettings::setScale
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
Definition: qgstextshadowsettings.cpp:171
QgsTextShadowSettings::setOffsetGlobal
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
Definition: qgstextshadowsettings.cpp:111
QgsPalLayerSettings::ShadowColor
@ ShadowColor
Definition: qgspallabeling.h:422
QgsTextShadowSettings::setOffsetUnit
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's offset.
Definition: qgstextshadowsettings.cpp:91
QgsTextShadowSettings::offsetAngle
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:66
qgsvectorlayer.h
QgsPalLayerSettings::ShadowScale
@ ShadowScale
Definition: qgspallabeling.h:421
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
QgsTextShadowSettings::setBlurRadiusUnit
void setBlurRadiusUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's blur radius.
Definition: qgstextshadowsettings.cpp:131
QgsPalLayerSettings::ShadowOffsetAngle
@ ShadowOffsetAngle
Definition: qgspallabeling.h:414
QgsTextShadowSettings
Definition: qgstextshadowsettings.h:37
QgsPalLayerSettings::ShadowOffsetDist
@ ShadowOffsetDist
Definition: qgspallabeling.h:415
QgsMapLayer::customProperty
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Definition: qgsmaplayer.cpp:1718
QgsTextShadowSettings::setBlurAlphaOnly
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
Definition: qgstextshadowsettings.cpp:151
QgsPropertyCollection::value
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection.
Definition: qgspropertycollection.cpp:218
QgsAbstractPropertyCollection::valueAsBool
bool valueAsBool(int key, const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an boolean.
Definition: qgspropertycollection.cpp:88
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsTextShadowSettings::referencedFields
QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns all field names referenced by the configuration (e.g.
Definition: qgstextshadowsettings.cpp:440
QgsPalLayerSettings::ShadowOpacity
@ ShadowOpacity
Shadow opacity.
Definition: qgspallabeling.h:420
QgsTextShadowSettings::opacity
double opacity() const
Returns the shadow's opacity.
Definition: qgstextshadowsettings.cpp:156
QgsTextShadowSettings::setBlurRadiusMapUnitScale
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
Definition: qgstextshadowsettings.cpp:141
QgsPalLayerSettings::ShadowRadiusUnits
@ ShadowRadiusUnits
Definition: qgspallabeling.h:418
QgsPainting::BlendMultiply
@ BlendMultiply
Definition: qgspainting.h:70
QgsTextShadowSettings::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
Definition: qgstextshadowsettings.cpp:191
QgsTextShadowSettings::shadowPlacement
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:56
QgsPropertyCollection::isActive
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition: qgspropertycollection.cpp:258
QgsTextRendererUtils::convertFromOldLabelUnit
static QgsUnitTypes::RenderUnit convertFromOldLabelUnit(int val)
Converts a unit from an old (pre 3.0) label unit.
Definition: qgstextrendererutils.cpp:131
QgsPalLayerSettings::ShadowDraw
@ ShadowDraw
Definition: qgspallabeling.h:412
MathUtils::angle
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
QgsTextShadowSettings::blurRadiusUnit
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
Definition: qgstextshadowsettings.cpp:126
QgsTextShadowSettings::QgsTextShadowSettings
QgsTextShadowSettings()
Definition: qgstextshadowsettings.cpp:24
QgsSymbolLayerUtils::decodeMapUnitScale
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
Definition: qgssymbollayerutils.cpp:568
QgsAbstractPropertyCollection::valueAsColor
QColor valueAsColor(int key, const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a color.
Definition: qgspropertycollection.cpp:54