QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
QgsRuleBasedLabeling Class Reference

Rule based labeling for a vector layer. More...

#include <qgsrulebasedlabeling.h>

Inheritance diagram for QgsRuleBasedLabeling:
Inheritance graph
[legend]

Classes

class  Rule
 A child rule for QgsRuleBasedLabeling. More...
 

Public Types

typedef QList< QgsRuleBasedLabeling::Rule * > RuleList
 
typedef QMap< QgsRuleBasedLabeling::Rule *, QgsVectorLayerLabelProvider * > RuleToProviderMap
 

Public Member Functions

 QgsRuleBasedLabeling (QgsRuleBasedLabeling::Rule *root)
 Constructs the labeling from given tree of rules (takes ownership)
 
 ~QgsRuleBasedLabeling () override
 
bool accept (QgsStyleEntityVisitorInterface *visitor) const override
 Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling.
 
QgsRuleBasedLabelingclone () const override
 Returns a new copy of the object.
 
void multiplyOpacity (double opacityFactor) override
 Multiply opacity by opacityFactor.
 
QgsVectorLayerLabelProviderprovider (QgsVectorLayer *layer) const override
 
bool requiresAdvancedEffects () const override
 Returns true if drawing labels requires advanced effects like composition modes, which could prevent it being used as an isolated cached image or exported to a vector format.
 
QgsRuleBasedLabeling::RulerootRule ()
 
const RulerootRule () const
 
QDomElement save (QDomDocument &doc, const QgsReadWriteContext &context) const override
 Returns labeling configuration as XML element.
 
void setSettings (QgsPalLayerSettings *settings, const QString &providerId=QString()) override
 Set pal settings for a specific provider (takes ownership).
 
QgsPalLayerSettings settings (const QString &providerId=QString()) const override
 Gets associated label settings.
 
QStringList subProviders () const override
 Gets list of sub-providers within the layer's labeling.
 
void toSld (QDomNode &parent, const QVariantMap &props) const override
 Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
 
QString type () const override
 Unique type string of the labeling configuration implementation.
 
- Public Member Functions inherited from QgsAbstractVectorLayerLabeling
 QgsAbstractVectorLayerLabeling ()=default
 
virtual ~QgsAbstractVectorLayerLabeling ()=default
 

Static Public Member Functions

static QgsRuleBasedLabelingcreate (const QDomElement &element, const QgsReadWriteContext &context)
 Create the instance from a DOM element with saved configuration.
 
- Static Public Member Functions inherited from QgsAbstractVectorLayerLabeling
static QgsAbstractVectorLayerLabelingcreate (const QDomElement &element, const QgsReadWriteContext &context)
 Try to create instance of an implementation based on the XML data.
 
static QgsPalLayerSettings defaultSettingsForLayer (const QgsVectorLayer *layer)
 Returns the default layer settings to use for the specified vector layer.
 

Protected Attributes

std::unique_ptr< RulemRootRule
 

Additional Inherited Members

- Protected Member Functions inherited from QgsAbstractVectorLayerLabeling
virtual void writeTextSymbolizer (QDomNode &parent, QgsPalLayerSettings &settings, const QVariantMap &props) const
 Writes a TextSymbolizer element contents based on the provided labeling settings.
 

Detailed Description

Rule based labeling for a vector layer.

Definition at line 41 of file qgsrulebasedlabeling.h.

Member Typedef Documentation

◆ RuleList

Definition at line 45 of file qgsrulebasedlabeling.h.

◆ RuleToProviderMap

Definition at line 46 of file qgsrulebasedlabeling.h.

Constructor & Destructor Documentation

◆ QgsRuleBasedLabeling()

QgsRuleBasedLabeling::QgsRuleBasedLabeling ( QgsRuleBasedLabeling::Rule root)
explicit

Constructs the labeling from given tree of rules (takes ownership)

Definition at line 444 of file qgsrulebasedlabeling.cpp.

◆ ~QgsRuleBasedLabeling()

QgsRuleBasedLabeling::~QgsRuleBasedLabeling ( )
override

Definition at line 465 of file qgsrulebasedlabeling.cpp.

Member Function Documentation

◆ accept()

bool QgsRuleBasedLabeling::accept ( QgsStyleEntityVisitorInterface visitor) const
overridevirtual

Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling.

Returns true if the visitor should continue visiting other objects, or false if visiting should be canceled.

Since
QGIS 3.10

Reimplemented from QgsAbstractVectorLayerLabeling.

Definition at line 530 of file qgsrulebasedlabeling.cpp.

◆ clone()

QgsRuleBasedLabeling * QgsRuleBasedLabeling::clone ( ) const
overridevirtual

Returns a new copy of the object.

Implements QgsAbstractVectorLayerLabeling.

Definition at line 449 of file qgsrulebasedlabeling.cpp.

◆ create()

QgsRuleBasedLabeling * QgsRuleBasedLabeling::create ( const QDomElement &  element,
const QgsReadWriteContext context 
)
static

Create the instance from a DOM element with saved configuration.

Definition at line 480 of file qgsrulebasedlabeling.cpp.

◆ multiplyOpacity()

void QgsRuleBasedLabeling::multiplyOpacity ( double  opacityFactor)
overridevirtual

Multiply opacity by opacityFactor.

This method multiplies the opacity of the labeling elements (text, shadow, buffer etc.) by opacity effectively changing the opacity of the whole labeling elements.

Since
QGIS 3.32

Reimplemented from QgsAbstractVectorLayerLabeling.

Definition at line 591 of file qgsrulebasedlabeling.cpp.

◆ provider()

QgsVectorLayerLabelProvider * QgsRuleBasedLabeling::provider ( QgsVectorLayer layer) const
overridevirtual
Note
not available in Python bindings

Reimplemented from QgsAbstractVectorLayerLabeling.

Definition at line 509 of file qgsrulebasedlabeling.cpp.

◆ requiresAdvancedEffects()

bool QgsRuleBasedLabeling::requiresAdvancedEffects ( ) const
overridevirtual

Returns true if drawing labels requires advanced effects like composition modes, which could prevent it being used as an isolated cached image or exported to a vector format.

Implements QgsAbstractVectorLayerLabeling.

Definition at line 535 of file qgsrulebasedlabeling.cpp.

◆ rootRule() [1/2]

QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::rootRule ( )

Definition at line 469 of file qgsrulebasedlabeling.cpp.

◆ rootRule() [2/2]

const QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::rootRule ( ) const

Definition at line 474 of file qgsrulebasedlabeling.cpp.

◆ save()

QDomElement QgsRuleBasedLabeling::save ( QDomDocument &  doc,
const QgsReadWriteContext context 
) const
overridevirtual

Returns labeling configuration as XML element.

Implements QgsAbstractVectorLayerLabeling.

Definition at line 497 of file qgsrulebasedlabeling.cpp.

◆ setSettings()

void QgsRuleBasedLabeling::setSettings ( QgsPalLayerSettings settings,
const QString &  providerId = QString() 
)
overridevirtual

Set pal settings for a specific provider (takes ownership).

Parameters
settingsPal layer settings
providerIdThe id of the provider

Implements QgsAbstractVectorLayerLabeling.

Definition at line 540 of file qgsrulebasedlabeling.cpp.

◆ settings()

QgsPalLayerSettings QgsRuleBasedLabeling::settings ( const QString &  providerId = QString()) const
overridevirtual

Gets associated label settings.

In case of multiple sub-providers with different settings, they are identified by their ID (e.g. in case of rule-based labeling, provider ID == rule key)

Implements QgsAbstractVectorLayerLabeling.

Definition at line 521 of file qgsrulebasedlabeling.cpp.

◆ subProviders()

QStringList QgsRuleBasedLabeling::subProviders ( ) const
overridevirtual

Gets list of sub-providers within the layer's labeling.

Reimplemented from QgsAbstractVectorLayerLabeling.

Definition at line 514 of file qgsrulebasedlabeling.cpp.

◆ toSld()

void QgsRuleBasedLabeling::toSld ( QDomNode &  parent,
const QVariantMap &  props 
) const
overridevirtual

Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.

Reimplemented from QgsAbstractVectorLayerLabeling.

Definition at line 550 of file qgsrulebasedlabeling.cpp.

◆ type()

QString QgsRuleBasedLabeling::type ( ) const
overridevirtual

Unique type string of the labeling configuration implementation.

Implements QgsAbstractVectorLayerLabeling.

Definition at line 492 of file qgsrulebasedlabeling.cpp.

Member Data Documentation

◆ mRootRule

std::unique_ptr<Rule> QgsRuleBasedLabeling::mRootRule
protected

Definition at line 393 of file qgsrulebasedlabeling.h.


The documentation for this class was generated from the following files: