QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsrulebasedlabeling.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrulebasedlabeling.cpp
3  ---------------------
4  begin : September 2015
5  copyright : (C) 2015 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "qgsrulebasedlabeling.h"
16 #include "qgssymbollayerutils.h"
17 #include "qgsstyleentityvisitor.h"
18 
20  : QgsVectorLayerLabelProvider( layer, QString(), withFeatureLoop, nullptr )
21 {
22  mRules.reset( rules.clone() );
23  mRules->rootRule()->createSubProviders( layer, mSubProviders, this );
24 }
25 
27 {
28  return new QgsVectorLayerLabelProvider( layer, providerId, withFeatureLoop, settings );
29 }
30 
31 bool QgsRuleBasedLabelProvider::prepare( QgsRenderContext &context, QSet<QString> &attributeNames )
32 {
33  for ( QgsVectorLayerLabelProvider *provider : qgis::as_const( mSubProviders ) )
34  provider->setEngine( mEngine );
35 
36  // populate sub-providers
37  mRules->rootRule()->prepare( context, attributeNames, mSubProviders );
38  return true;
39 }
40 
41 void QgsRuleBasedLabelProvider::registerFeature( const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry, const QgsSymbol *symbol )
42 {
43  // will register the feature to relevant sub-providers
44  mRules->rootRule()->registerFeature( feature, context, mSubProviders, obstacleGeometry, symbol );
45 }
46 
47 QList<QgsAbstractLabelProvider *> QgsRuleBasedLabelProvider::subProviders()
48 {
49  QList<QgsAbstractLabelProvider *> lst;
50  for ( QgsVectorLayerLabelProvider *subprovider : qgis::as_const( mSubProviders ) )
51  lst << subprovider;
52  return lst;
53 }
54 
55 
57 
58 QgsRuleBasedLabeling::Rule::Rule( QgsPalLayerSettings *settings, double scaleMinDenom, double scaleMaxDenom, const QString &filterExp, const QString &description, bool elseRule )
59  : mSettings( settings )
60  , mMaximumScale( scaleMinDenom )
61  , mMinimumScale( scaleMaxDenom )
62  , mFilterExp( filterExp )
63  , mDescription( description )
64  , mElseRule( elseRule )
65 
66 {
67  initFilter();
68 }
69 
71 {
72  qDeleteAll( mChildren );
73  // do NOT delete parent
74 }
75 
77 {
78  if ( mSettings.get() == settings )
79  return;
80 
81  mSettings.reset( settings );
82 }
83 
85 {
86  RuleList l;
87  for ( Rule *c : mChildren )
88  {
89  l += c;
90  l += c->descendants();
91  }
92  return l;
93 }
94 
95 void QgsRuleBasedLabeling::Rule::initFilter()
96 {
97  if ( mElseRule || mFilterExp.compare( QLatin1String( "ELSE" ), Qt::CaseInsensitive ) == 0 )
98  {
99  mElseRule = true;
100  mFilter.reset( nullptr );
101  }
102  else if ( !mFilterExp.isEmpty() )
103  {
104  mFilter.reset( new QgsExpression( mFilterExp ) );
105  }
106  else
107  {
108  mFilter.reset( nullptr );
109  }
110 }
111 
112 void QgsRuleBasedLabeling::Rule::updateElseRules()
113 {
114  mElseRules.clear();
115  for ( Rule *rule : qgis::as_const( mChildren ) )
116  {
117  if ( rule->isElse() )
118  mElseRules << rule;
119  }
120 }
121 
123 {
124  if ( mSettings && mSettings->format().containsAdvancedEffects() )
125  return true;
126 
127  for ( Rule *rule : qgis::as_const( mChildren ) )
128  {
129  if ( rule->requiresAdvancedEffects() )
130  return true;
131  }
132 
133  return false;
134 }
135 
137 {
138  // NOTE: if visitEnter returns false it means "don't visit the rule", not "abort all further visitations"
139  if ( mParent && !visitor->visitEnter( QgsStyleEntityVisitorInterface::Node( QgsStyleEntityVisitorInterface::NodeType::SymbolRule, mRuleKey, mDescription ) ) )
140  return true;
141 
142  if ( mSettings )
143  {
144  QgsStyleLabelSettingsEntity entity( *mSettings );
145  if ( !visitor->visit( QgsStyleEntityVisitorInterface::StyleLeaf( &entity ) ) )
146  return false;
147  }
148 
149  if ( !mChildren.empty() )
150  {
151  for ( const Rule *rule : mChildren )
152  {
153  if ( !rule->accept( visitor ) )
154  return false;
155  }
156  }
157 
158  if ( mParent && !visitor->visitExit( QgsStyleEntityVisitorInterface::Node( QgsStyleEntityVisitorInterface::NodeType::SymbolRule, mRuleKey, mDescription ) ) )
159  return false;
160 
161  return true;
162 }
163 
164 void QgsRuleBasedLabeling::Rule::subProviderIds( QStringList &list ) const
165 {
166  for ( const Rule *rule : qgis::as_const( mChildren ) )
167  {
168  if ( rule->settings() )
169  list << rule->ruleKey();
170 
171  rule->subProviderIds( list );
172  }
173 }
174 
175 
177 {
178  mChildren.append( rule );
179  rule->mParent = this;
180  updateElseRules();
181 }
182 
184 {
185  mChildren.insert( i, rule );
186  rule->mParent = this;
187  updateElseRules();
188 }
189 
191 {
192  delete mChildren.at( i );
193  mChildren.removeAt( i );
194  updateElseRules();
195 }
196 
198 {
199  // we could use a hash / map for search if this will be slow...
200 
201  if ( key == mRuleKey )
202  return this;
203 
204  for ( Rule *rule : mChildren )
205  {
206  const Rule *r = rule->findRuleByKey( key );
207  if ( r )
208  return r;
209  }
210  return nullptr;
211 }
212 
214 {
215  if ( key == mRuleKey )
216  return this;
217 
218  for ( Rule *rule : qgis::as_const( mChildren ) )
219  {
220  Rule *r = rule->findRuleByKey( key );
221  if ( r )
222  return r;
223  }
224  return nullptr;
225 }
226 
228 {
229  QgsPalLayerSettings *s = mSettings.get() ? new QgsPalLayerSettings( *mSettings ) : nullptr;
230  Rule *newrule = new Rule( s, mMaximumScale, mMinimumScale, mFilterExp, mDescription );
231  newrule->setActive( mIsActive );
232  // clone children
233  for ( Rule *rule : mChildren )
234  newrule->appendChild( rule->clone() );
235  return newrule;
236 }
237 
239 {
240  QgsPalLayerSettings *settings = nullptr;
241  QDomElement settingsElem = ruleElem.firstChildElement( QStringLiteral( "settings" ) );
242  if ( !settingsElem.isNull() )
243  {
244  settings = new QgsPalLayerSettings;
245  settings->readXml( settingsElem, context );
246  }
247 
248  QString filterExp = ruleElem.attribute( QStringLiteral( "filter" ) );
249  QString description = ruleElem.attribute( QStringLiteral( "description" ) );
250  int scaleMinDenom = ruleElem.attribute( QStringLiteral( "scalemindenom" ), QStringLiteral( "0" ) ).toInt();
251  int scaleMaxDenom = ruleElem.attribute( QStringLiteral( "scalemaxdenom" ), QStringLiteral( "0" ) ).toInt();
252  QString ruleKey = ruleElem.attribute( QStringLiteral( "key" ) );
253  Rule *rule = new Rule( settings, scaleMinDenom, scaleMaxDenom, filterExp, description );
254 
255  if ( !ruleKey.isEmpty() )
256  rule->mRuleKey = ruleKey;
257 
258  rule->setActive( ruleElem.attribute( QStringLiteral( "active" ), QStringLiteral( "1" ) ).toInt() );
259 
260  QDomElement childRuleElem = ruleElem.firstChildElement( QStringLiteral( "rule" ) );
261  while ( !childRuleElem.isNull() )
262  {
263  Rule *childRule = create( childRuleElem, context );
264  if ( childRule )
265  {
266  rule->appendChild( childRule );
267  }
268  else
269  {
270  //QgsDebugMsg( QStringLiteral( "failed to init a child rule!" ) );
271  }
272  childRuleElem = childRuleElem.nextSiblingElement( QStringLiteral( "rule" ) );
273  }
274 
275  return rule;
276 }
277 
278 QDomElement QgsRuleBasedLabeling::Rule::save( QDomDocument &doc, const QgsReadWriteContext &context ) const
279 {
280  QDomElement ruleElem = doc.createElement( QStringLiteral( "rule" ) );
281 
282  if ( mSettings )
283  {
284  ruleElem.appendChild( mSettings->writeXml( doc, context ) );
285  }
286  if ( !mFilterExp.isEmpty() )
287  ruleElem.setAttribute( QStringLiteral( "filter" ), mFilterExp );
288  if ( !qgsDoubleNear( mMaximumScale, 0 ) )
289  ruleElem.setAttribute( QStringLiteral( "scalemindenom" ), mMaximumScale );
290  if ( !qgsDoubleNear( mMinimumScale, 0 ) )
291  ruleElem.setAttribute( QStringLiteral( "scalemaxdenom" ), mMinimumScale );
292  if ( !mDescription.isEmpty() )
293  ruleElem.setAttribute( QStringLiteral( "description" ), mDescription );
294  if ( !mIsActive )
295  ruleElem.setAttribute( QStringLiteral( "active" ), 0 );
296  ruleElem.setAttribute( QStringLiteral( "key" ), mRuleKey );
297 
298  for ( RuleList::const_iterator it = mChildren.constBegin(); it != mChildren.constEnd(); ++it )
299  {
300  Rule *rule = *it;
301  ruleElem.appendChild( rule->save( doc, context ) );
302  }
303  return ruleElem;
304 }
305 
307 {
308  if ( mSettings )
309  {
310  // add provider!
311  QgsVectorLayerLabelProvider *p = provider->createProvider( layer, mRuleKey, false, mSettings.get() );
312  delete subProviders.value( this, nullptr );
313  subProviders[this] = p;
314  }
315 
316  // call recursively
317  for ( Rule *rule : qgis::as_const( mChildren ) )
318  {
319  rule->createSubProviders( layer, subProviders, provider );
320  }
321 }
322 
324 {
325  if ( mSettings )
326  {
327  QgsVectorLayerLabelProvider *p = subProviders[this];
328  if ( !p->prepare( context, attributeNames ) )
329  {
330  subProviders.remove( this );
331  delete p;
332  }
333  }
334 
335  if ( mFilter )
336  {
337  attributeNames.unite( mFilter->referencedColumns() );
338  mFilter->prepare( &context.expressionContext() );
339  }
340 
341  // call recursively
342  for ( Rule *rule : qgis::as_const( mChildren ) )
343  {
344  rule->prepare( context, attributeNames, subProviders );
345  }
346 }
347 
349 {
350  if ( !isFilterOK( feature, context )
351  || !isScaleOK( context.rendererScale() ) )
352  {
353  delete symbol;
354  return Filtered;
355  }
356 
357  bool registered = false;
358 
359  // do we have active subprovider for the rule?
360  if ( subProviders.contains( this ) && mIsActive )
361  {
362  subProviders[this]->registerFeature( feature, context, obstacleGeometry, symbol );
363  registered = true;
364  }
365 
366  bool willRegisterSomething = false;
367 
368  // call recursively
369  for ( Rule *rule : qgis::as_const( mChildren ) )
370  {
371  // Don't process else rules yet
372  if ( !rule->isElse() )
373  {
374  RegisterResult res = rule->registerFeature( feature, context, subProviders, obstacleGeometry );
375  // consider inactive items as "registered" so the else rule will ignore them
376  willRegisterSomething |= ( res == Registered || res == Inactive );
377  registered |= willRegisterSomething;
378  }
379  }
380 
381  // If none of the rules passed then we jump into the else rules and process them.
382  if ( !willRegisterSomething )
383  {
384  for ( Rule *rule : qgis::as_const( mElseRules ) )
385  {
386  registered |= rule->registerFeature( feature, context, subProviders, obstacleGeometry, symbol ) != Filtered;
387  }
388  }
389 
390  if ( !mIsActive )
391  return Inactive;
392  else if ( registered )
393  return Registered;
394  else
395  return Filtered;
396 }
397 
398 bool QgsRuleBasedLabeling::Rule::isFilterOK( const QgsFeature &f, QgsRenderContext &context ) const
399 {
400  if ( ! mFilter || mElseRule )
401  return true;
402 
403  context.expressionContext().setFeature( f );
404  QVariant res = mFilter->evaluate( &context.expressionContext() );
405  return res.toBool();
406 }
407 
408 bool QgsRuleBasedLabeling::Rule::isScaleOK( double scale ) const
409 {
410  if ( qgsDoubleNear( scale, 0.0 ) ) // so that we can count features in classes without scale context
411  return true;
412  if ( qgsDoubleNear( mMaximumScale, 0.0 ) && qgsDoubleNear( mMinimumScale, 0.0 ) )
413  return true;
414  if ( !qgsDoubleNear( mMaximumScale, 0.0 ) && mMaximumScale > scale )
415  return false;
416  if ( !qgsDoubleNear( mMinimumScale, 0.0 ) && mMinimumScale < scale )
417  return false;
418  return true;
419 }
420 
422 
424  : mRootRule( root )
425 {
426 }
427 
429 {
430  Rule *rootRule = mRootRule->clone();
431 
432  // normally with clone() the individual rules get new keys (UUID), but here we want to keep
433  // the tree of rules intact, so that other components that may use the rule keys work nicely (e.g. map themes)
434  rootRule->setRuleKey( mRootRule->ruleKey() );
435  RuleList origDescendants = mRootRule->descendants();
436  RuleList clonedDescendants = rootRule->descendants();
437  Q_ASSERT( origDescendants.count() == clonedDescendants.count() );
438  for ( int i = 0; i < origDescendants.count(); ++i )
439  clonedDescendants[i]->setRuleKey( origDescendants[i]->ruleKey() );
440 
441  return new QgsRuleBasedLabeling( rootRule );
442 }
443 
445 {
446 }
447 
449 {
450  return mRootRule.get();
451 }
452 
454 {
455  return mRootRule.get();
456 }
457 
458 
459 QgsRuleBasedLabeling *QgsRuleBasedLabeling::create( const QDomElement &element, const QgsReadWriteContext &context )
460 {
461  QDomElement rulesElem = element.firstChildElement( QStringLiteral( "rules" ) );
462 
463  Rule *root = Rule::create( rulesElem, context );
464  if ( !root )
465  return nullptr;
466 
467  QgsRuleBasedLabeling *rl = new QgsRuleBasedLabeling( root );
468  return rl;
469 }
470 
472 {
473  return QStringLiteral( "rule-based" );
474 }
475 
476 QDomElement QgsRuleBasedLabeling::save( QDomDocument &doc, const QgsReadWriteContext &context ) const
477 {
478  QDomElement elem = doc.createElement( QStringLiteral( "labeling" ) );
479  elem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "rule-based" ) );
480 
481  QDomElement rulesElem = mRootRule->save( doc, context );
482  rulesElem.setTagName( QStringLiteral( "rules" ) ); // instead of just "rule"
483  elem.appendChild( rulesElem );
484 
485  return elem;
486 }
487 
489 {
490  return new QgsRuleBasedLabelProvider( *this, layer, false );
491 }
492 
494 {
495  QStringList lst;
496  mRootRule->subProviderIds( lst );
497  return lst;
498 }
499 
500 QgsPalLayerSettings QgsRuleBasedLabeling::settings( const QString &providerId ) const
501 {
502  const Rule *rule = mRootRule->findRuleByKey( providerId );
503  if ( rule && rule->settings() )
504  return *rule->settings();
505 
506  return QgsPalLayerSettings();
507 }
508 
510 {
511  return mRootRule->accept( visitor );
512 }
513 
515 {
516  return mRootRule->requiresAdvancedEffects();
517 }
518 
520 {
521  if ( settings )
522  {
523  Rule *rule = mRootRule->findRuleByKey( providerId );
524  if ( rule && rule->settings() )
525  rule->setSettings( settings );
526  }
527 }
528 
529 void QgsRuleBasedLabeling::toSld( QDomNode &parent, const QgsStringMap &props ) const
530 {
531  if ( !mRootRule )
532  {
533  return;
534  }
535 
536  const QgsRuleBasedLabeling::RuleList rules = mRootRule->children();
537  for ( Rule *rule : rules )
538  {
539  QgsPalLayerSettings *settings = rule->settings();
540 
541  if ( settings && settings->drawLabels )
542  {
543  QDomDocument doc = parent.ownerDocument();
544 
545  QDomElement ruleElement = doc.createElement( QStringLiteral( "se:Rule" ) );
546  parent.appendChild( ruleElement );
547 
548  if ( !rule->filterExpression().isEmpty() )
549  {
550  QgsSymbolLayerUtils::createFunctionElement( doc, ruleElement, rule->filterExpression() );
551  }
552 
553  // scale dependencies, the actual behavior is that the PAL settings min/max and
554  // the rule min/max get intersected
555  QgsStringMap localProps = QgsStringMap( props );
556  QgsSymbolLayerUtils::mergeScaleDependencies( rule->maximumScale(), rule->minimumScale(), localProps );
557  if ( settings->scaleVisibility )
558  {
559  QgsSymbolLayerUtils::mergeScaleDependencies( settings->maximumScale, settings->minimumScale, localProps );
560  }
561  QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElement, localProps );
562 
563  QgsAbstractVectorLayerLabeling::writeTextSymbolizer( ruleElement, *settings, props );
564  }
565 
566  }
567 
568 }
static void mergeScaleDependencies(double mScaleMinDenom, double mScaleMaxDenom, QgsStringMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
Class for parsing and evaluation of expressions (formerly called "search strings").
The class is used as a container of context for various read/write operations on other objects...
QgsVectorLayerLabelProvider(QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings, const QString &layerName=QString())
Convenience constructor to initialize the provider from given vector layer.
bool requiresAdvancedEffects() const
Returns true if this rule or any of its children requires advanced composition effects to render...
QgsPalLayerSettings * settings() const
Returns the labeling settings.
double rendererScale() const
Returns the renderer map scale.
QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const override
double maximumScale
The maximum map scale (i.e.
void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString()) override
Set pal settings for a specific provider (takes ownership).
QgsRuleBasedLabeling::RuleToProviderMap mSubProviders
label providers are owned by labeling engine
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
void prepare(QgsRenderContext &context, QSet< QString > &attributeNames, RuleToProviderMap &subProviders)
call prepare() on sub-providers and populate attributeNames
bool requiresAdvancedEffects() const override
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Returns labeling configuration as XML element.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const
store labeling info to XML element
virtual bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
const QgsLabelingEngine * mEngine
Associated labeling engine.
static void applyScaleDependency(QDomDocument &doc, QDomElement &ruleElem, QgsStringMap &props)
Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into t...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
void insertChild(int i, QgsRuleBasedLabeling::Rule *rule)
add child rule, take ownership, sets this as parent
RegisterResult
The result of registering a rule.
QgsRuleBasedLabeling::Rule * clone() const
clone this rule, return new instance
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:280
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
QString description() const
A human readable description for this rule.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:122
bool drawLabels
Whether to draw labels for this layer.
QList< QgsAbstractLabelProvider * > subProviders() override
Returns subproviders.
QString ruleKey() const
Unique rule identifier (for identification of rule within labeling, used as provider ID) ...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
QMap< QgsRuleBasedLabeling::Rule *, QgsVectorLayerLabelProvider * > RuleToProviderMap
An interface for classes which can visit style entity (e.g.
void registerFeature(const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr) override
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
QMap< QString, QString > QgsStringMap
Definition: qgis.h:612
QgsRuleBasedLabeling::RuleList descendants() const
Returns all children, grand-children, grand-grand-children, grand-gra...
QList< QgsRuleBasedLabeling::Rule * > RuleList
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
RegisterResult registerFeature(const QgsFeature &feature, QgsRenderContext &context, RuleToProviderMap &subProviders, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
register individual features
static QgsRuleBasedLabeling::Rule * create(const QDomElement &ruleElem, const QgsReadWriteContext &context)
Create a rule from an XML definition.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
QString type() const override
Unique type string of the labeling configuration implementation.
void appendChild(QgsRuleBasedLabeling::Rule *rule)
add child rule, take ownership, sets this as parent
QStringList subProviders() const override
Gets list of sub-providers within the layer&#39;s labeling.
std::unique_ptr< QgsRuleBasedLabeling > mRules
owned copy
virtual bool visitExit(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor stops visiting a node.
std::unique_ptr< Rule > mRootRule
virtual QgsVectorLayerLabelProvider * createProvider(QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings)
create a label provider
void setSettings(QgsPalLayerSettings *settings)
Sets new settings (or nullptr). Deletes old settings if any.
QgsPalLayerSettings mSettings
Layer&#39;s labeling configuration.
const QgsPalLayerSettings & settings() const
Returns the layer&#39;s settings.
Contains information relating to a node (i.e.
QgsRuleBasedLabeling(QgsRuleBasedLabeling::Rule *root)
Constructs the labeling from given tree of rules (takes ownership)
const QgsRuleBasedLabeling::Rule * findRuleByKey(const QString &key) const
Try to find a rule given its unique key.
bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames) override
Prepare for registration of features.
void setActive(bool state)
Sets if this rule is active.
bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all child rules associated with the rule...
QgsExpressionContext & expressionContext()
Gets the expression context.
Rule based symbology or label child rule.
static QgsRuleBasedLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Create the instance from a DOM element with saved configuration.
QgsRuleBasedLabeling * clone() const override
Returns a new copy of the object.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Read settings from a DOM element.
void setRuleKey(const QString &key)
Override the assigned rule key (should be used just internally by rule-based labeling) ...
QgsPalLayerSettings settings(const QString &providerId=QString()) const override
Gets associated label settings.
void subProviderIds(QStringList &list) const
append rule keys of descendants that contain valid settings (i.e.
Contains information about the context of a rendering operation.
bool scaleVisibility
Set to true to limit label visibility to a range of scales.
virtual bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor starts visiting a node.
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
A label settings entity for QgsStyle databases.
Definition: qgsstyle.h:1064
virtual void writeTextSymbolizer(QDomNode &parent, QgsPalLayerSettings &settings, const QgsStringMap &props) const
Writes a TextSymbolizer element contents based on the provided labeling settings. ...
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e...
void toSld(QDomNode &parent, const QgsStringMap &props) const override
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
void removeChildAt(int i)
delete child rule
QgsRuleBasedLabeling::Rule * rootRule()
Represents a vector layer which manages a vector based data sets.
void createSubProviders(QgsVectorLayer *layer, RuleToProviderMap &subProviders, QgsRuleBasedLabelProvider *provider)
add providers
QgsRuleBasedLabelProvider(const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, bool withFeatureLoop=true)
Contains information relating to the style entity currently being visited.
double minimumScale
The minimum map scale (i.e.