32using namespace Qt::StringLiterals;
36 d =
new QgsTextBackgroundSettingsPrivate();
56 : d( std::move( other.d ) )
73 d = std::move( other.d );
82 if ( d->enabled != other.
enabled()
83 || d->type != other.
type()
84 || d->svgFile != other.
svgFile()
86 || d->size != other.
size()
91 || d->offset != other.
offset()
94 || d->radii != other.
radii()
100 || d->opacity != other.
opacity()
107 if (
static_cast< bool >( d->paintEffect ) !=
static_cast< bool >( other.
paintEffect() ) || ( d->paintEffect && d->paintEffect->properties() != other.
paintEffect()->
properties() ) )
110 if (
static_cast< bool >( d->markerSymbol ) !=
static_cast< bool >( other.
markerSymbol() )
114 if (
static_cast< bool >( d->fillSymbol ) !=
static_cast< bool >( other.
fillSymbol() )
123 return !( *
this == other );
158 return d->markerSymbol.get();
167 d->markerSymbol.reset( symbol );
172 return d->fillSymbol.get();
181 d->fillSymbol.reset( symbol );
216 return d->sizeMapUnitScale;
221 d->sizeMapUnitScale = scale;
226 return d->rotationType;
231 d->rotationType =
type;
256 return d->offsetUnits;
261 d->offsetUnits = units;
266 return d->offsetMapUnitScale;
271 d->offsetMapUnitScale = scale;
286 return d->radiiUnits;
291 d->radiiUnits = units;
296 return d->radiiMapUnitScale;
301 d->radiiMapUnitScale = scale;
326 return d->fillSymbol ? d->fillSymbol->color() : d->fillColor;
331 d->fillColor = color;
334 d->fillSymbol->setColor( color );
340 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
342 return qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->strokeColor();
344 return d->strokeColor;
349 d->strokeColor = color;
350 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
352 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeColor( color );
358 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
360 return qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->strokeWidth();
362 return d->strokeWidth;
367 d->strokeWidth = width;
368 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
370 QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) );
378 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
380 return qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->strokeWidthUnit();
382 return d->strokeWidthUnits;
387 d->strokeWidthUnits = units;
388 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
390 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeWidthUnit( units );
396 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
398 return qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->strokeWidthMapUnitScale();
400 return d->strokeWidthMapUnitScale;
405 d->strokeWidthMapUnitScale = scale;
406 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
408 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeWidthMapUnitScale( scale );
414 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
416 return qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->penJoinStyle();
423 d->joinStyle = style;
424 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() ==
"SimpleFill"_L1 )
426 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setPenJoinStyle( style );
432 return d->paintEffect.get();
437 d->paintEffect.reset( effect );
444 d->svgFile = layer->
customProperty( u
"labeling/shapeSVGFile"_s, QVariant(
"" ) ).toString();
446 d->size = QSizeF( layer->
customProperty( u
"labeling/shapeSizeX"_s, QVariant( 0.0 ) ).toDouble(), layer->
customProperty( u
"labeling/shapeSizeY"_s, QVariant( 0.0 ) ).toDouble() );
448 if ( layer->
customProperty( u
"labeling/shapeSizeUnit"_s ).toString().isEmpty() )
457 if ( layer->
customProperty( u
"labeling/shapeSizeMapUnitScale"_s ).toString().isEmpty() )
460 const double oldMin = layer->
customProperty( u
"labeling/shapeSizeMapUnitMinScale"_s, 0.0 ).toDouble();
461 d->sizeMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
462 const double oldMax = layer->
customProperty( u
"labeling/shapeSizeMapUnitMaxScale"_s, 0.0 ).toDouble();
463 d->sizeMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
470 d->rotation = layer->
customProperty( u
"labeling/shapeRotation"_s, QVariant( 0.0 ) ).toDouble();
471 d->offset = QPointF( layer->
customProperty( u
"labeling/shapeOffsetX"_s, QVariant( 0.0 ) ).toDouble(), layer->
customProperty( u
"labeling/shapeOffsetY"_s, QVariant( 0.0 ) ).toDouble() );
473 if ( layer->
customProperty( u
"labeling/shapeOffsetUnit"_s ).toString().isEmpty() )
482 if ( layer->
customProperty( u
"labeling/shapeOffsetMapUnitScale"_s ).toString().isEmpty() )
485 const double oldMin = layer->
customProperty( u
"labeling/shapeOffsetMapUnitMinScale"_s, 0.0 ).toDouble();
486 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
487 const double oldMax = layer->
customProperty( u
"labeling/shapeOffsetMapUnitMaxScale"_s, 0.0 ).toDouble();
488 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
494 d->radii = QSizeF( layer->
customProperty( u
"labeling/shapeRadiiX"_s, QVariant( 0.0 ) ).toDouble(), layer->
customProperty( u
"labeling/shapeRadiiY"_s, QVariant( 0.0 ) ).toDouble() );
497 if ( layer->
customProperty( u
"labeling/shapeRadiiUnit"_s ).toString().isEmpty() )
506 if ( layer->
customProperty( u
"labeling/shapeRadiiMapUnitScale"_s ).toString().isEmpty() )
509 const double oldMin = layer->
customProperty( u
"labeling/shapeRadiiMapUnitMinScale"_s, 0.0 ).toDouble();
510 d->radiiMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
511 const double oldMax = layer->
customProperty( u
"labeling/shapeRadiiMapUnitMaxScale"_s, 0.0 ).toDouble();
512 d->radiiMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
520 d->strokeWidth = layer->
customProperty( u
"labeling/shapeBorderWidth"_s, QVariant( .0 ) ).toDouble();
521 if ( layer->
customProperty( u
"labeling/shapeBorderWidthUnit"_s ).toString().isEmpty() )
529 if ( layer->
customProperty( u
"labeling/shapeBorderWidthMapUnitScale"_s ).toString().isEmpty() )
532 const double oldMin = layer->
customProperty( u
"labeling/shapeBorderWidthMapUnitMinScale"_s, 0.0 ).toDouble();
533 d->strokeWidthMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
534 const double oldMax = layer->
customProperty( u
"labeling/shapeBorderWidthMapUnitMaxScale"_s, 0.0 ).toDouble();
535 d->strokeWidthMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
541 d->joinStyle =
static_cast< Qt::PenJoinStyle
>( layer->
customProperty( u
"labeling/shapeJoinStyle"_s, QVariant( Qt::BevelJoin ) ).toUInt() );
543 if ( layer->
customProperty( u
"labeling/shapeOpacity"_s ).toString().isEmpty() )
545 d->opacity = ( 1 - layer->
customProperty( u
"labeling/shapeTransparency"_s ).toInt() / 100.0 );
549 d->opacity = ( layer->
customProperty( u
"labeling/shapeOpacity"_s ).toDouble() );
555 if ( layer->
customProperty( u
"labeling/shapeEffect"_s ).isValid() )
557 QDomDocument doc( u
"effect"_s );
558 doc.setContent( layer->
customProperty( u
"labeling/shapeEffect"_s ).toString() );
559 const QDomElement effectElem = doc.firstChildElement( u
"effect"_s ).firstChildElement( u
"effect"_s );
568 const QDomElement backgroundElem = elem.firstChildElement( u
"background"_s );
569 d->enabled = backgroundElem.attribute( u
"shapeDraw"_s, u
"0"_s ).toInt();
570 d->type =
static_cast< ShapeType >( backgroundElem.attribute( u
"shapeType"_s, QString::number(
ShapeRectangle ) ).toUInt() );
572 d->sizeType =
static_cast< SizeType >( backgroundElem.attribute( u
"shapeSizeType"_s, QString::number(
SizeBuffer ) ).toUInt() );
573 d->size = QSizeF( backgroundElem.attribute( u
"shapeSizeX"_s, u
"0"_s ).toDouble(), backgroundElem.attribute( u
"shapeSizeY"_s, u
"0"_s ).toDouble() );
575 if ( !backgroundElem.hasAttribute( u
"shapeSizeUnit"_s ) )
584 if ( !backgroundElem.hasAttribute( u
"shapeSizeMapUnitScale"_s ) )
587 const double oldMin = backgroundElem.attribute( u
"shapeSizeMapUnitMinScale"_s, u
"0"_s ).toDouble();
588 d->sizeMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
589 const double oldMax = backgroundElem.attribute( u
"shapeSizeMapUnitMaxScale"_s, u
"0"_s ).toDouble();
590 d->sizeMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
596 d->rotationType =
static_cast< RotationType >( backgroundElem.attribute( u
"shapeRotationType"_s, QString::number(
RotationSync ) ).toUInt() );
597 d->rotation = backgroundElem.attribute( u
"shapeRotation"_s, u
"0"_s ).toDouble();
598 d->offset = QPointF( backgroundElem.attribute( u
"shapeOffsetX"_s, u
"0"_s ).toDouble(), backgroundElem.attribute( u
"shapeOffsetY"_s, u
"0"_s ).toDouble() );
600 if ( !backgroundElem.hasAttribute( u
"shapeOffsetUnit"_s ) )
609 if ( !backgroundElem.hasAttribute( u
"shapeOffsetMapUnitScale"_s ) )
612 const double oldMin = backgroundElem.attribute( u
"shapeOffsetMapUnitMinScale"_s, u
"0"_s ).toDouble();
613 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
614 const double oldMax = backgroundElem.attribute( u
"shapeOffsetMapUnitMaxScale"_s, u
"0"_s ).toDouble();
615 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
621 d->radii = QSizeF( backgroundElem.attribute( u
"shapeRadiiX"_s, u
"0"_s ).toDouble(), backgroundElem.attribute( u
"shapeRadiiY"_s, u
"0"_s ).toDouble() );
623 if ( !backgroundElem.hasAttribute( u
"shapeRadiiUnit"_s ) )
631 if ( !backgroundElem.hasAttribute( u
"shapeRadiiMapUnitScale"_s ) )
634 const double oldMin = backgroundElem.attribute( u
"shapeRadiiMapUnitMinScale"_s, u
"0"_s ).toDouble();
635 d->radiiMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
636 const double oldMax = backgroundElem.attribute( u
"shapeRadiiMapUnitMaxScale"_s, u
"0"_s ).toDouble();
637 d->radiiMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
645 d->strokeWidth = backgroundElem.attribute( u
"shapeBorderWidth"_s, u
"0"_s ).toDouble();
647 if ( !backgroundElem.hasAttribute( u
"shapeBorderWidthUnit"_s ) )
655 if ( !backgroundElem.hasAttribute( u
"shapeBorderWidthMapUnitScale"_s ) )
658 const double oldMin = backgroundElem.attribute( u
"shapeBorderWidthMapUnitMinScale"_s, u
"0"_s ).toDouble();
659 d->strokeWidthMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
660 const double oldMax = backgroundElem.attribute( u
"shapeBorderWidthMapUnitMaxScale"_s, u
"0"_s ).toDouble();
661 d->strokeWidthMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
667 d->joinStyle =
static_cast< Qt::PenJoinStyle
>( backgroundElem.attribute( u
"shapeJoinStyle"_s, QString::number( Qt::BevelJoin ) ).toUInt() );
669 if ( !backgroundElem.hasAttribute( u
"shapeOpacity"_s ) )
671 d->opacity = ( 1 - backgroundElem.attribute( u
"shapeTransparency"_s ).toInt() / 100.0 );
675 d->opacity = ( backgroundElem.attribute( u
"shapeOpacity"_s ).toDouble() );
682 const QDomElement effectElem = backgroundElem.firstChildElement( u
"effect"_s );
683 if ( !effectElem.isNull() )
690 const QDomNodeList symbols = backgroundElem.elementsByTagName( u
"symbol"_s );
691 for (
int i = 0; i < symbols.size(); ++i )
693 if ( symbols.at( i ).isElement() )
695 const QDomElement symbolElement = symbols.at( i ).toElement();
696 const QString symbolElementName = symbolElement.attribute( u
"name"_s );
697 if ( symbolElementName ==
"markerSymbol"_L1 )
701 else if ( symbolElementName ==
"fillSymbol"_L1 )
708 if ( !d->fillSymbol )
725 QDomElement backgroundElem = doc.createElement( u
"background"_s );
726 backgroundElem.setAttribute( u
"shapeDraw"_s, d->enabled );
727 backgroundElem.setAttribute( u
"shapeType"_s,
static_cast< unsigned int >( d->type ) );
729 backgroundElem.setAttribute( u
"shapeSizeType"_s,
static_cast< unsigned int >( d->sizeType ) );
730 backgroundElem.setAttribute( u
"shapeSizeX"_s, d->size.width() );
731 backgroundElem.setAttribute( u
"shapeSizeY"_s, d->size.height() );
734 backgroundElem.setAttribute( u
"shapeRotationType"_s,
static_cast< unsigned int >( d->rotationType ) );
735 backgroundElem.setAttribute( u
"shapeRotation"_s, d->rotation );
736 backgroundElem.setAttribute( u
"shapeOffsetX"_s, d->offset.x() );
737 backgroundElem.setAttribute( u
"shapeOffsetY"_s, d->offset.y() );
740 backgroundElem.setAttribute( u
"shapeRadiiX"_s, d->radii.width() );
741 backgroundElem.setAttribute( u
"shapeRadiiY"_s, d->radii.height() );
746 backgroundElem.setAttribute( u
"shapeBorderWidth"_s, d->strokeWidth );
749 backgroundElem.setAttribute( u
"shapeJoinStyle"_s,
static_cast< unsigned int >( d->joinStyle ) );
750 backgroundElem.setAttribute( u
"shapeOpacity"_s, d->opacity );
753 d->paintEffect->saveProperties( doc, backgroundElem );
755 if ( d->markerSymbol )
761 return backgroundElem;
766 if ( !d->fillSymbol || d->fillSymbol->symbolLayers().at( 0 )->layerType() !=
"SimpleFill"_L1 )
768 QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) );
820 const QString units = exprVal.toString();
821 if ( !units.isEmpty() )
833 const QString skind = exprVal.toString().trimmed();
834 if ( !skind.isEmpty() )
843 const QString stype = exprVal.toString().trimmed();
844 if ( !stype.isEmpty() )
855 const QString svgfile = exprVal.toString().trimmed();
867 const QString rotstr = exprVal.toString().trimmed();
868 if ( !rotstr.isEmpty() )
887 const QString units = exprVal.toString();
888 if ( !units.isEmpty() )
893 d->offsetUnits = res;
911 const QString units = exprVal.toString();
912 if ( !units.isEmpty() )
927 d->opacity = val.toDouble() / 100.0;
951 const QString units = exprVal.toString();
952 if ( !units.isEmpty() )
964 const QString blendstr = exprVal.toString().trimmed();
965 if ( !blendstr.isEmpty() )
972 const QString joinstr = exprVal.toString().trimmed();
973 if ( !joinstr.isEmpty() )
982 QSet< QString > fields;
983 if ( d->markerSymbol )
985 fields.unite( d->markerSymbol->usedAttributes( context ) );
989 fields.unite( d->fillSymbol->usedAttributes( context ) );
BlendMode
Blending modes defining the available composition modes that can be used when painting.
RenderUnit
Rendering size units.
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.
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 QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
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.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
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.
A marker symbol type, for rendering Point and MultiPoint geometries.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
Base class for visual effects which can be applied to QPicture drawings.
bool enabled() const
Returns whether the effect is enabled.
virtual QVariantMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
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.
@ ShapeOpacity
Shape opacity.
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 hasProperty(int key) const final
Returns true if the collection contains a property with the specified key.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
A store for object properties.
A container for the context for various read/write operations on objects.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
Contains information about the context of a rendering operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
Renders polygons using a single fill and stroke color.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
void setStrokeWidthUnit(Qgis::RenderUnit unit)
Sets the units for the width of the fill's stroke.
void setPenJoinStyle(Qt::PenJoinStyle style)
void setStrokeWidth(double strokeWidth)
void setStrokeStyle(Qt::PenStyle strokeStyle)
static void clearSymbolLayerIds(QgsSymbol *symbol)
Remove recursively unique id from all symbol symbol layers and set an empty string instead.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QString svgSymbolPathToName(const QString &path, const QgsPathResolver &pathResolver)
Determines an SVG symbol's name from its path.
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a point.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static QSizeF toSize(const QVariant &value, bool *ok=nullptr)
Converts a value to a size.
static std::unique_ptr< QgsSymbol > loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
static QPainter::CompositionMode decodeBlendMode(const QString &s)
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
static QString encodeColor(const QColor &color)
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
static QString symbolProperties(QgsSymbol *symbol)
Returns a string representing the symbol.
@ StrokeColor
Stroke color.
@ JoinStyle
Line join style.
@ StrokeWidth
Stroke width.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
QgsMapUnitScale strokeWidthMapUnitScale() const
Returns the map unit scale object for the shape stroke width.
void setRadiiUnit(Qgis::RenderUnit units)
Sets the units used for the shape's radii.
void setFillSymbol(QgsFillSymbol *symbol)
Sets the current fill symbol for the background shape.
RotationType rotationType() const
Returns the method used for rotating the background shape.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
QSizeF size() const
Returns the size of the background shape.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns all field names referenced by the configuration (e.g.
QgsMapUnitScale radiiMapUnitScale() const
Returns the map unit scale object for the shape radii.
void upgradeDataDefinedProperties(QgsPropertyCollection &properties)
Upgrade data defined properties when reading a project file saved in QGIS prior to version 3....
void setOpacity(double opacity)
Sets the background shape's opacity.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
Qgis::RenderUnit radiiUnit() const
Returns the units used for the shape's radii.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape size.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing the background shape.
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
SizeType
Methods for determining the background shape size.
@ SizeBuffer
Shape size is determined by adding a buffer margin around text.
bool enabled() const
Returns whether the background is enabled.
QgsTextBackgroundSettings()
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Read settings from a DOM element.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the background shape.
double opacity() const
Returns the background shape's opacity.
bool operator!=(const QgsTextBackgroundSettings &other) const
void updateDataDefinedProperties(QgsRenderContext &context, const QgsPropertyCollection &properties)
Updates the format by evaluating current values of data defined properties.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape stroke width.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
QColor fillColor() const
Returns the color used for filing the background shape.
void setMarkerSymbol(QgsMarkerSymbol *symbol)
Sets the current marker symbol for the background shape.
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
QgsTextBackgroundSettings & operator=(const QgsTextBackgroundSettings &other)
Qgis::RenderUnit strokeWidthUnit() const
Returns the units used for the shape's stroke width.
~QgsTextBackgroundSettings()
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
ShapeType
Background shape types.
@ ShapeRectangle
Rectangle.
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the background shape.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the shape's size.
Qgis::RenderUnit offsetUnit() const
Returns the units used for the shape's offset.
QColor strokeColor() const
Returns the color used for outlining the background shape.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Write settings into a DOM element.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape offset.
QgsFillSymbol * fillSymbol() const
Returns the fill symbol to be rendered in the background.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
void readFromLayer(QgsVectorLayer *layer)
Reads settings from a layer's custom properties (for QGIS 2.x projects).
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Qgis::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
RotationType
Methods for determining the rotation of the background shape.
@ RotationSync
Shape rotation is synced with text rotation.
bool operator==(const QgsTextBackgroundSettings &other) const
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
QgsMarkerSymbol * markerSymbol() const
Returns the marker symbol to be rendered in the background.
void setRadiiMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the shape radii.
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.
void setStrokeWidthUnit(Qgis::RenderUnit units)
Sets the units used for the shape's stroke width.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shape's offset.
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
void setSize(QSizeF size)
Sets the size of the background shape.
const QgsPaintEffect * paintEffect() const
Returns the current paint effect for the background shape.
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
QgsMapUnitScale offsetMapUnitScale() const
Returns the map unit scale object for the shape offset.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
QPointF offset() const
Returns the offset used for drawing the background shape.
static QgsTextBackgroundSettings::ShapeType decodeShapeType(const QString &string)
Decodes a string representation of a background shape type to a type.
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 QgsTextBackgroundSettings::RotationType decodeBackgroundRotationType(const QString &string)
Decodes a string representation of a background rotation type to a type.
static QgsTextBackgroundSettings::SizeType decodeBackgroundSizeType(const QString &string)
Decodes a string representation of a background size type to a type.
static Qgis::RenderUnit convertFromOldLabelUnit(int val)
Converts a unit from an old (pre 3.0) label unit.
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.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).