QGIS API Documentation 3.41.0-Master (af5edcb665c)
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#include "qgstextrenderer_p.h"
18#include "qgsvectorlayer.h"
19#include "qgssymbollayerutils.h"
20#include "qgspainting.h"
21#include "qgspallabeling.h"
23#include "qgsunittypes.h"
24#include "qgscolorutils.h"
25
27{
28 d = new QgsTextShadowSettingsPrivate();
29}
30
32 : d( other.d )
33{
34
35}
36
38{
39 d = other.d;
40 return *this;
41}
42
47
49{
50 if ( d->enabled != other.enabled()
51 || d->shadowUnder != other.shadowPlacement()
52 || d->offsetAngle != other.offsetAngle()
53 || d->offsetDist != other.offsetDistance()
54 || d->offsetUnits != other.offsetUnit()
55 || d->offsetMapUnitScale != other.offsetMapUnitScale()
56 || d->offsetGlobal != other.offsetGlobal()
57 || d->radius != other.blurRadius()
58 || d->radiusUnits != other.blurRadiusUnit()
59 || d->radiusMapUnitScale != other.blurRadiusMapUnitScale()
60 || d->radiusAlphaOnly != other.blurAlphaOnly()
61 || d->scale != other.scale()
62 || d->color != other.color()
63 || d->opacity != other.opacity()
64 || d->blendMode != other.blendMode() )
65 return false;
66
67 return true;
68}
69
71{
72 return !( *this == other );
73}
74
76{
77 return d->enabled;
78}
79
81{
82 d->enabled = enabled;
83}
84
89
91{
92 d->shadowUnder = placement;
93}
94
96{
97 return d->offsetAngle;
98}
99
101{
102 d->offsetAngle = angle;
103}
104
106{
107 return d->offsetDist;
108}
109
111{
112 d->offsetDist = distance;
113}
114
116{
117 return d->offsetUnits;
118}
119
121{
122 d->offsetUnits = units;
123}
124
126{
127 return d->offsetMapUnitScale;
128}
129
131{
132 d->offsetMapUnitScale = scale;
133}
134
136{
137 return d->offsetGlobal;
138}
139
141{
142 d->offsetGlobal = global;
143}
144
146{
147 return d->radius;
148}
149
151{
152 d->radius = radius;
153}
154
156{
157 return d->radiusUnits;
158}
159
161{
162 d->radiusUnits = units;
163}
164
166{
167 return d->radiusMapUnitScale;
168}
169
171{
172 d->radiusMapUnitScale = scale;
173}
174
176{
177 return d->radiusAlphaOnly;
178}
179
181{
182 d->radiusAlphaOnly = alphaOnly;
183}
184
186{
187 return d->opacity;
188}
189
191{
192 d->opacity = opacity;
193}
194
196{
197 return d->scale;
198}
199
201{
202 d->scale = scale;
203}
204
206{
207 return d->color;
208}
209
210void QgsTextShadowSettings::setColor( const QColor &color )
211{
212 d->color = color;
213}
214
215QPainter::CompositionMode QgsTextShadowSettings::blendMode() const
216{
217 return d->blendMode;
218}
219
220void QgsTextShadowSettings::setBlendMode( QPainter::CompositionMode mode )
221{
222 d->blendMode = mode;
223}
224
226{
227 d->enabled = layer->customProperty( QStringLiteral( "labeling/shadowDraw" ), QVariant( false ) ).toBool();
228 d->shadowUnder = static_cast< ShadowPlacement >( layer->customProperty( QStringLiteral( "labeling/shadowUnder" ), QVariant( ShadowLowest ) ).toUInt() );//ShadowLowest;
229 d->offsetAngle = layer->customProperty( QStringLiteral( "labeling/shadowOffsetAngle" ), QVariant( 135 ) ).toInt();
230 d->offsetDist = layer->customProperty( QStringLiteral( "labeling/shadowOffsetDist" ), QVariant( 1.0 ) ).toDouble();
231
232 if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString().isEmpty() )
233 {
234 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnits" ), 0 ).toUInt() );
235 }
236 else
237 {
238 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString() );
239 }
240 if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString().isEmpty() )
241 {
242 //fallback to older property
243 const double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMinScale" ), 0.0 ).toDouble();
244 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
245 const double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
246 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
247 }
248 else
249 {
250 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString() );
251 }
252 d->offsetGlobal = layer->customProperty( QStringLiteral( "labeling/shadowOffsetGlobal" ), QVariant( true ) ).toBool();
253 d->radius = layer->customProperty( QStringLiteral( "labeling/shadowRadius" ), QVariant( 1.5 ) ).toDouble();
254
255 if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString().isEmpty() )
256 {
257 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnits" ), 0 ).toUInt() );
258 }
259 else
260 {
261 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString() );
262 }
263 if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString().isEmpty() )
264 {
265 //fallback to older property
266 const double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMinScale" ), 0.0 ).toDouble();
267 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
268 const double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMaxScale" ), 0.0 ).toDouble();
269 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
270 }
271 else
272 {
273 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString() );
274 }
275 d->radiusAlphaOnly = layer->customProperty( QStringLiteral( "labeling/shadowRadiusAlphaOnly" ), QVariant( false ) ).toBool();
276
277 if ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toString().isEmpty() )
278 {
279 d->opacity = ( 1 - layer->customProperty( QStringLiteral( "labeling/shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
280 }
281 else
282 {
283 d->opacity = ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toDouble() );
284 }
285 d->scale = layer->customProperty( QStringLiteral( "labeling/shadowScale" ), QVariant( 100 ) ).toInt();
286 d->color = QgsTextRendererUtils::readColor( layer, QStringLiteral( "labeling/shadowColor" ), Qt::black, false );
287 d->blendMode = QgsPainting::getCompositionMode(
288 static_cast< Qgis::BlendMode >( layer->customProperty( QStringLiteral( "labeling/shadowBlendMode" ), QVariant( static_cast< int >( Qgis::BlendMode::Multiply ) ) ).toUInt() ) );
289}
290
291void QgsTextShadowSettings::readXml( const QDomElement &elem )
292{
293 const QDomElement shadowElem = elem.firstChildElement( QStringLiteral( "shadow" ) );
294 d->enabled = shadowElem.attribute( QStringLiteral( "shadowDraw" ), QStringLiteral( "0" ) ).toInt();
295 d->shadowUnder = static_cast< ShadowPlacement >( shadowElem.attribute( QStringLiteral( "shadowUnder" ), QString::number( ShadowLowest ) ).toUInt() );//ShadowLowest;
296 d->offsetAngle = shadowElem.attribute( QStringLiteral( "shadowOffsetAngle" ), QStringLiteral( "135" ) ).toInt();
297 d->offsetDist = shadowElem.attribute( QStringLiteral( "shadowOffsetDist" ), QStringLiteral( "1" ) ).toDouble();
298
299 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetUnit" ) ) )
300 {
301 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnits" ) ).toUInt() );
302 }
303 else
304 {
305 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnit" ) ) );
306 }
307
308 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) )
309 {
310 //fallback to older property
311 const double oldMin = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
312 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
313 const double oldMax = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
314 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
315 }
316 else
317 {
318 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) );
319 }
320 d->offsetGlobal = shadowElem.attribute( QStringLiteral( "shadowOffsetGlobal" ), QStringLiteral( "1" ) ).toInt();
321 d->radius = shadowElem.attribute( QStringLiteral( "shadowRadius" ), QStringLiteral( "1.5" ) ).toDouble();
322
323 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusUnit" ) ) )
324 {
325 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnits" ) ).toUInt() );
326 }
327 else
328 {
329 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnit" ) ) );
330 }
331 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) )
332 {
333 //fallback to older property
334 const double oldMin = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
335 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
336 const double oldMax = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
337 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
338 }
339 else
340 {
341 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) );
342 }
343 d->radiusAlphaOnly = shadowElem.attribute( QStringLiteral( "shadowRadiusAlphaOnly" ), QStringLiteral( "0" ) ).toInt();
344
345 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOpacity" ) ) )
346 {
347 d->opacity = ( 1 - shadowElem.attribute( QStringLiteral( "shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
348 }
349 else
350 {
351 d->opacity = ( shadowElem.attribute( QStringLiteral( "shadowOpacity" ) ).toDouble() );
352 }
353 d->scale = shadowElem.attribute( QStringLiteral( "shadowScale" ), QStringLiteral( "100" ) ).toInt();
354 d->color = QgsColorUtils::colorFromString( shadowElem.attribute( QStringLiteral( "shadowColor" ), QgsColorUtils::colorToString( Qt::black ) ) );
355 d->blendMode = QgsPainting::getCompositionMode(
356 static_cast< Qgis::BlendMode >( shadowElem.attribute( QStringLiteral( "shadowBlendMode" ), QString::number( static_cast<int>( Qgis::BlendMode::Multiply ) ) ).toUInt() ) );
357}
358
359QDomElement QgsTextShadowSettings::writeXml( QDomDocument &doc ) const
360{
361 QDomElement shadowElem = doc.createElement( QStringLiteral( "shadow" ) );
362 shadowElem.setAttribute( QStringLiteral( "shadowDraw" ), d->enabled );
363 shadowElem.setAttribute( QStringLiteral( "shadowUnder" ), static_cast< unsigned int >( d->shadowUnder ) );
364 shadowElem.setAttribute( QStringLiteral( "shadowOffsetAngle" ), d->offsetAngle );
365 shadowElem.setAttribute( QStringLiteral( "shadowOffsetDist" ), d->offsetDist );
366 shadowElem.setAttribute( QStringLiteral( "shadowOffsetUnit" ), QgsUnitTypes::encodeUnit( d->offsetUnits ) );
367 shadowElem.setAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->offsetMapUnitScale ) );
368 shadowElem.setAttribute( QStringLiteral( "shadowOffsetGlobal" ), d->offsetGlobal );
369 shadowElem.setAttribute( QStringLiteral( "shadowRadius" ), d->radius );
370 shadowElem.setAttribute( QStringLiteral( "shadowRadiusUnit" ), QgsUnitTypes::encodeUnit( d->radiusUnits ) );
371 shadowElem.setAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->radiusMapUnitScale ) );
372 shadowElem.setAttribute( QStringLiteral( "shadowRadiusAlphaOnly" ), d->radiusAlphaOnly );
373 shadowElem.setAttribute( QStringLiteral( "shadowOpacity" ), d->opacity );
374 shadowElem.setAttribute( QStringLiteral( "shadowScale" ), d->scale );
375 shadowElem.setAttribute( QStringLiteral( "shadowColor" ), QgsColorUtils::colorToString( d->color ) );
376 shadowElem.setAttribute( QStringLiteral( "shadowBlendMode" ), static_cast< int >( QgsPainting::getBlendModeEnum( d->blendMode ) ) );
377 return shadowElem;
378}
379
381{
383 {
384 context.expressionContext().setOriginalValueVariable( d->enabled );
385 d->enabled = properties.valueAsBool( QgsPalLayerSettings::Property::ShadowDraw, context.expressionContext(), d->enabled );
386 }
387
388 // data defined shadow under type?
389 QVariant exprVal = properties.value( QgsPalLayerSettings::Property::ShadowUnder, context.expressionContext() );
390 if ( !QgsVariantUtils::isNull( exprVal ) )
391 {
392 const QString str = exprVal.toString().trimmed();
393 if ( !str.isEmpty() )
394 {
396 }
397 }
398
400 {
401 context.expressionContext().setOriginalValueVariable( d->offsetAngle );
402 d->offsetAngle = properties.valueAsInt( QgsPalLayerSettings::Property::ShadowOffsetAngle, context.expressionContext(), d->offsetAngle );
403 }
405 {
406 context.expressionContext().setOriginalValueVariable( d->offsetDist );
407 d->offsetDist = properties.valueAsDouble( QgsPalLayerSettings::Property::ShadowOffsetDist, context.expressionContext(), d->offsetDist );
408 }
409
411 if ( !QgsVariantUtils::isNull( exprVal ) )
412 {
413 const QString units = exprVal.toString();
414 if ( !units.isEmpty() )
415 {
416 bool ok;
417 const Qgis::RenderUnit res = QgsUnitTypes::decodeRenderUnit( units, &ok );
418 if ( ok )
419 d->offsetUnits = res;
420 }
421 }
422
424 {
425 context.expressionContext().setOriginalValueVariable( d->radius );
426 d->radius = properties.valueAsDouble( QgsPalLayerSettings::Property::ShadowRadius, context.expressionContext(), d->radius );
427 }
428
430 if ( !QgsVariantUtils::isNull( exprVal ) )
431 {
432 const QString units = exprVal.toString();
433 if ( !units.isEmpty() )
434 {
435 bool ok;
436 const Qgis::RenderUnit res = QgsUnitTypes::decodeRenderUnit( units, &ok );
437 if ( ok )
438 d->radiusUnits = res;
439 }
440 }
441
443 {
444 context.expressionContext().setOriginalValueVariable( d->opacity * 100 );
445 const QVariant val = properties.value( QgsPalLayerSettings::Property::ShadowOpacity, context.expressionContext(), d->opacity * 100 );
446 if ( !QgsVariantUtils::isNull( val ) )
447 {
448 d->opacity = val.toDouble() / 100.0;
449 }
450 }
451
453 {
454 context.expressionContext().setOriginalValueVariable( d->scale );
455 d->scale = properties.valueAsInt( QgsPalLayerSettings::Property::ShadowScale, context.expressionContext(), d->scale );
456 }
457
459 {
461 d->color = properties.valueAsColor( QgsPalLayerSettings::Property::ShadowColor, context.expressionContext(), d->color );
462 }
463
465 {
467 const QString blendstr = exprVal.toString().trimmed();
468 if ( !blendstr.isEmpty() )
469 d->blendMode = QgsSymbolLayerUtils::decodeBlendMode( blendstr );
470 }
471}
472
474{
475 return QSet< QString >(); // nothing for now
476}
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition qgis.h:4657
@ Multiply
Multiple.
RenderUnit
Rendering size units.
Definition qgis.h:4910
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.
@ ShadowOpacity
Shadow opacity.
A grouped map of multiple QgsProperty objects, each referenced by a 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.
Container for settings relating to a text shadow.
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 data sets.