Skip to content
Permalink
Browse files

Ensure that fields required by marker symbol backgrounds for labels

are fetched when rendering

Fixes #36944
  • Loading branch information
nyalldawson committed Jun 3, 2020
1 parent 6b27958 commit 8fb8e45d516611f09bf28e3832c3c6214f16c4a2
@@ -599,6 +599,13 @@ Write settings into a DOM element.
Updates the format by evaluating current values of data defined properties.

.. versionadded:: 3.10
%End

QSet<QString> referencedFields( const QgsRenderContext &context ) const;
%Docstring
Returns all field names referenced by the configuration (e.g. from data defined properties).

.. versionadded:: 3.14
%End

};
@@ -246,6 +246,13 @@ Sets the current paint ``effect`` for the buffer.
Updates the format by evaluating current values of data defined properties.

.. versionadded:: 3.10
%End

QSet<QString> referencedFields( const QgsRenderContext &context ) const;
%Docstring
Returns all field names referenced by the configuration (e.g. from data defined properties).

.. versionadded:: 3.14
%End

};
@@ -473,6 +473,13 @@ Returns a reference to the format's property collection, used for data defined o
%End


QSet<QString> referencedFields( const QgsRenderContext &context ) const;
%Docstring
Returns all field names referenced by the configuration (e.g. from data defined properties).

.. versionadded:: 3.14
%End

void setDataDefinedProperties( const QgsPropertyCollection &collection );
%Docstring
Sets the format's property collection, used for data defined overrides.
@@ -221,6 +221,13 @@ Sets the symbol layers that will be masked by this buffer.
void updateDataDefinedProperties( QgsRenderContext &context, const QgsPropertyCollection &properties );
%Docstring
Updates the format by evaluating current values of data defined properties.
%End

QSet<QString> referencedFields( const QgsRenderContext &context ) const;
%Docstring
Returns all field names referenced by the configuration (e.g. from data defined properties).

.. versionadded:: 3.14
%End

};
@@ -352,6 +352,13 @@ Write settings into a DOM element.
Updates the format by evaluating current values of data defined properties.

.. versionadded:: 3.10
%End

QSet<QString> referencedFields( const QgsRenderContext &context ) const;
%Docstring
Returns all field names referenced by the configuration (e.g. from data defined properties).

.. versionadded:: 3.14
%End

};
@@ -474,6 +474,7 @@ bool QgsPalLayerSettings::prepare( QgsRenderContext &context, QSet<QString> &att
attributeNames.insert( name );
}
}
attributeNames.unite( mFormat.referencedFields( context ) );

if ( mCallout )
{
@@ -502,6 +503,8 @@ QSet<QString> QgsPalLayerSettings::referencedFields( const QgsRenderContext &con
}
}

referenced.unite( mFormat.referencedFields( context ) );

// calling referencedFields() with ignoreContext=true because in our expression context
// we do not have valid QgsFields yet - because of that the field names from expressions
// wouldn't get reported
@@ -767,3 +767,13 @@ void QgsTextBackgroundSettings::updateDataDefinedProperties( QgsRenderContext &c
}
}
}

QSet<QString> QgsTextBackgroundSettings::referencedFields( const QgsRenderContext &context ) const
{
QSet< QString > fields;
if ( d->markerSymbol )
{
fields.unite( d->markerSymbol->usedAttributes( context ) );
}
return fields;
}
@@ -508,6 +508,12 @@ class CORE_EXPORT QgsTextBackgroundSettings
*/
void updateDataDefinedProperties( QgsRenderContext &context, const QgsPropertyCollection &properties );

/**
* Returns all field names referenced by the configuration (e.g. from data defined properties).
* \since QGIS 3.14
*/
QSet<QString> referencedFields( const QgsRenderContext &context ) const;

private:

QSharedDataPointer<QgsTextBackgroundSettingsPrivate> d;
@@ -202,6 +202,11 @@ void QgsTextBufferSettings::updateDataDefinedProperties( QgsRenderContext &conte
}
}

QSet<QString> QgsTextBufferSettings::referencedFields( const QgsRenderContext & ) const
{
return QSet< QString >(); // nothing for now
}

void QgsTextBufferSettings::readFromLayer( QgsVectorLayer *layer )
{
// text buffer
@@ -227,6 +227,12 @@ class CORE_EXPORT QgsTextBufferSettings
*/
void updateDataDefinedProperties( QgsRenderContext &context, const QgsPropertyCollection &properties );

/**
* Returns all field names referenced by the configuration (e.g. from data defined properties).
* \since QGIS 3.14
*/
QSet<QString> referencedFields( const QgsRenderContext &context ) const;

private:

QSharedDataPointer<QgsTextBufferSettingsPrivate> d;
@@ -576,6 +576,16 @@ const QgsPropertyCollection &QgsTextFormat::dataDefinedProperties() const
return d->mDataDefinedProperties;
}

QSet<QString> QgsTextFormat::referencedFields( const QgsRenderContext &context ) const
{
QSet< QString > fields = d->mDataDefinedProperties.referencedFields( context.expressionContext(), true );
fields.unite( mBufferSettings.referencedFields( context ) );
fields.unite( mBackgroundSettings.referencedFields( context ) );
fields.unite( mShadowSettings.referencedFields( context ) );
fields.unite( mMaskSettings.referencedFields( context ) );
return fields;
}

void QgsTextFormat::setDataDefinedProperties( const QgsPropertyCollection &collection )
{
d->mDataDefinedProperties = collection;
@@ -430,6 +430,12 @@ class CORE_EXPORT QgsTextFormat
*/
const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP;

/**
* Returns all field names referenced by the configuration (e.g. from data defined properties).
* \since QGIS 3.14
*/
QSet<QString> referencedFields( const QgsRenderContext &context ) const;

/**
* Sets the format's property collection, used for data defined overrides.
* \param collection property collection. Existing properties will be replaced.
@@ -165,6 +165,11 @@ void QgsTextMaskSettings::updateDataDefinedProperties( QgsRenderContext &context
}
}

QSet<QString> QgsTextMaskSettings::referencedFields( const QgsRenderContext & ) const
{
return QSet< QString >(); // nothing for now
}

void QgsTextMaskSettings::readXml( const QDomElement &elem )
{
QDomElement textMaskElem = elem.firstChildElement( QStringLiteral( "text-mask" ) );
@@ -209,6 +209,12 @@ class CORE_EXPORT QgsTextMaskSettings
*/
void updateDataDefinedProperties( QgsRenderContext &context, const QgsPropertyCollection &properties );

/**
* Returns all field names referenced by the configuration (e.g. from data defined properties).
* \since QGIS 3.14
*/
QSet<QString> referencedFields( const QgsRenderContext &context ) const;

private:

QSharedDataPointer<QgsTextMaskSettingsPrivate> d;
@@ -436,3 +436,8 @@ void QgsTextShadowSettings::updateDataDefinedProperties( QgsRenderContext &conte
d->blendMode = QgsSymbolLayerUtils::decodeBlendMode( blendstr );
}
}

QSet<QString> QgsTextShadowSettings::referencedFields( const QgsRenderContext & ) const
{
return QSet< QString >(); // nothing for now
}
@@ -306,6 +306,12 @@ class CORE_EXPORT QgsTextShadowSettings
*/
void updateDataDefinedProperties( QgsRenderContext &context, const QgsPropertyCollection &properties );

/**
* Returns all field names referenced by the configuration (e.g. from data defined properties).
* \since QGIS 3.14
*/
QSet<QString> referencedFields( const QgsRenderContext &context ) const;

private:

QSharedDataPointer<QgsTextShadowSettingsPrivate> d;

0 comments on commit 8fb8e45

Please sign in to comment.
You can’t perform that action at this time.