QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
26{
27 d = new QgsTextShadowSettingsPrivate();
28}
29
31 : d( other.d )
32{
33
34}
35
37{
38 d = other.d;
39 return *this;
40}
41
43{
44
45}
46
48{
49 if ( d->enabled != other.enabled()
50 || d->shadowUnder != other.shadowPlacement()
51 || d->offsetAngle != other.offsetAngle()
52 || d->offsetDist != other.offsetDistance()
53 || d->offsetUnits != other.offsetUnit()
54 || d->offsetMapUnitScale != other.offsetMapUnitScale()
55 || d->offsetGlobal != other.offsetGlobal()
56 || d->radius != other.blurRadius()
57 || d->radiusUnits != other.blurRadiusUnit()
58 || d->radiusMapUnitScale != other.blurRadiusMapUnitScale()
59 || d->radiusAlphaOnly != other.blurAlphaOnly()
60 || d->scale != other.scale()
61 || d->color != other.color()
62 || d->opacity != other.opacity()
63 || d->blendMode != other.blendMode() )
64 return false;
65
66 return true;
67}
68
70{
71 return !( *this == other );
72}
73
75{
76 return d->enabled;
77}
78
80{
81 d->enabled = enabled;
82}
83
85{
86 return d->shadowUnder;
87}
88
90{
91 d->shadowUnder = placement;
92}
93
95{
96 return d->offsetAngle;
97}
98
100{
101 d->offsetAngle = angle;
102}
103
105{
106 return d->offsetDist;
107}
108
110{
111 d->offsetDist = distance;
112}
113
115{
116 return d->offsetUnits;
117}
118
120{
121 d->offsetUnits = units;
122}
123
125{
126 return d->offsetMapUnitScale;
127}
128
130{
131 d->offsetMapUnitScale = scale;
132}
133
135{
136 return d->offsetGlobal;
137}
138
140{
141 d->offsetGlobal = global;
142}
143
145{
146 return d->radius;
147}
148
150{
151 d->radius = radius;
152}
153
155{
156 return d->radiusUnits;
157}
158
160{
161 d->radiusUnits = units;
162}
163
165{
166 return d->radiusMapUnitScale;
167}
168
170{
171 d->radiusMapUnitScale = scale;
172}
173
175{
176 return d->radiusAlphaOnly;
177}
178
180{
181 d->radiusAlphaOnly = alphaOnly;
182}
183
185{
186 return d->opacity;
187}
188
190{
191 d->opacity = opacity;
192}
193
195{
196 return d->scale;
197}
198
200{
201 d->scale = scale;
202}
203
205{
206 return d->color;
207}
208
209void QgsTextShadowSettings::setColor( const QColor &color )
210{
211 d->color = color;
212}
213
214QPainter::CompositionMode QgsTextShadowSettings::blendMode() const
215{
216 return d->blendMode;
217}
218
219void QgsTextShadowSettings::setBlendMode( QPainter::CompositionMode mode )
220{
221 d->blendMode = mode;
222}
223
225{
226 d->enabled = layer->customProperty( QStringLiteral( "labeling/shadowDraw" ), QVariant( false ) ).toBool();
227 d->shadowUnder = static_cast< ShadowPlacement >( layer->customProperty( QStringLiteral( "labeling/shadowUnder" ), QVariant( ShadowLowest ) ).toUInt() );//ShadowLowest;
228 d->offsetAngle = layer->customProperty( QStringLiteral( "labeling/shadowOffsetAngle" ), QVariant( 135 ) ).toInt();
229 d->offsetDist = layer->customProperty( QStringLiteral( "labeling/shadowOffsetDist" ), QVariant( 1.0 ) ).toDouble();
230
231 if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString().isEmpty() )
232 {
233 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnits" ), 0 ).toUInt() );
234 }
235 else
236 {
237 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowOffsetUnit" ) ).toString() );
238 }
239 if ( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString().isEmpty() )
240 {
241 //fallback to older property
242 const double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMinScale" ), 0.0 ).toDouble();
243 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
244 const double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
245 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
246 }
247 else
248 {
249 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowOffsetMapUnitScale" ) ).toString() );
250 }
251 d->offsetGlobal = layer->customProperty( QStringLiteral( "labeling/shadowOffsetGlobal" ), QVariant( true ) ).toBool();
252 d->radius = layer->customProperty( QStringLiteral( "labeling/shadowRadius" ), QVariant( 1.5 ) ).toDouble();
253
254 if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString().isEmpty() )
255 {
256 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnits" ), 0 ).toUInt() );
257 }
258 else
259 {
260 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( QStringLiteral( "labeling/shadowRadiusUnit" ) ).toString() );
261 }
262 if ( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString().isEmpty() )
263 {
264 //fallback to older property
265 const double oldMin = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMinScale" ), 0.0 ).toDouble();
266 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
267 const double oldMax = layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitMaxScale" ), 0.0 ).toDouble();
268 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
269 }
270 else
271 {
272 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( QStringLiteral( "labeling/shadowRadiusMapUnitScale" ) ).toString() );
273 }
274 d->radiusAlphaOnly = layer->customProperty( QStringLiteral( "labeling/shadowRadiusAlphaOnly" ), QVariant( false ) ).toBool();
275
276 if ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toString().isEmpty() )
277 {
278 d->opacity = ( 1 - layer->customProperty( QStringLiteral( "labeling/shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
279 }
280 else
281 {
282 d->opacity = ( layer->customProperty( QStringLiteral( "labeling/shadowOpacity" ) ).toDouble() );
283 }
284 d->scale = layer->customProperty( QStringLiteral( "labeling/shadowScale" ), QVariant( 100 ) ).toInt();
285 d->color = QgsTextRendererUtils::readColor( layer, QStringLiteral( "labeling/shadowColor" ), Qt::black, false );
286 d->blendMode = QgsPainting::getCompositionMode(
287 static_cast< Qgis::BlendMode >( layer->customProperty( QStringLiteral( "labeling/shadowBlendMode" ), QVariant( static_cast< int >( Qgis::BlendMode::Multiply ) ) ).toUInt() ) );
288}
289
290void QgsTextShadowSettings::readXml( const QDomElement &elem )
291{
292 const QDomElement shadowElem = elem.firstChildElement( QStringLiteral( "shadow" ) );
293 d->enabled = shadowElem.attribute( QStringLiteral( "shadowDraw" ), QStringLiteral( "0" ) ).toInt();
294 d->shadowUnder = static_cast< ShadowPlacement >( shadowElem.attribute( QStringLiteral( "shadowUnder" ), QString::number( ShadowLowest ) ).toUInt() );//ShadowLowest;
295 d->offsetAngle = shadowElem.attribute( QStringLiteral( "shadowOffsetAngle" ), QStringLiteral( "135" ) ).toInt();
296 d->offsetDist = shadowElem.attribute( QStringLiteral( "shadowOffsetDist" ), QStringLiteral( "1" ) ).toDouble();
297
298 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetUnit" ) ) )
299 {
300 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnits" ) ).toUInt() );
301 }
302 else
303 {
304 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowOffsetUnit" ) ) );
305 }
306
307 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) )
308 {
309 //fallback to older property
310 const double oldMin = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
311 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
312 const double oldMax = shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
313 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
314 }
315 else
316 {
317 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowOffsetMapUnitScale" ) ) );
318 }
319 d->offsetGlobal = shadowElem.attribute( QStringLiteral( "shadowOffsetGlobal" ), QStringLiteral( "1" ) ).toInt();
320 d->radius = shadowElem.attribute( QStringLiteral( "shadowRadius" ), QStringLiteral( "1.5" ) ).toDouble();
321
322 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusUnit" ) ) )
323 {
324 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnits" ) ).toUInt() );
325 }
326 else
327 {
328 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( QStringLiteral( "shadowRadiusUnit" ) ) );
329 }
330 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) )
331 {
332 //fallback to older property
333 const double oldMin = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMinScale" ), QStringLiteral( "0" ) ).toDouble();
334 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
335 const double oldMax = shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitMaxScale" ), QStringLiteral( "0" ) ).toDouble();
336 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
337 }
338 else
339 {
340 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( QStringLiteral( "shadowRadiusMapUnitScale" ) ) );
341 }
342 d->radiusAlphaOnly = shadowElem.attribute( QStringLiteral( "shadowRadiusAlphaOnly" ), QStringLiteral( "0" ) ).toInt();
343
344 if ( !shadowElem.hasAttribute( QStringLiteral( "shadowOpacity" ) ) )
345 {
346 d->opacity = ( 1 - shadowElem.attribute( QStringLiteral( "shadowTransparency" ) ).toInt() / 100.0 ); //0 -100
347 }
348 else
349 {
350 d->opacity = ( shadowElem.attribute( QStringLiteral( "shadowOpacity" ) ).toDouble() );
351 }
352 d->scale = shadowElem.attribute( QStringLiteral( "shadowScale" ), QStringLiteral( "100" ) ).toInt();
353 d->color = QgsSymbolLayerUtils::decodeColor( shadowElem.attribute( QStringLiteral( "shadowColor" ), QgsSymbolLayerUtils::encodeColor( Qt::black ) ) );
354 d->blendMode = QgsPainting::getCompositionMode(
355 static_cast< Qgis::BlendMode >( shadowElem.attribute( QStringLiteral( "shadowBlendMode" ), QString::number( static_cast<int>( Qgis::BlendMode::Multiply ) ) ).toUInt() ) );
356}
357
358QDomElement QgsTextShadowSettings::writeXml( QDomDocument &doc ) const
359{
360 QDomElement shadowElem = doc.createElement( QStringLiteral( "shadow" ) );
361 shadowElem.setAttribute( QStringLiteral( "shadowDraw" ), d->enabled );
362 shadowElem.setAttribute( QStringLiteral( "shadowUnder" ), static_cast< unsigned int >( d->shadowUnder ) );
363 shadowElem.setAttribute( QStringLiteral( "shadowOffsetAngle" ), d->offsetAngle );
364 shadowElem.setAttribute( QStringLiteral( "shadowOffsetDist" ), d->offsetDist );
365 shadowElem.setAttribute( QStringLiteral( "shadowOffsetUnit" ), QgsUnitTypes::encodeUnit( d->offsetUnits ) );
366 shadowElem.setAttribute( QStringLiteral( "shadowOffsetMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->offsetMapUnitScale ) );
367 shadowElem.setAttribute( QStringLiteral( "shadowOffsetGlobal" ), d->offsetGlobal );
368 shadowElem.setAttribute( QStringLiteral( "shadowRadius" ), d->radius );
369 shadowElem.setAttribute( QStringLiteral( "shadowRadiusUnit" ), QgsUnitTypes::encodeUnit( d->radiusUnits ) );
370 shadowElem.setAttribute( QStringLiteral( "shadowRadiusMapUnitScale" ), QgsSymbolLayerUtils::encodeMapUnitScale( d->radiusMapUnitScale ) );
371 shadowElem.setAttribute( QStringLiteral( "shadowRadiusAlphaOnly" ), d->radiusAlphaOnly );
372 shadowElem.setAttribute( QStringLiteral( "shadowOpacity" ), d->opacity );
373 shadowElem.setAttribute( QStringLiteral( "shadowScale" ), d->scale );
374 shadowElem.setAttribute( QStringLiteral( "shadowColor" ), QgsSymbolLayerUtils::encodeColor( d->color ) );
375 shadowElem.setAttribute( QStringLiteral( "shadowBlendMode" ), static_cast< int >( QgsPainting::getBlendModeEnum( d->blendMode ) ) );
376 return shadowElem;
377}
378
380{
381 if ( properties.isActive( QgsPalLayerSettings::ShadowDraw ) )
382 {
383 context.expressionContext().setOriginalValueVariable( d->enabled );
384 d->enabled = properties.valueAsBool( QgsPalLayerSettings::ShadowDraw, context.expressionContext(), d->enabled );
385 }
386
387 // data defined shadow under type?
388 QVariant exprVal = properties.value( QgsPalLayerSettings::ShadowUnder, context.expressionContext() );
389 if ( !QgsVariantUtils::isNull( exprVal ) )
390 {
391 const QString str = exprVal.toString().trimmed();
392 if ( !str.isEmpty() )
393 {
395 }
396 }
397
399 {
400 context.expressionContext().setOriginalValueVariable( d->offsetAngle );
401 d->offsetAngle = properties.valueAsInt( QgsPalLayerSettings::ShadowOffsetAngle, context.expressionContext(), d->offsetAngle );
402 }
404 {
405 context.expressionContext().setOriginalValueVariable( d->offsetDist );
406 d->offsetDist = properties.valueAsDouble( QgsPalLayerSettings::ShadowOffsetDist, context.expressionContext(), d->offsetDist );
407 }
408
409 exprVal = properties.value( QgsPalLayerSettings::ShadowOffsetUnits, context.expressionContext() );
410 if ( !QgsVariantUtils::isNull( exprVal ) )
411 {
412 const QString units = exprVal.toString();
413 if ( !units.isEmpty() )
414 {
415 bool ok;
416 const Qgis::RenderUnit res = QgsUnitTypes::decodeRenderUnit( units, &ok );
417 if ( ok )
418 d->offsetUnits = res;
419 }
420 }
421
423 {
424 context.expressionContext().setOriginalValueVariable( d->radius );
425 d->radius = properties.valueAsDouble( QgsPalLayerSettings::ShadowRadius, context.expressionContext(), d->radius );
426 }
427
428 exprVal = properties.value( QgsPalLayerSettings::ShadowRadiusUnits, context.expressionContext() );
429 if ( !QgsVariantUtils::isNull( exprVal ) )
430 {
431 const QString units = exprVal.toString();
432 if ( !units.isEmpty() )
433 {
434 bool ok;
435 const Qgis::RenderUnit res = QgsUnitTypes::decodeRenderUnit( units, &ok );
436 if ( ok )
437 d->radiusUnits = res;
438 }
439 }
440
442 {
443 context.expressionContext().setOriginalValueVariable( d->opacity * 100 );
444 const QVariant val = properties.value( QgsPalLayerSettings::ShadowOpacity, context.expressionContext(), d->opacity * 100 );
445 if ( !QgsVariantUtils::isNull( val ) )
446 {
447 d->opacity = val.toDouble() / 100.0;
448 }
449 }
450
451 if ( properties.isActive( QgsPalLayerSettings::ShadowScale ) )
452 {
453 context.expressionContext().setOriginalValueVariable( d->scale );
454 d->scale = properties.valueAsInt( QgsPalLayerSettings::ShadowScale, context.expressionContext(), d->scale );
455 }
456
457 if ( properties.isActive( QgsPalLayerSettings::ShadowColor ) )
458 {
460 d->color = properties.valueAsColor( QgsPalLayerSettings::ShadowColor, context.expressionContext(), d->color );
461 }
462
464 {
465 exprVal = properties.value( QgsPalLayerSettings::ShadowBlendMode, context.expressionContext() );
466 const QString blendstr = exprVal.toString().trimmed();
467 if ( !blendstr.isEmpty() )
468 d->blendMode = QgsSymbolLayerUtils::decodeBlendMode( blendstr );
469 }
470}
471
473{
474 return QSet< QString >(); // nothing for now
475}
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition: qgis.h:2978
RenderUnit
Rendering size units.
Definition: qgis.h:3176
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.
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 BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
@ 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 override
Returns the calculated value of the property with the specified key from within the collection.
bool isActive(int key) const override
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 QColor decodeColor(const QString &str)
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)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based data sets.
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
#define str(x)
Definition: qgis.cpp:37