QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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  if ( d->enabled != other.enabled()
49  || d->shadowUnder != other.shadowPlacement()
50  || d->offsetAngle != other.offsetAngle()
51  || d->offsetDist != other.offsetDistance()
52  || d->offsetUnits != other.offsetUnit()
53  || d->offsetMapUnitScale != other.offsetMapUnitScale()
54  || d->offsetGlobal != other.offsetGlobal()
55  || d->radius != other.blurRadius()
56  || d->radiusUnits != other.blurRadiusUnit()
57  || d->radiusMapUnitScale != other.blurRadiusMapUnitScale()
58  || d->radiusAlphaOnly != other.blurAlphaOnly()
59  || d->scale != other.scale()
60  || d->color != other.color()
61  || d->opacity != other.opacity()
62  || d->blendMode != other.blendMode() )
63  return false;
64 
65  return true;
66 }
67 
69 {
70  return !( *this == other );
71 }
72 
74 {
75  return d->enabled;
76 }
77 
79 {
80  d->enabled = enabled;
81 }
82 
84 {
85  return d->shadowUnder;
86 }
87 
89 {
90  d->shadowUnder = placement;
91 }
92 
94 {
95  return d->offsetAngle;
96 }
97 
99 {
100  d->offsetAngle = angle;
101 }
102 
104 {
105  return d->offsetDist;
106 }
107 
109 {
110  d->offsetDist = distance;
111 }
112 
114 {
115  return d->offsetUnits;
116 }
117 
119 {
120  d->offsetUnits = units;
121 }
122 
124 {
125  return d->offsetMapUnitScale;
126 }
127 
129 {
130  d->offsetMapUnitScale = scale;
131 }
132 
134 {
135  return d->offsetGlobal;
136 }
137 
139 {
140  d->offsetGlobal = global;
141 }
142 
144 {
145  return d->radius;
146 }
147 
149 {
150  d->radius = radius;
151 }
152 
154 {
155  return d->radiusUnits;
156 }
157 
159 {
160  d->radiusUnits = units;
161 }
162 
164 {
165  return d->radiusMapUnitScale;
166 }
167 
169 {
170  d->radiusMapUnitScale = scale;
171 }
172 
174 {
175  return d->radiusAlphaOnly;
176 }
177 
179 {
180  d->radiusAlphaOnly = alphaOnly;
181 }
182 
184 {
185  return d->opacity;
186 }
187 
188 void QgsTextShadowSettings::setOpacity( double opacity )
189 {
190  d->opacity = opacity;
191 }
192 
194 {
195  return d->scale;
196 }
197 
199 {
200  d->scale = scale;
201 }
202 
204 {
205  return d->color;
206 }
207 
208 void QgsTextShadowSettings::setColor( const QColor &color )
209 {
210  d->color = color;
211 }
212 
213 QPainter::CompositionMode QgsTextShadowSettings::blendMode() const
214 {
215  return d->blendMode;
216 }
217 
218 void QgsTextShadowSettings::setBlendMode( QPainter::CompositionMode mode )
219 {
220  d->blendMode = mode;
221 }
222 
224 {
225  d->enabled = layer->customProperty( QStringLiteral( "labeling/shadowDraw" ), QVariant( false ) ).toBool();
226  d->shadowUnder = static_cast< ShadowPlacement >( layer->customProperty( QStringLiteral( "labeling/shadowUnder" ), QVariant( ShadowLowest ) ).toUInt() );//ShadowLowest;
227  d->offsetAngle = layer->customProperty( QStringLiteral( "labeling/shadowOffsetAngle" ), QVariant( 135 ) ).toInt();
228  d->offsetDist = layer->customProperty( QStringLiteral( "labeling/shadowOffsetDist" ), QVariant( 1.0 ) ).toDouble();
229 
230  if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString().isEmpty() )
231  {
232  d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnits" ), 0 ).toUInt() );
233  }
234  else
235  {
236  d->offsetUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString() );
237  }
238  if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString().isEmpty() )
239  {
240  //fallback to older property
241  double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMinScale" ), 0.0 ).toDouble();
242  d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
243  double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
244  d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
245  }
246  else
247  {
248  d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString() );
249  }
250  d->offsetGlobal = layer->customProperty( QStringLiteral( "labeling/shadowOffsetGlobal" ), QVariant( true ) ).toBool();
251  d->radius = layer->customProperty( QStringLiteral( "labeling/shadowRadius" ), QVariant( 1.5 ) ).toDouble();
252 
253  if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString().isEmpty() )
254  {
255  d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnits" ), 0 ).toUInt() );
256  }
257  else
258  {
259  d->radiusUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString() );
260  }
261  if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString().isEmpty() )
262  {
263  //fallback to older property
264  double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMinScale" ), 0.0 ).toDouble();
265  d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
266  double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMaxScale" ), 0.0 ).toDouble();
267  d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
268  }
269  else
270  {
271  d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString() );
272  }
273  d->radiusAlphaOnly = layer->customProperty( QStringLiteral( "labeling/shadowRadiusAlphaOnly" ), QVariant( false ) ).toBool();
274 
275  if ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toString().isEmpty() )
276  {
277  d->opacity = ( 1 - layer->customProperty( QStringLiteral( "labeling/shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
278  }
279  else
280  {
281  d->opacity = ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toDouble() );
282  }
283  d->scale = layer->customProperty( QStringLiteral( "labeling/shadowScale" ), QVariant( 100 ) ).toInt();
284  d->color = QgsTextRendererUtils::readColor( layer, QStringLiteral( "labeling/shadowColor" ), Qt::black, false );
285  d->blendMode = QgsPainting::getCompositionMode(
286  static_cast< QgsPainting::BlendMode >( layer->customProperty( QStringLiteral( "labeling/shadowBlendMode" ), QVariant( QgsPainting::BlendMultiply ) ).toUInt() ) );
287 }
288 
289 void QgsTextShadowSettings::readXml( const QDomElement &elem )
290 {
291  QDomElement shadowElem = elem.firstChildElement( QStringLiteral( "shadow" ) );
292  d->enabled = shadowElem.attribute( QStringLiteral( "shadowDraw" ), QStringLiteral( "0" ) ).toInt();
293  d->shadowUnder = static_cast< ShadowPlacement >( shadowElem.attribute( QStringLiteral( "shadowUnder" ), QString::number( ShadowLowest ) ).toUInt() );//ShadowLowest;
294  d->offsetAngle = shadowElem.attribute( QStringLiteral( "shadowOffsetAngle" ), QStringLiteral( "135" ) ).toInt();
295  d->offsetDist = shadowElem.attribute( QStringLiteral( "shadowOffsetDist" ), QStringLiteral( "1" ) ).toDouble();
296 
297  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetUnit" ) ) )
298  {
299  d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnits" ) ).toUInt() );
300  }
301  else
302  {
303  d->offsetUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnit" ) ) );
304  }
305 
306  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) )
307  {
308  //fallback to older property
309  double oldMin = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
310  d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
311  double oldMax = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
312  d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
313  }
314  else
315  {
316  d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) );
317  }
318  d->offsetGlobal = shadowElem.attribute( QStringLiteral( "shadowOffsetGlobal" ), QStringLiteral( "1" ) ).toInt();
319  d->radius = shadowElem.attribute( QStringLiteral( "shadowRadius" ), QStringLiteral( "1.5" ) ).toDouble();
320 
321  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusUnit" ) ) )
322  {
323  d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnits" ) ).toUInt() );
324  }
325  else
326  {
327  d->radiusUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnit" ) ) );
328  }
329  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) )
330  {
331  //fallback to older property
332  double oldMin = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
333  d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
334  double oldMax = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
335  d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
336  }
337  else
338  {
339  d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) );
340  }
341  d->radiusAlphaOnly = shadowElem.attribute( QStringLiteral( "shadowRadiusAlphaOnly" ), QStringLiteral( "0" ) ).toInt();
342 
343  if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOpacity" ) ) )
344  {
345  d->opacity = ( 1 - shadowElem.attribute( QStringLiteral( "shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
346  }
347  else
348  {
349  d->opacity = ( shadowElem.attribute( QStringLiteral( "shadowOpacity" ) ).toDouble() );
350  }
351  d->scale = shadowElem.attribute( QStringLiteral( "shadowScale" ), QStringLiteral( "100" ) ).toInt();
352  d->color = QgsSymbolLayerUtils::decodeColor( shadowElem.attribute( QStringLiteral( "shadowColor" ), QgsSymbolLayerUtils::encodeColor( Qt::black ) ) );
353  d->blendMode = QgsPainting::getCompositionMode(
354  static_cast< QgsPainting::BlendMode >( shadowElem.attribute( QStringLiteral( "shadowBlendMode" ), QString::number( QgsPainting::BlendMultiply ) ).toUInt() ) );
355 }
356 
357 QDomElement QgsTextShadowSettings::writeXml( QDomDocument &doc ) const
358 {
359  QDomElement shadowElem = doc.createElement( QStringLiteral( "shadow" ) );
360  shadowElem.setAttribute( QStringLiteral( "shadowDraw" ), d->enabled );
361  shadowElem.setAttribute( QStringLiteral( "shadowUnder" ), static_cast< unsigned int >( d->shadowUnder ) );
362  shadowElem.setAttribute( QStringLiteral( "shadowOffsetAngle" ), d->offsetAngle );
363  shadowElem.setAttribute( QStringLiteral( "shadowOffsetDist" ), d->offsetDist );
364  shadowElem.setAttribute( QStringLiteral( "shadowOffsetUnit" ), QgsUnitTypes::encodeUnit( d->offsetUnits ) );
365  shadowElem.setAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->offsetMapUnitScale ) );
366  shadowElem.setAttribute( QStringLiteral( "shadowOffsetGlobal" ), d->offsetGlobal );
367  shadowElem.setAttribute( QStringLiteral( "shadowRadius" ), d->radius );
368  shadowElem.setAttribute( QStringLiteral( "shadowRadiusUnit" ), QgsUnitTypes::encodeUnit( d->radiusUnits ) );
369  shadowElem.setAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->radiusMapUnitScale ) );
370  shadowElem.setAttribute( QStringLiteral( "shadowRadiusAlphaOnly" ), d->radiusAlphaOnly );
371  shadowElem.setAttribute( QStringLiteral( "shadowOpacity" ), d->opacity );
372  shadowElem.setAttribute( QStringLiteral( "shadowScale" ), d->scale );
373  shadowElem.setAttribute( QStringLiteral( "shadowColor" ), QgsSymbolLayerUtils::encodeColor( d->color ) );
374  shadowElem.setAttribute( QStringLiteral( "shadowBlendMode" ), QgsPainting::getBlendModeEnum( d->blendMode ) );
375  return shadowElem;
376 }
377 
379 {
380  if ( properties.isActive( QgsPalLayerSettings::ShadowDraw ) )
381  {
382  context.expressionContext().setOriginalValueVariable( d->enabled );
383  d->enabled = properties.valueAsBool( QgsPalLayerSettings::ShadowDraw, context.expressionContext(), d->enabled );
384  }
385 
386  // data defined shadow under type?
387  QVariant exprVal = properties.value( QgsPalLayerSettings::ShadowUnder, context.expressionContext() );
388  if ( exprVal.isValid() )
389  {
390  QString str = exprVal.toString().trimmed();
391  if ( !str.isEmpty() )
392  {
393  d->shadowUnder = QgsTextRendererUtils::decodeShadowPlacementType( str );
394  }
395  }
396 
398  {
399  context.expressionContext().setOriginalValueVariable( d->offsetAngle );
400  d->offsetAngle = properties.valueAsInt( QgsPalLayerSettings::ShadowOffsetAngle, context.expressionContext(), d->offsetAngle );
401  }
403  {
404  context.expressionContext().setOriginalValueVariable( d->offsetDist );
405  d->offsetDist = properties.valueAsDouble( QgsPalLayerSettings::ShadowOffsetDist, context.expressionContext(), d->offsetDist );
406  }
407 
408  exprVal = properties.value( QgsPalLayerSettings::ShadowOffsetUnits, context.expressionContext() );
409  if ( exprVal.isValid() )
410  {
411  QString units = exprVal.toString();
412  if ( !units.isEmpty() )
413  {
414  bool ok;
416  if ( ok )
417  d->offsetUnits = res;
418  }
419  }
420 
421  if ( properties.isActive( QgsPalLayerSettings::ShadowRadius ) )
422  {
423  context.expressionContext().setOriginalValueVariable( d->radius );
424  d->radius = properties.valueAsDouble( QgsPalLayerSettings::ShadowRadius, context.expressionContext(), d->radius );
425  }
426 
427  exprVal = properties.value( QgsPalLayerSettings::ShadowRadiusUnits, context.expressionContext() );
428  if ( exprVal.isValid() )
429  {
430  QString units = exprVal.toString();
431  if ( !units.isEmpty() )
432  {
433  bool ok;
435  if ( ok )
436  d->radiusUnits = res;
437  }
438  }
439 
440  if ( properties.isActive( QgsPalLayerSettings::ShadowOpacity ) )
441  {
442  context.expressionContext().setOriginalValueVariable( d->opacity * 100 );
443  d->opacity = properties.value( QgsPalLayerSettings::ShadowOpacity, context.expressionContext(), d->opacity * 100 ).toDouble() / 100.0;
444  }
445 
446  if ( properties.isActive( QgsPalLayerSettings::ShadowScale ) )
447  {
448  context.expressionContext().setOriginalValueVariable( d->scale );
449  d->scale = properties.valueAsInt( QgsPalLayerSettings::ShadowScale, context.expressionContext(), d->scale );
450  }
451 
452  if ( properties.isActive( QgsPalLayerSettings::ShadowColor ) )
453  {
455  d->color = properties.valueAsColor( QgsPalLayerSettings::ShadowColor, context.expressionContext(), d->color );
456  }
457 
459  {
460  exprVal = properties.value( QgsPalLayerSettings::ShadowBlendMode, context.expressionContext() );
461  QString blendstr = exprVal.toString().trimmed();
462  if ( !blendstr.isEmpty() )
463  d->blendMode = QgsSymbolLayerUtils::decodeBlendMode( blendstr );
464  }
465 }
466 
468 {
469  return QSet< QString >(); // nothing for now
470 }
QgsPalLayerSettings::ShadowBlendMode
@ ShadowBlendMode
Definition: qgspallabeling.h:430
QgsPalLayerSettings::ShadowRadius
@ ShadowRadius
Definition: qgspallabeling.h:424
QgsTextShadowSettings::readFromLayer
void readFromLayer(QgsVectorLayer *layer)
Reads settings from a layer's custom properties (for QGIS 2.x projects).
Definition: qgstextshadowsettings.cpp:223
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:188
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:103
QgsTextShadowSettings::setEnabled
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
Definition: qgstextshadowsettings.cpp:78
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
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:596
QgsPainting::BlendMode
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Definition: qgspainting.h:37
QgsTextShadowSettings::blurRadiusMapUnitScale
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
Definition: qgstextshadowsettings.cpp:163
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:113
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:289
qgstextshadowsettings.h
QgsTextShadowSettings::scale
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
Definition: qgstextshadowsettings.cpp:193
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsTextShadowSettings::setOffsetMapUnitScale
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
Definition: qgstextshadowsettings.cpp:128
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:423
QgsTextShadowSettings::~QgsTextShadowSettings
~QgsTextShadowSettings()
Definition: qgstextshadowsettings.cpp:41
QgsTextShadowSettings::blurRadius
double blurRadius() const
Returns the blur radius for the shadow.
Definition: qgstextshadowsettings.cpp:143
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:108
QgsTextShadowSettings::setOffsetAngle
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:98
QgsTextShadowSettings::enabled
bool enabled() const
Returns whether the shadow is enabled.
Definition: qgstextshadowsettings.cpp:73
QgsTextShadowSettings::writeXml
QDomElement writeXml(QDomDocument &doc) const
Write settings into a DOM element.
Definition: qgstextshadowsettings.cpp:357
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:173
qgstextrendererutils.h
QgsTextShadowSettings::blendMode
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
Definition: qgstextshadowsettings.cpp:213
QgsTextShadowSettings::ShadowPlacement
ShadowPlacement
Placement positions for text shadow.
Definition: qgstextshadowsettings.h:45
QgsTextShadowSettings::updateDataDefinedProperties
void updateDataDefinedProperties(QgsRenderContext &context, const QgsPropertyCollection &properties)
Updates the format by evaluating current values of data defined properties.
Definition: qgstextshadowsettings.cpp:378
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:420
QgsTextShadowSettings::setColor
void setColor(const QColor &color)
Sets the color for the drop shadow.
Definition: qgstextshadowsettings.cpp:208
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:123
QgsTextShadowSettings::color
QColor color() const
Returns the color of the drop shadow.
Definition: qgstextshadowsettings.cpp:203
QgsTextShadowSettings::setBlurRadius
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
Definition: qgstextshadowsettings.cpp:148
qgspainting.h
QgsTextShadowSettings::setShadowPlacement
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:88
QgsTextShadowSettings::offsetGlobal
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
Definition: qgstextshadowsettings.cpp:133
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:38
QgsTextShadowSettings::setScale
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
Definition: qgstextshadowsettings.cpp:198
QgsTextShadowSettings::setOffsetGlobal
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
Definition: qgstextshadowsettings.cpp:138
QgsPalLayerSettings::ShadowColor
@ ShadowColor
Definition: qgspallabeling.h:429
QgsTextShadowSettings::setOffsetUnit
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's offset.
Definition: qgstextshadowsettings.cpp:118
QgsTextShadowSettings::offsetAngle
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
Definition: qgstextshadowsettings.cpp:93
qgsvectorlayer.h
QgsPalLayerSettings::ShadowScale
@ ShadowScale
Definition: qgspallabeling.h:428
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:319
QgsTextShadowSettings::setBlurRadiusUnit
void setBlurRadiusUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's blur radius.
Definition: qgstextshadowsettings.cpp:158
QgsPalLayerSettings::ShadowOffsetAngle
@ ShadowOffsetAngle
Definition: qgspallabeling.h:421
QgsTextShadowSettings
Container for settings relating to a text shadow.
Definition: qgstextshadowsettings.h:38
QgsPalLayerSettings::ShadowOffsetDist
@ ShadowOffsetDist
Definition: qgspallabeling.h:422
QgsMapLayer::customProperty
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Definition: qgsmaplayer.cpp:1723
QgsTextShadowSettings::setBlurAlphaOnly
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
Definition: qgstextshadowsettings.cpp:178
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:228
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
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsTextShadowSettings::referencedFields
QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns all field names referenced by the configuration (e.g.
Definition: qgstextshadowsettings.cpp:467
QgsPalLayerSettings::ShadowOpacity
@ ShadowOpacity
Shadow opacity.
Definition: qgspallabeling.h:427
QgsTextShadowSettings::opacity
double opacity() const
Returns the shadow's opacity.
Definition: qgstextshadowsettings.cpp:183
QgsTextShadowSettings::setBlurRadiusMapUnitScale
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
Definition: qgstextshadowsettings.cpp:168
QgsPalLayerSettings::ShadowRadiusUnits
@ ShadowRadiusUnits
Definition: qgspallabeling.h:425
QgsPainting::BlendMultiply
@ BlendMultiply
Definition: qgspainting.h:44
QgsTextShadowSettings::operator==
bool operator==(const QgsTextShadowSettings &other) const
Definition: qgstextshadowsettings.cpp:46
QgsTextShadowSettings::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
Definition: qgstextshadowsettings.cpp:218
QgsTextShadowSettings::shadowPlacement
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:83
QgsPropertyCollection::isActive
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition: qgspropertycollection.cpp:268
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:419
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::operator!=
bool operator!=(const QgsTextShadowSettings &other) const
Definition: qgstextshadowsettings.cpp:68
QgsTextShadowSettings::blurRadiusUnit
QgsUnitTypes::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
Definition: qgstextshadowsettings.cpp:153
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