QGIS API Documentation  3.4.15-Madeira (e83d02e274)
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsRuleBasedLabeling::Rule Class Reference

#include <qgsrulebasedlabeling.h>

Public Types

enum  RegisterResult { Filtered = 0, Inactive, Registered }
 The result of registering a rule. More...
 

Public Member Functions

 Rule (QgsPalLayerSettings *settings, double maximumScale=0, double minimumScale=0, const QString &filterExp=QString(), const QString &description=QString(), bool elseRule=false)
 takes ownership of settings, settings may be nullptr More...
 
 Rule (const Rule &rh)=delete
 Rules cannot be copied. More...
 
 ~Rule ()
 
bool active () const
 Returns if this rule is active. More...
 
void appendChild (QgsRuleBasedLabeling::Rule *rule)
 add child rule, take ownership, sets this as parent More...
 
const QgsRuleBasedLabeling::RuleListchildren () const
 Returns all children rules of this rule. More...
 
QgsRuleBasedLabeling::RuleListchildren ()
 Returns all children rules of this rule. More...
 
QgsRuleBasedLabeling::Ruleclone () const
 clone this rule, return new instance More...
 
void createSubProviders (QgsVectorLayer *layer, RuleToProviderMap &subProviders, QgsRuleBasedLabelProvider *provider)
 add providers More...
 
bool dependsOnScale () const
 Determines if scale based labeling is active. More...
 
QgsRuleBasedLabeling::RuleList descendants () const
 Returns all children, grand-children, grand-grand-children, grand-gra... More...
 
QString description () const
 A human readable description for this rule. More...
 
QString filterExpression () const
 A filter that will check if this rule applies. More...
 
const QgsRuleBasedLabeling::RulefindRuleByKey (const QString &key) const
 Try to find a rule given its unique key. More...
 
QgsRuleBasedLabeling::RulefindRuleByKey (const QString &key)
 Find a labeling rule thanks to its key. More...
 
void insertChild (int i, QgsRuleBasedLabeling::Rule *rule)
 add child rule, take ownership, sets this as parent More...
 
bool isElse () const
 Check if this rule is an ELSE rule. More...
 
double maximumScale () const
 Returns the maximum map scale (i.e. More...
 
double minimumScale () const
 Returns the minimum map scale (i.e. More...
 
Ruleoperator= (const Rule &rh)=delete
 Rules cannot be copied. More...
 
const QgsRuleBasedLabeling::Ruleparent () const
 The parent rule. More...
 
QgsRuleBasedLabeling::Ruleparent ()
 The parent rule. More...
 
void prepare (const QgsRenderContext &context, QSet< QString > &attributeNames, RuleToProviderMap &subProviders)
 call prepare() on sub-providers and populate attributeNames More...
 
RegisterResult registerFeature (QgsFeature &feature, QgsRenderContext &context, RuleToProviderMap &subProviders, const QgsGeometry &obstacleGeometry=QgsGeometry())
 register individual features More...
 
void removeChildAt (int i)
 delete child rule More...
 
bool requiresAdvancedEffects () const
 Returns true if this rule or any of its children requires advanced composition effects to render. More...
 
QString ruleKey () const
 Unique rule identifier (for identification of rule within labeling, used as provider ID) More...
 
QDomElement save (QDomDocument &doc, const QgsReadWriteContext &context) const
 store labeling info to XML element More...
 
void setActive (bool state)
 Sets if this rule is active. More...
 
void setDescription (const QString &description)
 Set a human readable description for this rule. More...
 
void setFilterExpression (const QString &filterExp)
 Set the expression used to check if a given feature shall be rendered with this rule. More...
 
void setIsElse (bool iselse)
 Sets if this rule is an ELSE rule. More...
 
void setMaximumScale (double scale)
 Sets the maximum map scale (i.e. More...
 
void setMinimumScale (double scale)
 Sets the minimum map scale (i.e. More...
 
void setRuleKey (const QString &key)
 Override the assigned rule key (should be used just internally by rule-based labeling) More...
 
void setSettings (QgsPalLayerSettings *settings)
 Sets new settings (or NULL). Deletes old settings if any. More...
 
QgsPalLayerSettingssettings () const
 Gets the labeling settings. More...
 
void subProviderIds (QStringList &list) const
 append rule keys of descendants that contain valid settings (i.e. More...
 

Static Public Member Functions

static QgsRuleBasedLabeling::Rulecreate (const QDomElement &ruleElem, const QgsReadWriteContext &context)
 Create a rule from an XML definition. More...
 

Detailed Description

Since
QGIS 3.0

Definition at line 52 of file qgsrulebasedlabeling.h.

Member Enumeration Documentation

The result of registering a rule.

Enumerator
Filtered 

The rule does not apply.

Inactive 

The rule is inactive.

Registered 

Something was registered.

Definition at line 65 of file qgsrulebasedlabeling.h.

Constructor & Destructor Documentation

QgsRuleBasedLabeling::Rule::Rule ( QgsPalLayerSettings settings,
double  maximumScale = 0,
double  minimumScale = 0,
const QString &  filterExp = QString(),
const QString &  description = QString(),
bool  elseRule = false 
)

takes ownership of settings, settings may be nullptr

Definition at line 57 of file qgsrulebasedlabeling.cpp.

QgsRuleBasedLabeling::Rule::~Rule ( )

Definition at line 69 of file qgsrulebasedlabeling.cpp.

QgsRuleBasedLabeling::Rule::Rule ( const Rule rh)
delete

Rules cannot be copied.

Member Function Documentation

bool QgsRuleBasedLabeling::Rule::active ( ) const
inline

Returns if this rule is active.

Returns
True if the rule is active

Definition at line 122 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::appendChild ( QgsRuleBasedLabeling::Rule rule)

add child rule, take ownership, sets this as parent

Definition at line 147 of file qgsrulebasedlabeling.cpp.

const QgsRuleBasedLabeling::RuleList& QgsRuleBasedLabeling::Rule::children ( ) const
inline

Returns all children rules of this rule.

Returns
A list of rules

Definition at line 192 of file qgsrulebasedlabeling.h.

QgsRuleBasedLabeling::RuleList& QgsRuleBasedLabeling::Rule::children ( )
inline

Returns all children rules of this rule.

Returns
A list of rules

Definition at line 199 of file qgsrulebasedlabeling.h.

QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::Rule::clone ( ) const

clone this rule, return new instance

Definition at line 198 of file qgsrulebasedlabeling.cpp.

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

Create a rule from an XML definition.

Parameters
ruleElemThe XML rule element
contextreading context
Returns
A new rule

Definition at line 209 of file qgsrulebasedlabeling.cpp.

void QgsRuleBasedLabeling::Rule::createSubProviders ( QgsVectorLayer layer,
QgsRuleBasedLabeling::RuleToProviderMap subProviders,
QgsRuleBasedLabelProvider provider 
)

add providers

Note
not available in Python bindings

Definition at line 277 of file qgsrulebasedlabeling.cpp.

bool QgsRuleBasedLabeling::Rule::dependsOnScale ( ) const
inline

Determines if scale based labeling is active.

Returns
True if scale based labeling is active

Definition at line 82 of file qgsrulebasedlabeling.h.

QgsRuleBasedLabeling::RuleList QgsRuleBasedLabeling::Rule::descendants ( ) const

Returns all children, grand-children, grand-grand-children, grand-gra...

you get it

Returns
A list of descendant rules

Definition at line 83 of file qgsrulebasedlabeling.cpp.

QString QgsRuleBasedLabeling::Rule::description ( ) const
inline

A human readable description for this rule.

Returns
Description

Definition at line 115 of file qgsrulebasedlabeling.h.

QString QgsRuleBasedLabeling::Rule::filterExpression ( ) const
inline

A filter that will check if this rule applies.

Returns
An expression

Definition at line 108 of file qgsrulebasedlabeling.h.

const QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::Rule::findRuleByKey ( const QString &  key) const

Try to find a rule given its unique key.

Definition at line 168 of file qgsrulebasedlabeling.cpp.

QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::Rule::findRuleByKey ( const QString &  key)

Find a labeling rule thanks to its key.

Parameters
keyThe key of the rule to find
Returns
The rule or a nullptr if not found
Since
QGIS 3.0

Definition at line 184 of file qgsrulebasedlabeling.cpp.

void QgsRuleBasedLabeling::Rule::insertChild ( int  i,
QgsRuleBasedLabeling::Rule rule 
)

add child rule, take ownership, sets this as parent

Definition at line 154 of file qgsrulebasedlabeling.cpp.

bool QgsRuleBasedLabeling::Rule::isElse ( ) const
inline

Check if this rule is an ELSE rule.

Returns
True if this rule is an else rule

Definition at line 129 of file qgsrulebasedlabeling.h.

double QgsRuleBasedLabeling::Rule::maximumScale ( ) const
inline

Returns the maximum map scale (i.e.

most "zoomed in" scale) at which the label rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.

See also
minimumScale()
setMaximumScale()
Since
QGIS 3.0

Definition at line 92 of file qgsrulebasedlabeling.h.

double QgsRuleBasedLabeling::Rule::minimumScale ( ) const
inline

Returns the minimum map scale (i.e.

most "zoomed out" scale) at which the label rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.

See also
maximumScale()
setMinimumScale()
Since
QGIS 3.0

Definition at line 102 of file qgsrulebasedlabeling.h.

Rule& QgsRuleBasedLabeling::Rule::operator= ( const Rule rh)
delete

Rules cannot be copied.

const QgsRuleBasedLabeling::Rule* QgsRuleBasedLabeling::Rule::parent ( ) const
inline

The parent rule.

Returns
Parent rule

Definition at line 213 of file qgsrulebasedlabeling.h.

QgsRuleBasedLabeling::Rule* QgsRuleBasedLabeling::Rule::parent ( )
inline

The parent rule.

Returns
Parent rule

Definition at line 220 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::prepare ( const QgsRenderContext context,
QSet< QString > &  attributeNames,
QgsRuleBasedLabeling::RuleToProviderMap subProviders 
)

call prepare() on sub-providers and populate attributeNames

Note
not available in Python bindings

Definition at line 294 of file qgsrulebasedlabeling.cpp.

QgsRuleBasedLabeling::Rule::RegisterResult QgsRuleBasedLabeling::Rule::registerFeature ( QgsFeature feature,
QgsRenderContext context,
QgsRuleBasedLabeling::RuleToProviderMap subProviders,
const QgsGeometry obstacleGeometry = QgsGeometry() 
)

register individual features

Note
not available in Python bindings

Definition at line 319 of file qgsrulebasedlabeling.cpp.

void QgsRuleBasedLabeling::Rule::removeChildAt ( int  i)

delete child rule

Definition at line 161 of file qgsrulebasedlabeling.cpp.

bool QgsRuleBasedLabeling::Rule::requiresAdvancedEffects ( ) const

Returns true if this rule or any of its children requires advanced composition effects to render.

Definition at line 121 of file qgsrulebasedlabeling.cpp.

QString QgsRuleBasedLabeling::Rule::ruleKey ( ) const
inline

Unique rule identifier (for identification of rule within labeling, used as provider ID)

Definition at line 132 of file qgsrulebasedlabeling.h.

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

store labeling info to XML element

Definition at line 249 of file qgsrulebasedlabeling.cpp.

void QgsRuleBasedLabeling::Rule::setActive ( bool  state)
inline

Sets if this rule is active.

Parameters
stateDetermines if the rule should be activated or deactivated

Definition at line 173 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::setDescription ( const QString &  description)
inline

Set a human readable description for this rule.

Parameters
descriptionDescription

Definition at line 167 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::setFilterExpression ( const QString &  filterExp)
inline

Set the expression used to check if a given feature shall be rendered with this rule.

Parameters
filterExpAn expression

Definition at line 160 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::setIsElse ( bool  iselse)
inline

Sets if this rule is an ELSE rule.

Parameters
iselseIf true, this rule is an ELSE rule

Definition at line 180 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::setMaximumScale ( double  scale)
inline

Sets the maximum map scale (i.e.

most "zoomed in" scale) at which the rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no maximum scale visibility.

See also
maximumScale()
setMinimumScale()

Definition at line 153 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::setMinimumScale ( double  scale)
inline

Sets the minimum map scale (i.e.

most "zoomed out" scale) at which the label rule will be active. The scale value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. A scale of 0 indicates no minimum scale visibility.

See also
minimumScale()
setMaximumScale()

Definition at line 144 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::setRuleKey ( const QString &  key)
inline

Override the assigned rule key (should be used just internally by rule-based labeling)

Definition at line 183 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::setSettings ( QgsPalLayerSettings settings)

Sets new settings (or NULL). Deletes old settings if any.

Definition at line 75 of file qgsrulebasedlabeling.cpp.

QgsPalLayerSettings* QgsRuleBasedLabeling::Rule::settings ( ) const
inline

Gets the labeling settings.

May return a null pointer.

Definition at line 75 of file qgsrulebasedlabeling.h.

void QgsRuleBasedLabeling::Rule::subProviderIds ( QStringList &  list) const

append rule keys of descendants that contain valid settings (i.e.

they will be sub-providers)

Note
not available in Python bindings

Definition at line 135 of file qgsrulebasedlabeling.cpp.


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