Class: QgsRuleBasedLabeling¶
-
class
qgis.core.
QgsRuleBasedLabeling
(root: QgsRuleBasedLabeling.Rule)¶ Bases:
QgsAbstractVectorLayerLabeling
Constructs the labeling from given tree of rules (takes ownership)
New in version 3.0.
- Parameters
root –
-
class
Rule
(settings: QgsPalLayerSettings, maximumScale: float = 0, minimumScale: float = 0, filterExp: str = '', description: str = '', elseRule: bool = False)¶ Bases:
sip.wrapper
takes ownership of settings, settings may be
None
New in version 3.0.
- Parameters
settings (QgsPalLayerSettings) –
maximumScale (float = 0) –
minimumScale (float = 0) –
filterExp (str = '') –
description (str = '') –
elseRule (bool = False) –
-
Filtered
= 0¶
-
Inactive
= 1¶
-
class
RegisterResult
¶ Bases:
int
-
Registered
= 2¶
-
accept
(self, visitor: QgsStyleEntityVisitorInterface) → bool¶ 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, orFalse
if visiting should be canceled.New in version 3.10.
- Parameters
visitor (QgsStyleEntityVisitorInterface) –
- Return type
bool
-
active
(self) → bool¶ Returns if this rule is active
- Return type
bool
- Returns
True
if the rule is active
-
appendChild
(self, rule: QgsRuleBasedLabeling.Rule)¶ add child rule, take ownership, sets this as parent
- Parameters
rule (QgsRuleBasedLabeling.Rule) –
-
children
(self) → List[QgsRuleBasedLabeling.Rule]¶ Returns all children rules of this rule
- Return type
- Returns
A list of rules
-
clone
(self) → QgsRuleBasedLabeling.Rule¶ clone this rule, return new instance
- Return type
-
create
(ruleElem: QDomElement, context: QgsReadWriteContext) → QgsRuleBasedLabeling.Rule¶ Create a rule from an XML definition
- Parameters
ruleElem (QDomElement) – The XML rule element
context (QgsReadWriteContext) – reading context
- Return type
- Returns
A new rule
-
dependsOnScale
(self) → bool¶ Determines if scale based labeling is active
- Return type
bool
- Returns
True
if scale based labeling is active
-
descendants
(self) → List[QgsRuleBasedLabeling.Rule]¶ Returns all children, grand-children, grand-grand-children, grand-gra… you get it
- Return type
- Returns
A list of descendant rules
-
description
(self) → str¶ A human readable description for this rule
- Return type
str
- Returns
Description
-
filterExpression
(self) → str¶ A filter that will check if this rule applies
- Return type
str
- Returns
An expression
-
findRuleByKey
(self, key: str) → QgsRuleBasedLabeling.Rule¶ Try to find a rule given its unique key
- Parameters
key (str) –
- Return type
-
insertChild
(self, i: int, rule: QgsRuleBasedLabeling.Rule)¶ add child rule, take ownership, sets this as parent
- Parameters
i (int) –
rule (QgsRuleBasedLabeling.Rule) –
-
isElse
(self) → bool¶ Check if this rule is an ELSE rule
- Return type
bool
- Returns
True
if this rule is an else rule
-
maximumScale
(self) → float¶ 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
See also
New in version 3.0.
- Return type
float
-
minimumScale
(self) → float¶ 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
See also
New in version 3.0.
- Return type
float
-
parent
(self) → QgsRuleBasedLabeling.Rule¶ The parent rule
- Return type
- Returns
Parent rule
-
removeChildAt
(self, i: int)¶ delete child rule
- Parameters
i (int) –
-
requiresAdvancedEffects
(self) → bool¶ Returns
True
if this rule or any of its children requires advanced composition effects to render.- Return type
bool
-
ruleKey
(self) → str¶ Unique rule identifier (for identification of rule within labeling, used as provider ID)
- Return type
str
-
save
(self, doc: QDomDocument, context: QgsReadWriteContext) → QDomElement¶ store labeling info to XML element
- Parameters
doc (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
QDomElement
-
setActive
(self, state: bool)¶ Sets if this rule is active
- Parameters
state (bool) – Determines if the rule should be activated or deactivated
-
setDescription
(self, description: str)¶ Set a human readable description for this rule
- Parameters
description (str) – Description
-
setFilterExpression
(self, filterExp: str)¶ Set the expression used to check if a given feature shall be rendered with this rule
- Parameters
filterExp (str) – An expression
-
setIsElse
(self, iselse: bool)¶ Sets if this rule is an ELSE rule
- Parameters
iselse (bool) – If
True
, this rule is an ELSE rule
-
setMaximumScale
(self, scale: float)¶ Sets the maximum map
scale
(i.e. most “zoomed in” scale) at which the rule will be active. Thescale
value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Ascale
of 0 indicates no maximum scale visibility.See also
See also
- Parameters
scale (float) –
-
setMinimumScale
(self, scale: float)¶ Sets the minimum map
scale
(i.e. most “zoomed out” scale) at which the label rule will be active. Thescale
value indicates the scale denominator, e.g. 1000.0 for a 1:1000 map. Ascale
of 0 indicates no minimum scale visibility.See also
See also
- Parameters
scale (float) –
-
setRuleKey
(self, key: str)¶ Override the assigned rule key (should be used just internally by rule-based labeling)
- Parameters
key (str) –
-
setSettings
(self, settings: QgsPalLayerSettings)¶ Sets new settings (or
None
). Deletes old settings if any.- Parameters
settings (QgsPalLayerSettings) –
-
settings
(self) → QgsPalLayerSettings¶ Returns the labeling settings. May return
None
.- Return type
-
accept
(self, visitor: QgsStyleEntityVisitorInterface) → bool¶ - Parameters
visitor (QgsStyleEntityVisitorInterface) –
- Return type
bool
-
clone
(self) → QgsRuleBasedLabeling¶ - Return type
-
create
(element: QDomElement, context: QgsReadWriteContext) → QgsRuleBasedLabeling¶ Create the instance from a DOM element with saved configuration
- Parameters
element (QDomElement) –
context (QgsReadWriteContext) –
- Return type
-
requiresAdvancedEffects
(self) → bool¶ - Return type
bool
-
rootRule
(self) → QgsRuleBasedLabeling.Rule¶ - Return type
-
save
(self, doc: QDomDocument, context: QgsReadWriteContext) → QDomElement¶ - Parameters
doc (QDomDocument) –
context (QgsReadWriteContext) –
- Return type
QDomElement
-
setSettings
(self, settings: QgsPalLayerSettings, providerId: str = '')¶ Set pal settings for a specific provider (takes ownership).
- Parameters
settings (QgsPalLayerSettings) – Pal layer settings
providerId (str = '') – The id of the provider
New in version 3.0.
-
settings
(self, providerId: str = '') → QgsPalLayerSettings¶ - Parameters
providerId (str = '') –
- Return type
-
subProviders
(self) → List[str]¶ - Return type
List[str]
-
toSld
(self, parent: QDomNode, props: Dict[str, str])¶ - Parameters
parent (QDomNode) –
props (Dict[str) –
-
type
(self) → str¶ - Return type
str
-
writeTextSymbolizer
(self, parent: QDomNode, settings: QgsPalLayerSettings, props: Dict[str, str])¶ Writes a TextSymbolizer element contents based on the provided labeling settings
- Parameters
parent – the node that will have the text symbolizer element added to it
settings – the settings getting translated to a TextSymbolizer
props – a open ended set of properties that can drive/inform the SLD encoding