30 d =
new QgsTextBackgroundSettingsPrivate();
64 if ( !d->enabled == other.
enabled()
65 || d->type != other.
type()
66 || d->svgFile != other.
svgFile()
68 || d->size != other.
size()
73 || d->offset != other.
offset()
76 || d->radii != other.
radii()
82 || d->opacity != other.
opacity()
89 if (
static_cast< bool >( d->paintEffect ) !=
static_cast< bool >( other.
paintEffect() )
93 if (
static_cast< bool >( d->markerSymbol ) !=
static_cast< bool >( other.
markerSymbol() )
97 if (
static_cast< bool >( d->fillSymbol ) !=
static_cast< bool >( other.
fillSymbol() )
106 return !( *
this == other );
141 return d->markerSymbol.get();
150 d->markerSymbol.reset( symbol );
155 return d->fillSymbol.get();
164 d->fillSymbol.reset( symbol );
199 return d->sizeMapUnitScale;
204 d->sizeMapUnitScale = scale;
209 return d->rotationType;
214 d->rotationType =
type;
239 return d->offsetUnits;
244 d->offsetUnits = units;
249 return d->offsetMapUnitScale;
254 d->offsetMapUnitScale = scale;
269 return d->radiiUnits;
274 d->radiiUnits = units;
279 return d->radiiMapUnitScale;
284 d->radiiMapUnitScale = scale;
314 d->fillColor = color;
315 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String(
"SimpleFill" ) )
317 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setColor( color );
323 return d->strokeColor;
328 d->strokeColor = color;
329 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String(
"SimpleFill" ) )
331 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeColor( color );
337 return d->strokeWidth;
342 d->strokeWidth = width;
343 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String(
"SimpleFill" ) )
345 QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) );
353 return d->strokeWidthUnits;
358 d->strokeWidthUnits = units;
359 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String(
"SimpleFill" ) )
361 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeWidthUnit( units );
367 return d->strokeWidthMapUnitScale;
372 d->strokeWidthMapUnitScale = scale;
373 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String(
"SimpleFill" ) )
375 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeWidthMapUnitScale( scale );
386 d->joinStyle = style;
387 if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String(
"SimpleFill" ) )
389 qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setPenJoinStyle( style );
395 return d->paintEffect.get();
400 d->paintEffect.reset( effect );
405 d->enabled = layer->
customProperty( QStringLiteral(
"labeling/shapeDraw" ), QVariant(
false ) ).toBool();
407 d->svgFile = layer->
customProperty( QStringLiteral(
"labeling/shapeSVGFile" ), QVariant(
"" ) ).toString();
409 d->size = QSizeF( layer->
customProperty( QStringLiteral(
"labeling/shapeSizeX" ), QVariant( 0.0 ) ).toDouble(),
410 layer->
customProperty( QStringLiteral(
"labeling/shapeSizeY" ), QVariant( 0.0 ) ).toDouble() );
412 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeSizeUnit" ) ).toString().isEmpty() )
421 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeSizeMapUnitScale" ) ).toString().isEmpty() )
424 const double oldMin = layer->
customProperty( QStringLiteral(
"labeling/shapeSizeMapUnitMinScale" ), 0.0 ).toDouble();
425 d->sizeMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
426 const double oldMax = layer->
customProperty( QStringLiteral(
"labeling/shapeSizeMapUnitMaxScale" ), 0.0 ).toDouble();
427 d->sizeMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
434 d->rotation = layer->
customProperty( QStringLiteral(
"labeling/shapeRotation" ), QVariant( 0.0 ) ).toDouble();
435 d->offset = QPointF( layer->
customProperty( QStringLiteral(
"labeling/shapeOffsetX" ), QVariant( 0.0 ) ).toDouble(),
436 layer->
customProperty( QStringLiteral(
"labeling/shapeOffsetY" ), QVariant( 0.0 ) ).toDouble() );
438 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeOffsetUnit" ) ).toString().isEmpty() )
447 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeOffsetMapUnitScale" ) ).toString().isEmpty() )
450 const double oldMin = layer->
customProperty( QStringLiteral(
"labeling/shapeOffsetMapUnitMinScale" ), 0.0 ).toDouble();
451 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
452 const double oldMax = layer->
customProperty( QStringLiteral(
"labeling/shapeOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
453 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
459 d->radii = QSizeF( layer->
customProperty( QStringLiteral(
"labeling/shapeRadiiX" ), QVariant( 0.0 ) ).toDouble(),
460 layer->
customProperty( QStringLiteral(
"labeling/shapeRadiiY" ), QVariant( 0.0 ) ).toDouble() );
463 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeRadiiUnit" ) ).toString().isEmpty() )
472 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeRadiiMapUnitScale" ) ).toString().isEmpty() )
475 const double oldMin = layer->
customProperty( QStringLiteral(
"labeling/shapeRadiiMapUnitMinScale" ), 0.0 ).toDouble();
476 d->radiiMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
477 const double oldMax = layer->
customProperty( QStringLiteral(
"labeling/shapeRadiiMapUnitMaxScale" ), 0.0 ).toDouble();
478 d->radiiMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
486 d->strokeWidth = layer->
customProperty( QStringLiteral(
"labeling/shapeBorderWidth" ), QVariant( .0 ) ).toDouble();
487 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeBorderWidthUnit" ) ).toString().isEmpty() )
495 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeBorderWidthMapUnitScale" ) ).toString().isEmpty() )
498 const double oldMin = layer->
customProperty( QStringLiteral(
"labeling/shapeBorderWidthMapUnitMinScale" ), 0.0 ).toDouble();
499 d->strokeWidthMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
500 const double oldMax = layer->
customProperty( QStringLiteral(
"labeling/shapeBorderWidthMapUnitMaxScale" ), 0.0 ).toDouble();
501 d->strokeWidthMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
507 d->joinStyle =
static_cast< Qt::PenJoinStyle
>( layer->
customProperty( QStringLiteral(
"labeling/shapeJoinStyle" ), QVariant( Qt::BevelJoin ) ).toUInt() );
509 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeOpacity" ) ).toString().isEmpty() )
511 d->opacity = ( 1 - layer->
customProperty( QStringLiteral(
"labeling/shapeTransparency" ) ).toInt() / 100.0 );
515 d->opacity = ( layer->
customProperty( QStringLiteral(
"labeling/shapeOpacity" ) ).toDouble() );
520 if ( layer->
customProperty( QStringLiteral(
"labeling/shapeEffect" ) ).isValid() )
522 QDomDocument doc( QStringLiteral(
"effect" ) );
523 doc.setContent( layer->
customProperty( QStringLiteral(
"labeling/shapeEffect" ) ).toString() );
524 const QDomElement effectElem = doc.firstChildElement( QStringLiteral(
"effect" ) ).firstChildElement( QStringLiteral(
"effect" ) );
533 const QDomElement backgroundElem = elem.firstChildElement( QStringLiteral(
"background" ) );
534 d->enabled = backgroundElem.attribute( QStringLiteral(
"shapeDraw" ), QStringLiteral(
"0" ) ).toInt();
535 d->type =
static_cast< ShapeType >( backgroundElem.attribute( QStringLiteral(
"shapeType" ), QString::number(
ShapeRectangle ) ).toUInt() );
537 d->sizeType =
static_cast< SizeType >( backgroundElem.attribute( QStringLiteral(
"shapeSizeType" ), QString::number(
SizeBuffer ) ).toUInt() );
538 d->size = QSizeF( backgroundElem.attribute( QStringLiteral(
"shapeSizeX" ), QStringLiteral(
"0" ) ).toDouble(),
539 backgroundElem.attribute( QStringLiteral(
"shapeSizeY" ), QStringLiteral(
"0" ) ).toDouble() );
541 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeSizeUnit" ) ) )
550 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeSizeMapUnitScale" ) ) )
553 const double oldMin = backgroundElem.attribute( QStringLiteral(
"shapeSizeMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
554 d->sizeMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
555 const double oldMax = backgroundElem.attribute( QStringLiteral(
"shapeSizeMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
556 d->sizeMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
562 d->rotationType =
static_cast< RotationType >( backgroundElem.attribute( QStringLiteral(
"shapeRotationType" ), QString::number(
RotationSync ) ).toUInt() );
563 d->rotation = backgroundElem.attribute( QStringLiteral(
"shapeRotation" ), QStringLiteral(
"0" ) ).toDouble();
564 d->offset = QPointF( backgroundElem.attribute( QStringLiteral(
"shapeOffsetX" ), QStringLiteral(
"0" ) ).toDouble(),
565 backgroundElem.attribute( QStringLiteral(
"shapeOffsetY" ), QStringLiteral(
"0" ) ).toDouble() );
567 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeOffsetUnit" ) ) )
576 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeOffsetMapUnitScale" ) ) )
579 const double oldMin = backgroundElem.attribute( QStringLiteral(
"shapeOffsetMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
580 d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
581 const double oldMax = backgroundElem.attribute( QStringLiteral(
"shapeOffsetMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
582 d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
588 d->radii = QSizeF( backgroundElem.attribute( QStringLiteral(
"shapeRadiiX" ), QStringLiteral(
"0" ) ).toDouble(),
589 backgroundElem.attribute( QStringLiteral(
"shapeRadiiY" ), QStringLiteral(
"0" ) ).toDouble() );
591 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeRadiiUnit" ) ) )
599 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeRadiiMapUnitScale" ) ) )
602 const double oldMin = backgroundElem.attribute( QStringLiteral(
"shapeRadiiMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
603 d->radiiMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
604 const double oldMax = backgroundElem.attribute( QStringLiteral(
"shapeRadiiMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
605 d->radiiMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
613 d->strokeWidth = backgroundElem.attribute( QStringLiteral(
"shapeBorderWidth" ), QStringLiteral(
"0" ) ).toDouble();
615 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeBorderWidthUnit" ) ) )
623 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeBorderWidthMapUnitScale" ) ) )
626 const double oldMin = backgroundElem.attribute( QStringLiteral(
"shapeBorderWidthMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
627 d->strokeWidthMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
628 const double oldMax = backgroundElem.attribute( QStringLiteral(
"shapeBorderWidthMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
629 d->strokeWidthMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
635 d->joinStyle =
static_cast< Qt::PenJoinStyle
>( backgroundElem.attribute( QStringLiteral(
"shapeJoinStyle" ), QString::number( Qt::BevelJoin ) ).toUInt() );
637 if ( !backgroundElem.hasAttribute( QStringLiteral(
"shapeOpacity" ) ) )
639 d->opacity = ( 1 - backgroundElem.attribute( QStringLiteral(
"shapeTransparency" ) ).toInt() / 100.0 );
643 d->opacity = ( backgroundElem.attribute( QStringLiteral(
"shapeOpacity" ) ).toDouble() );
649 const QDomElement effectElem = backgroundElem.firstChildElement( QStringLiteral(
"effect" ) );
650 if ( !effectElem.isNull() )
657 const QDomNodeList symbols = backgroundElem.elementsByTagName( QStringLiteral(
"symbol" ) );
658 for (
int i = 0; i < symbols.size(); ++i )
660 if ( symbols.at( i ).isElement() )
662 const QDomElement symbolElement = symbols.at( i ).toElement();
663 const QString symbolElementName = symbolElement.attribute( QStringLiteral(
"name" ) );
664 if ( symbolElementName == QLatin1String(
"markerSymbol" ) )
666 setMarkerSymbol( QgsSymbolLayerUtils::loadSymbol< QgsMarkerSymbol >( symbolElement, context ) );
668 else if ( symbolElementName == QLatin1String(
"fillSymbol" ) )
670 setFillSymbol( QgsSymbolLayerUtils::loadSymbol< QgsFillSymbol >( symbolElement, context ) );
675 if ( !d->fillSymbol )
692 QDomElement backgroundElem = doc.createElement( QStringLiteral(
"background" ) );
693 backgroundElem.setAttribute( QStringLiteral(
"shapeDraw" ), d->enabled );
694 backgroundElem.setAttribute( QStringLiteral(
"shapeType" ),
static_cast< unsigned int >( d->type ) );
696 backgroundElem.setAttribute( QStringLiteral(
"shapeSizeType" ),
static_cast< unsigned int >( d->sizeType ) );
697 backgroundElem.setAttribute( QStringLiteral(
"shapeSizeX" ), d->size.width() );
698 backgroundElem.setAttribute( QStringLiteral(
"shapeSizeY" ), d->size.height() );
701 backgroundElem.setAttribute( QStringLiteral(
"shapeRotationType" ),
static_cast< unsigned int >( d->rotationType ) );
702 backgroundElem.setAttribute( QStringLiteral(
"shapeRotation" ), d->rotation );
703 backgroundElem.setAttribute( QStringLiteral(
"shapeOffsetX" ), d->offset.x() );
704 backgroundElem.setAttribute( QStringLiteral(
"shapeOffsetY" ), d->offset.y() );
707 backgroundElem.setAttribute( QStringLiteral(
"shapeRadiiX" ), d->radii.width() );
708 backgroundElem.setAttribute( QStringLiteral(
"shapeRadiiY" ), d->radii.height() );
713 backgroundElem.setAttribute( QStringLiteral(
"shapeBorderWidth" ), d->strokeWidth );
714 backgroundElem.setAttribute( QStringLiteral(
"shapeBorderWidthUnit" ),
QgsUnitTypes::encodeUnit( d->strokeWidthUnits ) );
716 backgroundElem.setAttribute( QStringLiteral(
"shapeJoinStyle" ),
static_cast< unsigned int >( d->joinStyle ) );
717 backgroundElem.setAttribute( QStringLiteral(
"shapeOpacity" ), d->opacity );
720 d->paintEffect->saveProperties( doc, backgroundElem );
722 if ( d->markerSymbol )
728 return backgroundElem;
733 if ( !d->fillSymbol || d->fillSymbol->symbolLayers().at( 0 )->layerType() != QLatin1String(
"SimpleFill" ) )
735 QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) );
791 const QString units = exprVal.toString();
792 if ( !units.isEmpty() )
804 const QString skind = exprVal.toString().trimmed();
805 if ( !skind.isEmpty() )
814 const QString stype = exprVal.toString().trimmed();
815 if ( !stype.isEmpty() )
826 const QString svgfile = exprVal.toString().trimmed();
838 const QString rotstr = exprVal.toString().trimmed();
839 if ( !rotstr.isEmpty() )
858 const QString units = exprVal.toString();
859 if ( !units.isEmpty() )
864 d->offsetUnits = res;
882 const QString units = exprVal.toString();
883 if ( !units.isEmpty() )
898 d->opacity = val.toDouble() / 100.0;
923 const QString units = exprVal.toString();
924 if ( !units.isEmpty() )
929 d->strokeWidthUnits = res;
936 const QString blendstr = exprVal.toString().trimmed();
937 if ( !blendstr.isEmpty() )
944 const QString joinstr = exprVal.toString().trimmed();
945 if ( !joinstr.isEmpty() )
954 QSet< QString > fields;
955 if ( d->markerSymbol )
957 fields.unite( d->markerSymbol->usedAttributes( context ) );
961 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.
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.
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 a integer key value.
bool hasProperty(int key) const override
Returns true if the collection contains a property with the specified key.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
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.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
A store for object properties.
The class is used as a container of context for various read/write operations on other 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...
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 QColor decodeColor(const QString &str)
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 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.
@ PropertyJoinStyle
Line join style.
@ PropertyStrokeWidth
Stroke width.
@ PropertyFillColor
Fill color.
@ PropertyStrokeColor
Stroke color.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
bool changeSymbolLayer(int index, QgsSymbolLayer *layer)
Deletes the current layer at the specified index and replaces it with layer.
Container for settings relating to a text background object.
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)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based data sets.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)