24 d =
new QgsTextMaskSettingsPrivate();
42 if ( d->enabled != other.
enabled()
43 || d->type != other.
type()
44 || d->size != other.
size()
48 || d->opacity != other.
opacity()
52 if (
static_cast< bool >( d->paintEffect ) !=
static_cast< bool >( other.
paintEffect() )
61 return !( *
this == other );
107 return d->sizeMapUnitScale;
112 d->sizeMapUnitScale = scale;
122 d->joinStyle = style;
137 return d->paintEffect.get();
142 d->paintEffect.reset( effect );
162 if ( !exprVal.isNull() )
164 const QString units = exprVal.toString();
165 if ( !units.isEmpty() )
181 d->opacity = val.toDouble() / 100.0;
188 const QString joinstr = exprVal.toString().trimmed();
189 if ( !joinstr.isEmpty() )
198 return QSet< QString >();
203 const QDomElement textMaskElem = elem.firstChildElement( QStringLiteral(
"text-mask" ) );
204 d->enabled = textMaskElem.attribute( QStringLiteral(
"maskEnabled" ), QStringLiteral(
"0" ) ).toInt();
205 d->type =
static_cast<QgsTextMaskSettings::MaskType>( textMaskElem.attribute( QStringLiteral(
"maskType" ), QStringLiteral(
"0" ) ).toInt() );
206 d->size = textMaskElem.attribute( QStringLiteral(
"maskSize" ), QStringLiteral(
"0" ) ).toDouble();
209 d->joinStyle =
static_cast< Qt::PenJoinStyle
>( textMaskElem.attribute( QStringLiteral(
"maskJoinStyle" ), QString::number( Qt::RoundJoin ) ).toUInt() );
210 d->opacity = textMaskElem.attribute( QStringLiteral(
"maskOpacity" ), QStringLiteral(
"1.0" ) ).toDouble();
211 const QDomElement effectElem = textMaskElem.firstChildElement( QStringLiteral(
"effect" ) );
212 if ( !effectElem.isNull() )
221 QDomElement textMaskElem = doc.createElement( QStringLiteral(
"text-mask" ) );
222 textMaskElem.setAttribute( QStringLiteral(
"maskEnabled" ), d->enabled );
223 textMaskElem.setAttribute( QStringLiteral(
"maskType" ), d->type );
224 textMaskElem.setAttribute( QStringLiteral(
"maskSize" ), d->size );
227 textMaskElem.setAttribute( QStringLiteral(
"maskJoinStyle" ),
static_cast< unsigned int >( d->joinStyle ) );
228 textMaskElem.setAttribute( QStringLiteral(
"maskOpacity" ), d->opacity );
230 d->paintEffect->saveProperties( doc, textMaskElem );
237 return d->maskedSymbolLayers;
242 d->maskedSymbolLayers = maskedSymbols;
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.
Struct for storing maximum and minimum scales for measurements in map units.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
QgsPaintEffect * createEffect(const QString &name, const QVariantMap &properties=QVariantMap()) const
Creates a new paint effect given the effect name and properties map.
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.
@ MaskEnabled
Whether the mask is enabled.
@ MaskJoinStyle
Mask join style.
@ MaskBufferUnit
Mask buffer size unit.
@ MaskBufferSize
Mask buffer size.
@ MaskOpacity
Mask 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 Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
Container for settings relating to a selective masking around a text.
void setEnabled(bool)
Returns whether the mask is enabled.
void setMaskedSymbolLayers(const QList< QgsSymbolLayerReference > &maskedLayers)
Sets the symbol layers that will be masked by this buffer.
MaskType
Mask shape types.
QList< QgsSymbolLayerReference > maskedSymbolLayers() const
Returns a list of references to symbol layers that are masked by this buffer.
void setSize(double size)
Sets the size of the buffer.
QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns all field names referenced by the configuration (e.g.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
double size() const
Returns the size of the buffer.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the buffer size.
void updateDataDefinedProperties(QgsRenderContext &context, const QgsPropertyCollection &properties)
Updates the format by evaluating current values of data defined properties.
void readXml(const QDomElement &elem)
Read settings from a DOM element.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
QDomElement writeXml(QDomDocument &doc) const
Write settings into a DOM element.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the mask.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the buffer size.
double opacity() const
Returns the mask's opacity.
bool enabled() const
Returns whether the mask is enabled.
bool operator==(const QgsTextMaskSettings &other) const
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the mask.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
void setType(MaskType type)
Sets the type of mask shape.
MaskType type() const
Returns the type of mask shape.
bool operator!=(const QgsTextMaskSettings &other) const
QgsTextMaskSettings & operator=(const QgsTextMaskSettings &other)
Copy constructor.
void setOpacity(double opacity)
Sets the mask's opacity.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
RenderUnit
Rendering size units.
QString symbolLayerReferenceListToString(const QgsSymbolLayerReferenceList &lst)
Utilitary function to turn a QgsSymbolLayerReferenceList into a string.
QgsSymbolLayerReferenceList stringToSymbolLayerReferenceList(const QString &str)
Utilitary function to parse a string originated from symbolLayerReferenceListToString into a QgsSymbo...