QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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
17
18#include "qgscolorutils.h"
19#include "qgspainting.h"
20#include "qgspallabeling.h"
21#include "qgssymbollayerutils.h"
22#include "qgstextrenderer_p.h"
24#include "qgsunittypes.h"
25#include "qgsvectorlayer.h"
26
28{
29 d = new QgsTextShadowSettingsPrivate();
30}
31
33 : d( other.d )
34{
35
36}
37
39 : d( std::move( other.d ) )
40{
41
42}
43
45{
46 if ( &other == this )
47 return *this;
48
49 d = other.d;
50 return *this;
51}
52
54{
55 if ( &other == this )
56 return *this;
57
58 d = std::move( other.d );
59 return *this;
60}
61
62
67
69{
70 if ( d->enabled != other.enabled()
71 || d->shadowUnder != other.shadowPlacement()
72 || d->offsetAngle != other.offsetAngle()
73 || d->offsetDist != other.offsetDistance()
74 || d->offsetUnits != other.offsetUnit()
75 || d->offsetMapUnitScale != other.offsetMapUnitScale()
76 || d->offsetGlobal != other.offsetGlobal()
77 || d->radius != other.blurRadius()
78 || d->radiusUnits != other.blurRadiusUnit()
79 || d->radiusMapUnitScale != other.blurRadiusMapUnitScale()
80 || d->radiusAlphaOnly != other.blurAlphaOnly()
81 || d->scale != other.scale()
82 || d->color != other.color()
83 || d->opacity != other.opacity()
84 || d->blendMode != other.blendMode() )
85 return false;
86
87 return true;
88}
89
91{
92 return !( *this == other );
93}
94
96{
97 return d->enabled;
98}
99
101{
102 d->enabled = enabled;
103}
104
109
111{
112 d->shadowUnder = placement;
113}
114
116{
117 return d->offsetAngle;
118}
119
121{
122 d->offsetAngle = angle;
123}
124
126{
127 return d->offsetDist;
128}
129
131{
132 d->offsetDist = distance;
133}
134
136{
137 return d->offsetUnits;
138}
139
141{
142 d->offsetUnits = units;
143}
144
146{
147 return d->offsetMapUnitScale;
148}
149
151{
152 d->offsetMapUnitScale = scale;
153}
154
156{
157 return d->offsetGlobal;
158}
159
161{
162 d->offsetGlobal = global;
163}
164
166{
167 return d->radius;
168}
169
171{
172 d->radius = radius;
173}
174
176{
177 return d->radiusUnits;
178}
179
181{
182 d->radiusUnits = units;
183}
184
186{
187 return d->radiusMapUnitScale;
188}
189
191{
192 d->radiusMapUnitScale = scale;
193}
194
196{
197 return d->radiusAlphaOnly;
198}
199
201{
202 d->radiusAlphaOnly = alphaOnly;
203}
204
206{
207 return d->opacity;
208}
209
211{
212 d->opacity = opacity;
213}
214
216{
217 return d->scale;
218}
219
221{
222 d->scale = scale;
223}
224
226{
227 return d->color;
228}
229
231{
232 d->color = color;
233}
234
235QPainter::CompositionMode QgsTextShadowSettings::blendMode() const
236{
237 return d->blendMode;
238}
239
240void QgsTextShadowSettings::setBlendMode( QPainter::CompositionMode mode )
241{
242 d->blendMode = mode;
243}
244
246{
247 d->enabled = layer->customProperty( QStringLiteral( "labeling/shadowDraw" ), QVariant( false ) ).toBool();
248 d->shadowUnder = static_cast< ShadowPlacement >( layer->customProperty( QStringLiteral( "labeling/shadowUnder" ), QVariant( ShadowLowest ) ).toUInt() );//ShadowLowest;
249 d->offsetAngle = layer->customProperty( QStringLiteral( "labeling/shadowOffsetAngle" ), QVariant( 135 ) ).toInt();
250 d->offsetDist = layer->customProperty( QStringLiteral( "labeling/shadowOffsetDist" ), QVariant( 1.0 ) ).toDouble();
251
252 if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString().isEmpty() )
253 {
254 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnits" ), 0 ).toUInt() );
255 }
256 else
257 {
258 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString() );
259 }
260 if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString().isEmpty() )
261 {
262 //fallback to older property
263 const double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMinScale" ), 0.0 ).toDouble();
264 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
265 const double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
266 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
267 }
268 else
269 {
270 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString() );
271 }
272 d->offsetGlobal = layer->customProperty( QStringLiteral( "labeling/shadowOffsetGlobal" ), QVariant( true ) ).toBool();
273 d->radius = layer->customProperty( QStringLiteral( "labeling/shadowRadius" ), QVariant( 1.5 ) ).toDouble();
274
275 if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString().isEmpty() )
276 {
277 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnits" ), 0 ).toUInt() );
278 }
279 else
280 {
281 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString() );
282 }
283 if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString().isEmpty() )
284 {
285 //fallback to older property
286 const double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMinScale" ), 0.0 ).toDouble();
287 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
288 const double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMaxScale" ), 0.0 ).toDouble();
289 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
290 }
291 else
292 {
293 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString() );
294 }
295 d->radiusAlphaOnly = layer->customProperty( QStringLiteral( "labeling/shadowRadiusAlphaOnly" ), QVariant( false ) ).toBool();
296
297 if ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toString().isEmpty() )
298 {
299 d->opacity = ( 1 - layer->customProperty( QStringLiteral( "labeling/shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
300 }
301 else
302 {
303 d->opacity = ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toDouble() );
304 }
305 d->scale = layer->customProperty( QStringLiteral( "labeling/shadowScale" ), QVariant( 100 ) ).toInt();
306 d->color = QgsTextRendererUtils::readColor( layer, QStringLiteral( "labeling/shadowColor" ), Qt::black, false );
307 d->blendMode = QgsPainting::getCompositionMode(
308 static_cast< Qgis::BlendMode >( layer->customProperty( QStringLiteral( "labeling/shadowBlendMode" ), QVariant( static_cast< int >( Qgis::BlendMode::Multiply ) ) ).toUInt() ) );
309}
310
311void QgsTextShadowSettings::readXml( const QDomElement &elem )
312{
313 const QDomElement shadowElem = elem.firstChildElement( QStringLiteral( "shadow" ) );
314 d->enabled = shadowElem.attribute( QStringLiteral( "shadowDraw" ), QStringLiteral( "0" ) ).toInt();
315 d->shadowUnder = static_cast< ShadowPlacement >( shadowElem.attribute( QStringLiteral( "shadowUnder" ), QString::number( ShadowLowest ) ).toUInt() );//ShadowLowest;
316 d->offsetAngle = shadowElem.attribute( QStringLiteral( "shadowOffsetAngle" ), QStringLiteral( "135" ) ).toInt();
317 d->offsetDist = shadowElem.attribute( QStringLiteral( "shadowOffsetDist" ), QStringLiteral( "1" ) ).toDouble();
318
319 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetUnit" ) ) )
320 {
321 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnits" ) ).toUInt() );
322 }
323 else
324 {
325 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnit" ) ) );
326 }
327
328 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) )
329 {
330 //fallback to older property
331 const double oldMin = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
332 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
333 const double oldMax = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
334 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
335 }
336 else
337 {
338 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) );
339 }
340 d->offsetGlobal = shadowElem.attribute( QStringLiteral( "shadowOffsetGlobal" ), QStringLiteral( "1" ) ).toInt();
341 d->radius = shadowElem.attribute( QStringLiteral( "shadowRadius" ), QStringLiteral( "1.5" ) ).toDouble();
342
343 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusUnit" ) ) )
344 {
345 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnits" ) ).toUInt() );
346 }
347 else
348 {
349 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnit" ) ) );
350 }
351 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) )
352 {
353 //fallback to older property
354 const double oldMin = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
355 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
356 const double oldMax = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
357 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
358 }
359 else
360 {
361 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) );
362 }
363 d->radiusAlphaOnly = shadowElem.attribute( QStringLiteral( "shadowRadiusAlphaOnly" ), QStringLiteral( "0" ) ).toInt();
364
365 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOpacity" ) ) )
366 {
367 d->opacity = ( 1 - shadowElem.attribute( QStringLiteral( "shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
368 }
369 else
370 {
371 d->opacity = ( shadowElem.attribute( QStringLiteral( "shadowOpacity" ) ).toDouble() );
372 }
373 d->scale = shadowElem.attribute( QStringLiteral( "shadowScale" ), QStringLiteral( "100" ) ).toInt();
374 d->color = QgsColorUtils::colorFromString( shadowElem.attribute( QStringLiteral( "shadowColor" ), QgsColorUtils::colorToString( Qt::black ) ) );
375 d->blendMode = QgsPainting::getCompositionMode(
376 static_cast< Qgis::BlendMode >( shadowElem.attribute( QStringLiteral( "shadowBlendMode" ), QString::number( static_cast<int>( Qgis::BlendMode::Multiply ) ) ).toUInt() ) );
377}
378
379QDomElement QgsTextShadowSettings::writeXml( QDomDocument &doc ) const
380{
381 QDomElement shadowElem = doc.createElement( QStringLiteral( "shadow" ) );
382 shadowElem.setAttribute( QStringLiteral( "shadowDraw" ), d->enabled );
383 shadowElem.setAttribute( QStringLiteral( "shadowUnder" ), static_cast< unsigned int >( d->shadowUnder ) );
384 shadowElem.setAttribute( QStringLiteral( "shadowOffsetAngle" ), d->offsetAngle );
385 shadowElem.setAttribute( QStringLiteral( "shadowOffsetDist" ), d->offsetDist );
386 shadowElem.setAttribute( QStringLiteral( "shadowOffsetUnit" ), QgsUnitTypes::encodeUnit( d->offsetUnits ) );
387 shadowElem.setAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->offsetMapUnitScale ) );
388 shadowElem.setAttribute( QStringLiteral( "shadowOffsetGlobal" ), d->offsetGlobal );
389 shadowElem.setAttribute( QStringLiteral( "shadowRadius" ), d->radius );
390 shadowElem.setAttribute( QStringLiteral( "shadowRadiusUnit" ), QgsUnitTypes::encodeUnit( d->radiusUnits ) );
391 shadowElem.setAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->radiusMapUnitScale ) );
392 shadowElem.setAttribute( QStringLiteral( "shadowRadiusAlphaOnly" ), d->radiusAlphaOnly );
393 shadowElem.setAttribute( QStringLiteral( "shadowOpacity" ), d->opacity );
394 shadowElem.setAttribute( QStringLiteral( "shadowScale" ), d->scale );
395 shadowElem.setAttribute( QStringLiteral( "shadowColor" ), QgsColorUtils::colorToString( d->color ) );
396 shadowElem.setAttribute( QStringLiteral( "shadowBlendMode" ), static_cast< int >( QgsPainting::getBlendModeEnum( d->blendMode ) ) );
397 return shadowElem;
398}
399
401{
403 {
404 context.expressionContext().setOriginalValueVariable( d->enabled );
405 d->enabled = properties.valueAsBool( QgsPalLayerSettings::Property::ShadowDraw, context.expressionContext(), d->enabled );
406 }
407
408 // data defined shadow under type?
409 QVariant exprVal = properties.value( QgsPalLayerSettings::Property::ShadowUnder, context.expressionContext() );
410 if ( !QgsVariantUtils::isNull( exprVal ) )
411 {
412 const QString str = exprVal.toString().trimmed();
413 if ( !str.isEmpty() )
414 {
416 }
417 }
418
420 {
421 context.expressionContext().setOriginalValueVariable( d->offsetAngle );
422 d->offsetAngle = properties.valueAsInt( QgsPalLayerSettings::Property::ShadowOffsetAngle, context.expressionContext(), d->offsetAngle );
423 }
425 {
426 context.expressionContext().setOriginalValueVariable( d->offsetDist );
427 d->offsetDist = properties.valueAsDouble( QgsPalLayerSettings::Property::ShadowOffsetDist, context.expressionContext(), d->offsetDist );
428 }
429
431 if ( !QgsVariantUtils::isNull( exprVal ) )
432 {
433 const QString units = exprVal.toString();
434 if ( !units.isEmpty() )
435 {
436 bool ok;
437 const Qgis::RenderUnit res = QgsUnitTypes::decodeRenderUnit( units, &ok );
438 if ( ok )
439 d->offsetUnits = res;
440 }
441 }
442
444 {
445 context.expressionContext().setOriginalValueVariable( d->radius );
446 d->radius = properties.valueAsDouble( QgsPalLayerSettings::Property::ShadowRadius, context.expressionContext(), d->radius );
447 }
448
450 if ( !QgsVariantUtils::isNull( exprVal ) )
451 {
452 const QString units = exprVal.toString();
453 if ( !units.isEmpty() )
454 {
455 bool ok;
456 const Qgis::RenderUnit res = QgsUnitTypes::decodeRenderUnit( units, &ok );
457 if ( ok )
458 d->radiusUnits = res;
459 }
460 }
461
463 {
464 context.expressionContext().setOriginalValueVariable( d->opacity * 100 );
465 const QVariant val = properties.value( QgsPalLayerSettings::Property::ShadowOpacity, context.expressionContext(), d->opacity * 100 );
466 if ( !QgsVariantUtils::isNull( val ) )
467 {
468 d->opacity = val.toDouble() / 100.0;
469 }
470 }
471
473 {
474 context.expressionContext().setOriginalValueVariable( d->scale );
475 d->scale = properties.valueAsInt( QgsPalLayerSettings::Property::ShadowScale, context.expressionContext(), d->scale );
476 }
477
479 {
481 d->color = properties.valueAsColor( QgsPalLayerSettings::Property::ShadowColor, context.expressionContext(), d->color );
482 }
483
485 {
487 const QString blendstr = exprVal.toString().trimmed();
488 if ( !blendstr.isEmpty() )
489 d->blendMode = QgsSymbolLayerUtils::decodeBlendMode( blendstr );
490 }
491}
492
494{
495 return QSet< QString >(); // nothing for now
496}
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition qgis.h:4930
@ Multiply
Multiple.
Definition qgis.h:4937
RenderUnit
Rendering size units.
Definition qgis.h:5183
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.
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.
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.
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.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Struct for storing maximum and minimum scales for measurements in map units.
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const final
Returns the calculated value of the property with the specified key from within the collection.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
Contains information about the context of a rendering operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static QPainter::CompositionMode decodeBlendMode(const QString &s)
static QString encodeColor(const QColor &color)
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.
static QgsTextShadowSettings::ShadowPlacement decodeShadowPlacementType(const QString &string)
Decodes a string representation of a shadow placement type to a type.
static Qgis::RenderUnit convertFromOldLabelUnit(int val)
Converts a unit from an old (pre 3.0) label unit.
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
void setBlurRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow blur radius.
QgsTextShadowSettings & operator=(const QgsTextShadowSettings &other)
void setBlurRadiusUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's blur radius.
bool enabled() const
Returns whether the shadow is enabled.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's offset.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
Qgis::RenderUnit offsetUnit() const
Returns the units used for the shadow's offset.
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
double opacity() const
Returns the shadow's opacity.
QgsMapUnitScale blurRadiusMapUnitScale() const
Returns the map unit scale object for the shadow blur radius.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shadow offset distance.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
void setColor(const QColor &color)
Sets the color for the drop shadow.
QColor color() const
Returns the color of the drop shadow.
void readXml(const QDomElement &elem)
Read settings from a DOM element.
void setOffsetGlobal(bool global)
Sets whether the global shadow offset should be used.
ShadowPlacement
Placement positions for text shadow.
@ ShadowLowest
Draw shadow below all text components.
QDomElement writeXml(QDomDocument &doc) const
Write settings into a DOM element.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
void setBlurAlphaOnly(bool alphaOnly)
Sets whether only the alpha channel for the shadow should be blurred.
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
Qgis::RenderUnit blurRadiusUnit() const
Returns the units used for the shadow's blur radius.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
void updateDataDefinedProperties(QgsRenderContext &context, const QgsPropertyCollection &properties)
Updates the format by evaluating current values of data defined properties.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the drop shadow.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
void setOpacity(double opacity)
Sets the shadow's opacity.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shadow offset distance.
bool operator==(const QgsTextShadowSettings &other) const
QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns all field names referenced by the configuration (e.g.
bool blurAlphaOnly() const
Returns whether only the alpha channel for the shadow will be blurred.
bool offsetGlobal() const
Returns true if the global shadow offset will be used.
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
bool operator!=(const QgsTextShadowSettings &other) const
double blurRadius() const
Returns the blur radius for the shadow.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
void readFromLayer(QgsVectorLayer *layer)
Reads settings from a layer's custom properties (for QGIS 2.x projects).
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based dataset.