QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 
26 QgsVectorLayerLabelProvider *QgsRuleBasedLabelProvider::createProvider( QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings )
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  {
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  {
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  return Filtered;
354  }
355 
356  bool registered = false;
357 
358  // do we have active subprovider for the rule?
359  if ( subProviders.contains( this ) && mIsActive )
360  {
361  subProviders[this]->registerFeature( feature, context, obstacleGeometry, symbol );
362  registered = true;
363  }
364 
365  bool willRegisterSomething = false;
366 
367  // call recursively
368  for ( Rule *rule : qgis::as_const( mChildren ) )
369  {
370  // Don't process else rules yet
371  if ( !rule->isElse() )
372  {
373  RegisterResult res = rule->registerFeature( feature, context, subProviders, obstacleGeometry );
374  // consider inactive items as "registered" so the else rule will ignore them
375  willRegisterSomething |= ( res == Registered || res == Inactive );
376  registered |= willRegisterSomething;
377  }
378  }
379 
380  // If none of the rules passed then we jump into the else rules and process them.
381  if ( !willRegisterSomething )
382  {
383  for ( Rule *rule : qgis::as_const( mElseRules ) )
384  {
385  registered |= rule->registerFeature( feature, context, subProviders, obstacleGeometry, symbol ) != Filtered;
386  }
387  }
388 
389  if ( !mIsActive )
390  return Inactive;
391  else if ( registered )
392  return Registered;
393  else
394  return Filtered;
395 }
396 
397 bool QgsRuleBasedLabeling::Rule::isFilterOK( const QgsFeature &f, QgsRenderContext &context ) const
398 {
399  if ( ! mFilter || mElseRule )
400  return true;
401 
402  context.expressionContext().setFeature( f );
403  QVariant res = mFilter->evaluate( &context.expressionContext() );
404  return res.toBool();
405 }
406 
407 bool QgsRuleBasedLabeling::Rule::isScaleOK( double scale ) const
408 {
409  if ( qgsDoubleNear( scale, 0.0 ) ) // so that we can count features in classes without scale context
410  return true;
411  if ( qgsDoubleNear( mMaximumScale, 0.0 ) && qgsDoubleNear( mMinimumScale, 0.0 ) )
412  return true;
413  if ( !qgsDoubleNear( mMaximumScale, 0.0 ) && mMaximumScale > scale )
414  return false;
415  if ( !qgsDoubleNear( mMinimumScale, 0.0 ) && mMinimumScale < scale )
416  return false;
417  return true;
418 }
419 
421 
423  : mRootRule( root )
424 {
425 }
426 
428 {
429  Rule *rootRule = mRootRule->clone();
430 
431  // normally with clone() the individual rules get new keys (UUID), but here we want to keep
432  // the tree of rules intact, so that other components that may use the rule keys work nicely (e.g. map themes)
433  rootRule->setRuleKey( mRootRule->ruleKey() );
434  RuleList origDescendants = mRootRule->descendants();
435  RuleList clonedDescendants = rootRule->descendants();
436  Q_ASSERT( origDescendants.count() == clonedDescendants.count() );
437  for ( int i = 0; i < origDescendants.count(); ++i )
438  clonedDescendants[i]->setRuleKey( origDescendants[i]->ruleKey() );
439 
440  return new QgsRuleBasedLabeling( rootRule );
441 }
442 
444 {
445 }
446 
448 {
449  return mRootRule.get();
450 }
451 
453 {
454  return mRootRule.get();
455 }
456 
457 
458 QgsRuleBasedLabeling *QgsRuleBasedLabeling::create( const QDomElement &element, const QgsReadWriteContext &context )
459 {
460  QDomElement rulesElem = element.firstChildElement( QStringLiteral( "rules" ) );
461 
462  Rule *root = Rule::create( rulesElem, context );
463  if ( !root )
464  return nullptr;
465 
466  QgsRuleBasedLabeling *rl = new QgsRuleBasedLabeling( root );
467  return rl;
468 }
469 
471 {
472  return QStringLiteral( "rule-based" );
473 }
474 
475 QDomElement QgsRuleBasedLabeling::save( QDomDocument &doc, const QgsReadWriteContext &context ) const
476 {
477  QDomElement elem = doc.createElement( QStringLiteral( "labeling" ) );
478  elem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "rule-based" ) );
479 
480  QDomElement rulesElem = mRootRule->save( doc, context );
481  rulesElem.setTagName( QStringLiteral( "rules" ) ); // instead of just "rule"
482  elem.appendChild( rulesElem );
483 
484  return elem;
485 }
486 
488 {
489  return new QgsRuleBasedLabelProvider( *this, layer, false );
490 }
491 
493 {
494  QStringList lst;
495  mRootRule->subProviderIds( lst );
496  return lst;
497 }
498 
499 QgsPalLayerSettings QgsRuleBasedLabeling::settings( const QString &providerId ) const
500 {
501  const Rule *rule = mRootRule->findRuleByKey( providerId );
502  if ( rule && rule->settings() )
503  return *rule->settings();
504 
505  return QgsPalLayerSettings();
506 }
507 
509 {
510  return mRootRule->accept( visitor );
511 }
512 
514 {
515  return mRootRule->requiresAdvancedEffects();
516 }
517 
518 void QgsRuleBasedLabeling::setSettings( QgsPalLayerSettings *settings, const QString &providerId )
519 {
520  if ( settings )
521  {
522  Rule *rule = mRootRule->findRuleByKey( providerId );
523  if ( rule && rule->settings() )
524  rule->setSettings( settings );
525  }
526 }
527 
528 void QgsRuleBasedLabeling::toSld( QDomNode &parent, const QVariantMap &props ) const
529 {
530  if ( !mRootRule )
531  {
532  return;
533  }
534 
535  const QgsRuleBasedLabeling::RuleList rules = mRootRule->children();
536  for ( Rule *rule : rules )
537  {
538  QgsPalLayerSettings *settings = rule->settings();
539 
540  if ( settings && settings->drawLabels )
541  {
542  QDomDocument doc = parent.ownerDocument();
543 
544  QDomElement ruleElement = doc.createElement( QStringLiteral( "se:Rule" ) );
545  parent.appendChild( ruleElement );
546 
547  if ( !rule->filterExpression().isEmpty() )
548  {
549  QgsSymbolLayerUtils::createFunctionElement( doc, ruleElement, rule->filterExpression() );
550  }
551 
552  // scale dependencies, the actual behavior is that the PAL settings min/max and
553  // the rule min/max get intersected
554  QVariantMap localProps = QVariantMap( props );
555  QgsSymbolLayerUtils::mergeScaleDependencies( rule->maximumScale(), rule->minimumScale(), localProps );
556  if ( settings->scaleVisibility )
557  {
559  }
560  QgsSymbolLayerUtils::applyScaleDependency( doc, ruleElement, localProps );
561 
563  }
564 
565  }
566 
567 }
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
const QgsLabelingEngine * mEngine
Associated labeling engine.
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e....
virtual void writeTextSymbolizer(QDomNode &parent, QgsPalLayerSettings &settings, const QVariantMap &props) const
Writes a TextSymbolizer element contents based on the provided labeling settings.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
Contains settings for how a map layer will be labeled.
bool drawLabels
Whether to draw labels for this layer.
double minimumScale
The minimum map scale (i.e.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Read settings from a DOM element.
bool scaleVisibility
Set to true to limit label visibility to a range of scales.
double maximumScale
The maximum map scale (i.e.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
Label provider for rule based labeling.
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.
bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames) override
Prepare for registration of features.
std::unique_ptr< QgsRuleBasedLabeling > mRules
owned copy
QgsRuleBasedLabelProvider(const QgsRuleBasedLabeling &rules, QgsVectorLayer *layer, bool withFeatureLoop=true)
QgsRuleBasedLabeling::RuleToProviderMap mSubProviders
label providers are owned by labeling engine
virtual QgsVectorLayerLabelProvider * createProvider(QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings)
create a label provider
QList< QgsAbstractLabelProvider * > subProviders() override
Returns subproviders.
A child rule for QgsRuleBasedLabeling.
void setRuleKey(const QString &key)
Override the assigned rule key (should be used just internally by rule-based labeling)
QgsRuleBasedLabeling::Rule * clone() const
clone this rule, return new instance
RegisterResult registerFeature(const QgsFeature &feature, QgsRenderContext &context, RuleToProviderMap &subProviders, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
register individual features
void prepare(QgsRenderContext &context, QSet< QString > &attributeNames, RuleToProviderMap &subProviders)
call prepare() on sub-providers and populate attributeNames
QgsPalLayerSettings * settings() const
Returns the labeling settings.
RegisterResult
The result of registering a rule.
bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all child rules associated with the rule...
static QgsRuleBasedLabeling::Rule * create(const QDomElement &ruleElem, const QgsReadWriteContext &context)
Create a rule from an XML definition.
void subProviderIds(QStringList &list) const
append rule keys of descendants that contain valid settings (i.e.
bool requiresAdvancedEffects() const
Returns true if this rule or any of its children requires advanced composition effects to render.
void removeChildAt(int i)
delete child rule
void setActive(bool state)
Sets if this rule is active.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const
store labeling info to XML element
void setSettings(QgsPalLayerSettings *settings)
Sets new settings (or nullptr). Deletes old settings if any.
QgsRuleBasedLabeling::RuleList descendants() const
Returns all children, grand-children, grand-grand-children, grand-gra...
void createSubProviders(QgsVectorLayer *layer, RuleToProviderMap &subProviders, QgsRuleBasedLabelProvider *provider)
add providers
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
void insertChild(int i, QgsRuleBasedLabeling::Rule *rule)
add child rule, take ownership, sets this as parent
const QgsRuleBasedLabeling::Rule * findRuleByKey(const QString &key) const
Try to find a rule given its unique key.
void appendChild(QgsRuleBasedLabeling::Rule *rule)
add child rule, take ownership, sets this as parent
Rule based labeling for a vector layer.
QList< QgsRuleBasedLabeling::Rule * > RuleList
std::unique_ptr< Rule > mRootRule
void toSld(QDomNode &parent, const QVariantMap &props) const override
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
QStringList subProviders() const override
Gets list of sub-providers within the layer's labeling.
QgsRuleBasedLabeling(QgsRuleBasedLabeling::Rule *root)
Constructs the labeling from given tree of rules (takes ownership)
QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const override
static QgsRuleBasedLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Create the instance from a DOM element with saved configuration.
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.
QMap< QgsRuleBasedLabeling::Rule *, QgsVectorLayerLabelProvider * > RuleToProviderMap
QString type() const override
Unique type string of the labeling configuration implementation.
QgsRuleBasedLabeling * clone() const override
Returns a new copy of the object.
QgsRuleBasedLabeling::Rule * rootRule()
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Returns labeling configuration as XML element.
bool requiresAdvancedEffects() const override
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
An interface for classes which can visit style entity (e.g.
@ SymbolRule
Rule based symbology or label child rule.
virtual bool visitExit(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor stops visiting a node.
virtual bool visitEnter(const QgsStyleEntityVisitorInterface::Node &node)
Called when the visitor starts visiting a node.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
A label settings entity for QgsStyle databases.
Definition: qgsstyle.h:1294
static void applyScaleDependency(QDomDocument &doc, QDomElement &ruleElem, QVariantMap &props)
Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into t...
static bool createFunctionElement(QDomDocument &doc, QDomElement &element, const QString &function)
static void mergeScaleDependencies(double mScaleMinDenom, double mScaleMaxDenom, QVariantMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:65
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
virtual bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
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.
const QgsPalLayerSettings & settings() const
Returns the layer's settings.
Represents a vector layer which manages a vector based data sets.
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
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:316
Contains information relating to a node (i.e.
Contains information relating to the style entity currently being visited.