QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
32{
33 d = new QgsTextShadowSettingsPrivate();
34}
35
37 : d( other.d )
38{}
39
41 : d( std::move( other.d ) )
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
65
67{
68 if ( d->enabled != other.enabled()
69 || d->shadowUnder != other.shadowPlacement()
70 || d->offsetAngle != other.offsetAngle()
71 || d->offsetDist != other.offsetDistance()
72 || d->offsetUnits != other.offsetUnit()
73 || d->offsetMapUnitScale != other.offsetMapUnitScale()
74 || d->offsetGlobal != other.offsetGlobal()
75 || d->radius != other.blurRadius()
76 || d->radiusUnits != other.blurRadiusUnit()
77 || d->radiusMapUnitScale != other.blurRadiusMapUnitScale()
78 || d->radiusAlphaOnly != other.blurAlphaOnly()
79 || d->scale != other.scale()
80 || d->color != other.color()
81 || d->opacity != other.opacity()
82 || d->blendMode != other.blendMode() )
83 return false;
84
85 return true;
86}
87
89{
90 return !( *this == other );
91}
92
94{
95 return d->enabled;
96}
97
99{
100 d->enabled = enabled;
101}
102
107
109{
110 d->shadowUnder = placement;
111}
112
114{
115 return d->offsetAngle;
116}
117
119{
120 d->offsetAngle = angle;
121}
122
124{
125 return d->offsetDist;
126}
127
129{
130 d->offsetDist = distance;
131}
132
134{
135 return d->offsetUnits;
136}
137
139{
140 d->offsetUnits = units;
141}
142
144{
145 return d->offsetMapUnitScale;
146}
147
149{
150 d->offsetMapUnitScale = scale;
151}
152
154{
155 return d->offsetGlobal;
156}
157
159{
160 d->offsetGlobal = global;
161}
162
164{
165 return d->radius;
166}
167
169{
170 d->radius = radius;
171}
172
174{
175 return d->radiusUnits;
176}
177
179{
180 d->radiusUnits = units;
181}
182
184{
185 return d->radiusMapUnitScale;
186}
187
189{
190 d->radiusMapUnitScale = scale;
191}
192
194{
195 return d->radiusAlphaOnly;
196}
197
199{
200 d->radiusAlphaOnly = alphaOnly;
201}
202
204{
205 return d->opacity;
206}
207
209{
210 d->opacity = opacity;
211}
212
214{
215 return d->scale;
216}
217
219{
220 d->scale = scale;
221}
222
224{
225 return d->color;
226}
227
229{
230 d->color = color;
231}
232
233QPainter::CompositionMode QgsTextShadowSettings::blendMode() const
234{
235 return d->blendMode;
236}
237
238void QgsTextShadowSettings::setBlendMode( QPainter::CompositionMode mode )
239{
240 d->blendMode = mode;
241}
242
244{
245 d->enabled = layer->customProperty( u"labeling/shadowDraw"_s, QVariant( false ) ).toBool();
246 d->shadowUnder = static_cast< ShadowPlacement >( layer->customProperty( u"labeling/shadowUnder"_s, QVariant( ShadowLowest ) ).toUInt() ); //ShadowLowest;
247 d->offsetAngle = layer->customProperty( u"labeling/shadowOffsetAngle"_s, QVariant( 135 ) ).toInt();
248 d->offsetDist = layer->customProperty( u"labeling/shadowOffsetDist"_s, QVariant( 1.0 ) ).toDouble();
249
250 if ( layer->customProperty( u"labeling/shadowOffsetUnit"_s ).toString().isEmpty() )
251 {
252 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( u"labeling/shadowOffsetUnits"_s, 0 ).toUInt() );
253 }
254 else
255 {
256 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( u"labeling/shadowOffsetUnit"_s ).toString() );
257 }
258 if ( layer->customProperty( u"labeling/shadowOffsetMapUnitScale"_s ).toString().isEmpty() )
259 {
260 //fallback to older property
261 const double oldMin = layer->customProperty( u"labeling/shadowOffsetMapUnitMinScale"_s, 0.0 ).toDouble();
262 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
263 const double oldMax = layer->customProperty( u"labeling/shadowOffsetMapUnitMaxScale"_s, 0.0 ).toDouble();
264 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
265 }
266 else
267 {
268 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( u"labeling/shadowOffsetMapUnitScale"_s ).toString() );
269 }
270 d->offsetGlobal = layer->customProperty( u"labeling/shadowOffsetGlobal"_s, QVariant( true ) ).toBool();
271 d->radius = layer->customProperty( u"labeling/shadowRadius"_s, QVariant( 1.5 ) ).toDouble();
272
273 if ( layer->customProperty( u"labeling/shadowRadiusUnit"_s ).toString().isEmpty() )
274 {
275 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( layer->customProperty( u"labeling/shadowRadiusUnits"_s, 0 ).toUInt() );
276 }
277 else
278 {
279 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( layer->customProperty( u"labeling/shadowRadiusUnit"_s ).toString() );
280 }
281 if ( layer->customProperty( u"labeling/shadowRadiusMapUnitScale"_s ).toString().isEmpty() )
282 {
283 //fallback to older property
284 const double oldMin = layer->customProperty( u"labeling/shadowRadiusMapUnitMinScale"_s, 0.0 ).toDouble();
285 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
286 const double oldMax = layer->customProperty( u"labeling/shadowRadiusMapUnitMaxScale"_s, 0.0 ).toDouble();
287 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
288 }
289 else
290 {
291 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( layer->customProperty( u"labeling/shadowRadiusMapUnitScale"_s ).toString() );
292 }
293 d->radiusAlphaOnly = layer->customProperty( u"labeling/shadowRadiusAlphaOnly"_s, QVariant( false ) ).toBool();
294
295 if ( layer->customProperty( u"labeling/shadowOpacity"_s ).toString().isEmpty() )
296 {
297 d->opacity = ( 1 - layer->customProperty( u"labeling/shadowTransparency"_s ).toInt() / 100.0 ); //0 -100
298 }
299 else
300 {
301 d->opacity = ( layer->customProperty( u"labeling/shadowOpacity"_s ).toDouble() );
302 }
303 d->scale = layer->customProperty( u"labeling/shadowScale"_s, QVariant( 100 ) ).toInt();
304 d->color = QgsTextRendererUtils::readColor( layer, u"labeling/shadowColor"_s, Qt::black, false );
305 d->blendMode = QgsPainting::getCompositionMode(
306 static_cast< Qgis::BlendMode >( layer->customProperty( u"labeling/shadowBlendMode"_s, QVariant( static_cast< int >( Qgis::BlendMode::Multiply ) ) ).toUInt() )
307 );
308}
309
310void QgsTextShadowSettings::readXml( const QDomElement &elem )
311{
312 const QDomElement shadowElem = elem.firstChildElement( u"shadow"_s );
313 d->enabled = shadowElem.attribute( u"shadowDraw"_s, u"0"_s ).toInt();
314 d->shadowUnder = static_cast< ShadowPlacement >( shadowElem.attribute( u"shadowUnder"_s, QString::number( ShadowLowest ) ).toUInt() ); //ShadowLowest;
315 d->offsetAngle = shadowElem.attribute( u"shadowOffsetAngle"_s, u"135"_s ).toInt();
316 d->offsetDist = shadowElem.attribute( u"shadowOffsetDist"_s, u"1"_s ).toDouble();
317
318 if ( !shadowElem.hasAttribute( u"shadowOffsetUnit"_s ) )
319 {
320 d->offsetUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( u"shadowOffsetUnits"_s ).toUInt() );
321 }
322 else
323 {
324 d->offsetUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( u"shadowOffsetUnit"_s ) );
325 }
326
327 if ( !shadowElem.hasAttribute( u"shadowOffsetMapUnitScale"_s ) )
328 {
329 //fallback to older property
330 const double oldMin = shadowElem.attribute( u"shadowOffsetMapUnitMinScale"_s, u"0"_s ).toDouble();
331 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
332 const double oldMax = shadowElem.attribute( u"shadowOffsetMapUnitMaxScale"_s, u"0"_s ).toDouble();
333 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
334 }
335 else
336 {
337 d->offsetMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( u"shadowOffsetMapUnitScale"_s ) );
338 }
339 d->offsetGlobal = shadowElem.attribute( u"shadowOffsetGlobal"_s, u"1"_s ).toInt();
340 d->radius = shadowElem.attribute( u"shadowRadius"_s, u"1.5"_s ).toDouble();
341
342 if ( !shadowElem.hasAttribute( u"shadowRadiusUnit"_s ) )
343 {
344 d->radiusUnits = QgsTextRendererUtils::convertFromOldLabelUnit( shadowElem.attribute( u"shadowRadiusUnits"_s ).toUInt() );
345 }
346 else
347 {
348 d->radiusUnits = QgsUnitTypes::decodeRenderUnit( shadowElem.attribute( u"shadowRadiusUnit"_s ) );
349 }
350 if ( !shadowElem.hasAttribute( u"shadowRadiusMapUnitScale"_s ) )
351 {
352 //fallback to older property
353 const double oldMin = shadowElem.attribute( u"shadowRadiusMapUnitMinScale"_s, u"0"_s ).toDouble();
354 d->radiusMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
355 const double oldMax = shadowElem.attribute( u"shadowRadiusMapUnitMaxScale"_s, u"0"_s ).toDouble();
356 d->radiusMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
357 }
358 else
359 {
360 d->radiusMapUnitScale = QgsSymbolLayerUtils::decodeMapUnitScale( shadowElem.attribute( u"shadowRadiusMapUnitScale"_s ) );
361 }
362 d->radiusAlphaOnly = shadowElem.attribute( u"shadowRadiusAlphaOnly"_s, u"0"_s ).toInt();
363
364 if ( !shadowElem.hasAttribute( u"shadowOpacity"_s ) )
365 {
366 d->opacity = ( 1 - shadowElem.attribute( u"shadowTransparency"_s ).toInt() / 100.0 ); //0 -100
367 }
368 else
369 {
370 d->opacity = ( shadowElem.attribute( u"shadowOpacity"_s ).toDouble() );
371 }
372 d->scale = shadowElem.attribute( u"shadowScale"_s, u"100"_s ).toInt();
373 d->color = QgsColorUtils::colorFromString( shadowElem.attribute( u"shadowColor"_s, QgsColorUtils::colorToString( Qt::black ) ) );
374 d->blendMode = QgsPainting::getCompositionMode(
375 static_cast< Qgis::BlendMode >( shadowElem.attribute( u"shadowBlendMode"_s, QString::number( static_cast<int>( Qgis::BlendMode::Multiply ) ) ).toUInt() )
376 );
377}
378
379QDomElement QgsTextShadowSettings::writeXml( QDomDocument &doc ) const
380{
381 QDomElement shadowElem = doc.createElement( u"shadow"_s );
382 shadowElem.setAttribute( u"shadowDraw"_s, d->enabled );
383 shadowElem.setAttribute( u"shadowUnder"_s, static_cast< unsigned int >( d->shadowUnder ) );
384 shadowElem.setAttribute( u"shadowOffsetAngle"_s, d->offsetAngle );
385 shadowElem.setAttribute( u"shadowOffsetDist"_s, d->offsetDist );
386 shadowElem.setAttribute( u"shadowOffsetUnit"_s, QgsUnitTypes::encodeUnit( d->offsetUnits ) );
387 shadowElem.setAttribute( u"shadowOffsetMapUnitScale"_s, QgsSymbolLayerUtils::encodeMapUnitScale( d->offsetMapUnitScale ) );
388 shadowElem.setAttribute( u"shadowOffsetGlobal"_s, d->offsetGlobal );
389 shadowElem.setAttribute( u"shadowRadius"_s, d->radius );
390 shadowElem.setAttribute( u"shadowRadiusUnit"_s, QgsUnitTypes::encodeUnit( d->radiusUnits ) );
391 shadowElem.setAttribute( u"shadowRadiusMapUnitScale"_s, QgsSymbolLayerUtils::encodeMapUnitScale( d->radiusMapUnitScale ) );
392 shadowElem.setAttribute( u"shadowRadiusAlphaOnly"_s, d->radiusAlphaOnly );
393 shadowElem.setAttribute( u"shadowOpacity"_s, d->opacity );
394 shadowElem.setAttribute( u"shadowScale"_s, d->scale );
395 shadowElem.setAttribute( u"shadowColor"_s, QgsColorUtils::colorToString( d->color ) );
396 shadowElem.setAttribute( u"shadowBlendMode"_s, 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:5087
@ Multiply
Multiple.
Definition qgis.h:5094
RenderUnit
Rendering size units.
Definition qgis.h:5340
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.