QGIS API Documentation 3.41.0-Master (64d82d4c163)
|
A child rule for QgsRuleBasedLabeling. More...
#include <qgsrulebasedlabeling.h>
Public Types | |
enum | RegisterResult { Filtered = 0 , Inactive , Registered } |
The result of registering a rule. More... | |
Public Member Functions | |
Rule (const Rule &rh)=delete | |
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 | |
~Rule () | |
bool | accept (QgsStyleEntityVisitorInterface *visitor) const |
Accepts the specified symbology visitor, causing it to visit all child rules associated with the rule. | |
bool | active () const |
Returns if this rule is active. | |
void | appendChild (QgsRuleBasedLabeling::Rule *rule) |
add child rule, take ownership, sets this as parent | |
QgsRuleBasedLabeling::RuleList & | children () |
Returns all children rules of this rule. | |
const QgsRuleBasedLabeling::RuleList & | children () const |
Returns all children rules of this rule. | |
QgsRuleBasedLabeling::Rule * | clone (bool resetRuleKey=true) const |
clone this rule | |
void | createSubProviders (QgsVectorLayer *layer, RuleToProviderVec &subProviders, QgsRuleBasedLabelProvider *provider) |
add providers | |
bool | dependsOnScale () const |
Determines if scale based labeling is active. | |
QgsRuleBasedLabeling::RuleList | descendants () const |
Returns all children, grand-children, grand-grand-children, grand-gra... you get it. | |
QString | description () const |
A human readable description for this rule. | |
QString | filterExpression () const |
A filter that will check if this rule applies. | |
QgsRuleBasedLabeling::Rule * | findRuleByKey (const QString &key) |
Find a labeling rule thanks to its key. | |
const QgsRuleBasedLabeling::Rule * | findRuleByKey (const QString &key) const |
Try to find a rule given its unique key. | |
void | insertChild (int i, QgsRuleBasedLabeling::Rule *rule) |
add child rule, take ownership, sets this as parent | |
bool | isElse () const |
Check if this rule is an ELSE rule. | |
double | maximumScale () const |
Returns the maximum map scale (i.e. | |
double | minimumScale () const |
Returns the minimum map scale (i.e. | |
Rule & | operator= (const Rule &rh)=delete |
QgsRuleBasedLabeling::Rule * | parent () |
The parent rule. | |
const QgsRuleBasedLabeling::Rule * | parent () const |
The parent rule. | |
void | prepare (QgsRenderContext &context, QSet< QString > &attributeNames, RuleToProviderVec &subProviders) |
call prepare() on sub-providers and populate attributeNames | |
std::tuple< RegisterResult, QList< QgsLabelFeature * > > | registerFeature (const QgsFeature &feature, QgsRenderContext &context, RuleToProviderVec &subProviders, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr) |
Register individual features. | |
void | removeChildAt (int i) |
delete child rule | |
bool | requiresAdvancedEffects () const |
Returns true if this rule or any of its children requires advanced composition effects to render. | |
QString | ruleKey () const |
Unique rule identifier (for identification of rule within labeling, used as provider ID) | |
QDomElement | save (QDomDocument &doc, const QgsReadWriteContext &context) const |
store labeling info to XML element | |
void | setActive (bool state) |
Sets if this rule is active. | |
void | setDescription (const QString &description) |
Set a human readable description for this rule. | |
void | setFilterExpression (const QString &filterExp) |
Set the expression used to check if a given feature shall be rendered with this rule. | |
void | setIsElse (bool iselse) |
Sets if this rule is an ELSE rule. | |
void | setMaximumScale (double scale) |
Sets the maximum map scale (i.e. | |
void | setMinimumScale (double scale) |
Sets the minimum map scale (i.e. | |
void | setRuleKey (const QString &key) |
Override the assigned rule key (should be used just internally by rule-based labeling) | |
void | setSettings (QgsPalLayerSettings *settings) |
Sets new settings (or nullptr ). Deletes old settings if any. | |
QgsPalLayerSettings * | settings () const |
Returns the labeling settings. | |
void | subProviderIds (QStringList &list) const |
append rule keys of descendants that contain valid settings (i.e. | |
Static Public Member Functions | |
static QgsRuleBasedLabeling::Rule * | create (const QDomElement &ruleElem, const QgsReadWriteContext &context, bool reuseId=true) |
Create a rule from an XML definition. | |
A child rule for QgsRuleBasedLabeling.
Definition at line 56 of file qgsrulebasedlabeling.h.
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 67 of file qgsrulebasedlabeling.h.
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 63 of file qgsrulebasedlabeling.cpp.
QgsRuleBasedLabeling::Rule::~Rule | ( | ) |
Definition at line 77 of file qgsrulebasedlabeling.cpp.
|
delete |
bool QgsRuleBasedLabeling::Rule::accept | ( | QgsStyleEntityVisitorInterface * | visitor | ) | const |
Accepts the specified symbology visitor, causing it to visit all child rules associated with the rule.
Returns true
if the visitor should continue visiting other objects, or false
if visiting should be canceled.
Definition at line 145 of file qgsrulebasedlabeling.cpp.
|
inline |
Returns if this rule is active.
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 185 of file qgsrulebasedlabeling.cpp.
|
inline |
Returns all children rules of this rule.
Definition at line 199 of file qgsrulebasedlabeling.h.
|
inline |
Returns all children rules of this rule.
Definition at line 192 of file qgsrulebasedlabeling.h.
QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::Rule::clone | ( | bool | resetRuleKey = true | ) | const |
clone this rule
resetRuleKey | true if this rule and its children rule key need to be reset to new unique ones. |
Definition at line 236 of file qgsrulebasedlabeling.cpp.
|
static |
Create a rule from an XML definition.
ruleElem | The XML rule element |
context | reading context |
reuseId | set to true to create an exact copy of the original symbol or false to create a new rule with the same parameters as the original but a new unique ruleKey(). (Since QGIS 3.30) |
Definition at line 251 of file qgsrulebasedlabeling.cpp.
void QgsRuleBasedLabeling::Rule::createSubProviders | ( | QgsVectorLayer * | layer, |
QgsRuleBasedLabeling::RuleToProviderVec & | subProviders, | ||
QgsRuleBasedLabelProvider * | provider | ||
) |
add providers
Definition at line 323 of file qgsrulebasedlabeling.cpp.
|
inline |
Determines if scale based labeling is active.
true
if scale based labeling is active Definition at line 84 of file qgsrulebasedlabeling.h.
QgsRuleBasedLabeling::RuleList QgsRuleBasedLabeling::Rule::descendants | ( | ) | const |
Returns all children, grand-children, grand-grand-children, grand-gra... you get it.
Definition at line 91 of file qgsrulebasedlabeling.cpp.
|
inline |
A human readable description for this rule.
Definition at line 115 of file qgsrulebasedlabeling.h.
|
inline |
A filter that will check if this rule applies.
Definition at line 108 of file qgsrulebasedlabeling.h.
QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::Rule::findRuleByKey | ( | const QString & | key | ) |
Find a labeling rule thanks to its key.
key | The key of the rule to find |
nullptr
if not found Definition at line 222 of file qgsrulebasedlabeling.cpp.
const QgsRuleBasedLabeling::Rule * QgsRuleBasedLabeling::Rule::findRuleByKey | ( | const QString & | key | ) | const |
Try to find a rule given its unique key.
Definition at line 206 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 192 of file qgsrulebasedlabeling.cpp.
|
inline |
Check if this rule is an ELSE rule.
true
if this rule is an else rule Definition at line 129 of file qgsrulebasedlabeling.h.
|
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.
Definition at line 93 of file qgsrulebasedlabeling.h.
|
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.
Definition at line 102 of file qgsrulebasedlabeling.h.
|
inline |
|
inline |
void QgsRuleBasedLabeling::Rule::prepare | ( | QgsRenderContext & | context, |
QSet< QString > & | attributeNames, | ||
QgsRuleBasedLabeling::RuleToProviderVec & | subProviders | ||
) |
call prepare() on sub-providers and populate attributeNames
Definition at line 351 of file qgsrulebasedlabeling.cpp.
std::tuple< QgsRuleBasedLabeling::Rule::RegisterResult, QList< QgsLabelFeature * > > QgsRuleBasedLabeling::Rule::registerFeature | ( | const QgsFeature & | feature, |
QgsRenderContext & | context, | ||
QgsRuleBasedLabeling::RuleToProviderVec & | subProviders, | ||
const QgsGeometry & | obstacleGeometry = QgsGeometry() , |
||
const QgsSymbol * | symbol = nullptr |
||
) |
Register individual features.
Returns result of registration, together with a list of all label features which were created as a result of registering feature. Ownership of these label features is not transferred (it has already been assigned to the label provider).
Definition at line 385 of file qgsrulebasedlabeling.cpp.
void QgsRuleBasedLabeling::Rule::removeChildAt | ( | int | i | ) |
delete child rule
Definition at line 199 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 131 of file qgsrulebasedlabeling.cpp.
|
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 295 of file qgsrulebasedlabeling.cpp.
|
inline |
Sets if this rule is active.
state | Determines if the rule should be activated or deactivated |
Definition at line 173 of file qgsrulebasedlabeling.h.
|
inline |
Set a human readable description for this rule.
description | Description |
Definition at line 167 of file qgsrulebasedlabeling.h.
|
inline |
Set the expression used to check if a given feature shall be rendered with this rule.
filterExp | An expression |
Definition at line 160 of file qgsrulebasedlabeling.h.
|
inline |
Sets if this rule is an ELSE rule.
iselse | If true , this rule is an ELSE rule |
Definition at line 180 of file qgsrulebasedlabeling.h.
|
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.
Definition at line 153 of file qgsrulebasedlabeling.h.
|
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.
Definition at line 144 of file qgsrulebasedlabeling.h.
|
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 nullptr
). Deletes old settings if any.
Definition at line 83 of file qgsrulebasedlabeling.cpp.
|
inline |
Returns the labeling settings.
May return nullptr
.
Definition at line 77 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)
Definition at line 173 of file qgsrulebasedlabeling.cpp.