QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsrenderer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrenderer.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 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 
16 #include "qgsrenderer.h"
17 #include "qgssymbol.h"
18 #include "qgssymbollayerutils.h"
19 #include "qgsrulebasedrenderer.h"
20 
21 #include "qgssinglesymbolrenderer.h" // for default renderer
22 
23 #include "qgsrendererregistry.h"
24 
25 #include "qgsrendercontext.h"
26 #include "qgsclipper.h"
27 #include "qgsgeometry.h"
28 #include "qgsgeometrycollection.h"
29 #include "qgsfeature.h"
30 #include "qgslogger.h"
31 #include "qgsvectorlayer.h"
32 #include "qgspainteffect.h"
33 #include "qgseffectstack.h"
34 #include "qgspainteffectregistry.h"
35 #include "qgswkbptr.h"
36 #include "qgspoint.h"
37 #include "qgsproperty.h"
38 #include "qgsapplication.h"
39 #include "qgsmarkersymbol.h"
40 #include "qgslinesymbol.h"
41 
42 #include <QDomElement>
43 #include <QDomDocument>
44 #include <QPolygonF>
45 #include <QThread>
46 
47 QPointF QgsFeatureRenderer::_getPoint( QgsRenderContext &context, const QgsPoint &point )
48 {
49  return QgsSymbol::_getPoint( context, point );
50 }
51 
53 {
54  if ( !destRenderer )
55  return;
56 
57  if ( mPaintEffect )
58  destRenderer->setPaintEffect( mPaintEffect->clone() );
59 
60  destRenderer->setForceRasterRender( mForceRaster );
62  destRenderer->mOrderBy = mOrderBy;
63  destRenderer->mOrderByEnabled = mOrderByEnabled;
64  destRenderer->mReferenceScale = mReferenceScale;
65 }
66 
68  : mType( type )
69 {
71  mPaintEffect->setEnabled( false );
72 }
73 
75 {
76  delete mPaintEffect;
77 }
78 
80 {
81  return new QgsSingleSymbolRenderer( QgsSymbol::defaultSymbol( geomType ) );
82 }
83 
85 {
86  return symbolForFeature( feature, context );
87 }
88 
89 QSet< QString > QgsFeatureRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
90 {
91  Q_UNUSED( feature )
92  Q_UNUSED( context )
93  return QSet< QString >();
94 }
95 
97 {
98 #ifdef QGISDEBUG
99  if ( !mThread )
100  {
101  mThread = QThread::currentThread();
102  }
103  else
104  {
105  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
106  }
107 #endif
108 }
109 
111 {
112 #ifdef QGISDEBUG
113  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::stopRender", "stopRender called in a different thread - use a cloned renderer instead" );
114 #endif
115 }
116 
118 {
119  return false;
120 }
121 
123 {
124  return false;
125 }
126 
127 bool QgsFeatureRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
128 {
129 #ifdef QGISDEBUG
130  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::renderFeature", "renderFeature called in a different thread - use a cloned renderer instead" );
131 #endif
132 
133  QgsSymbol *symbol = symbolForFeature( feature, context );
134  if ( !symbol )
135  return false;
136 
137  renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
138  return true;
139 }
140 
141 void QgsFeatureRenderer::renderFeatureWithSymbol( const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
142 {
143  symbol->renderFeature( feature, context, layer, selected, drawVertexMarker, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
144 }
145 
147 {
148  return QStringLiteral( "UNKNOWN RENDERER\n" );
149 }
150 
152 {
153  Q_UNUSED( context )
154  return QgsSymbolList();
155 }
156 
157 QgsFeatureRenderer *QgsFeatureRenderer::load( QDomElement &element, const QgsReadWriteContext &context )
158 {
159  // <renderer-v2 type=""> ... </renderer-v2>
160 
161  if ( element.isNull() )
162  return nullptr;
163 
164  // load renderer
165  const QString rendererType = element.attribute( QStringLiteral( "type" ) );
166 
168  if ( !m )
169  return nullptr;
170 
171  QgsFeatureRenderer *r = m->createRenderer( element, context );
172  if ( r )
173  {
174  r->setUsingSymbolLevels( element.attribute( QStringLiteral( "symbollevels" ), QStringLiteral( "0" ) ).toInt() );
175  r->setForceRasterRender( element.attribute( QStringLiteral( "forceraster" ), QStringLiteral( "0" ) ).toInt() );
176  r->setReferenceScale( element.attribute( QStringLiteral( "referencescale" ), QStringLiteral( "-1" ) ).toDouble() );
177 
178  //restore layer effect
179  const QDomElement effectElem = element.firstChildElement( QStringLiteral( "effect" ) );
180  if ( !effectElem.isNull() )
181  {
182  r->setPaintEffect( QgsApplication::paintEffectRegistry()->createEffect( effectElem ) );
183  }
184 
185  // restore order by
186  const QDomElement orderByElem = element.firstChildElement( QStringLiteral( "orderby" ) );
187  r->mOrderBy.load( orderByElem );
188  r->setOrderByEnabled( element.attribute( QStringLiteral( "enableorderby" ), QStringLiteral( "0" ) ).toInt() );
189  }
190  return r;
191 }
192 
193 QDomElement QgsFeatureRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context )
194 {
195  Q_UNUSED( context )
196  // create empty renderer element
197  QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
198 
199  saveRendererData( doc, rendererElem, context );
200 
201  return rendererElem;
202 }
203 
204 void QgsFeatureRenderer::saveRendererData( QDomDocument &doc, QDomElement &rendererElem, const QgsReadWriteContext & )
205 {
206  rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
207  rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
208  rendererElem.setAttribute( QStringLiteral( "referencescale" ), mReferenceScale );
209 
211  mPaintEffect->saveProperties( doc, rendererElem );
212 
213  if ( !mOrderBy.isEmpty() )
214  {
215  QDomElement orderBy = doc.createElement( QStringLiteral( "orderby" ) );
216  mOrderBy.save( orderBy );
217  rendererElem.appendChild( orderBy );
218  }
219  rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
220 }
221 
222 QgsFeatureRenderer *QgsFeatureRenderer::loadSld( const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage )
223 {
224  const QDomElement element = node.toElement();
225  if ( element.isNull() )
226  return nullptr;
227 
228  // get the UserStyle element
229  const QDomElement userStyleElem = element.firstChildElement( QStringLiteral( "UserStyle" ) );
230  if ( userStyleElem.isNull() )
231  {
232  // UserStyle element not found, nothing will be rendered
233  errorMessage = QStringLiteral( "Info: UserStyle element not found." );
234  return nullptr;
235  }
236 
237  // get the FeatureTypeStyle element
238  QDomElement featTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral( "FeatureTypeStyle" ) );
239  if ( featTypeStyleElem.isNull() )
240  {
241  errorMessage = QStringLiteral( "Info: FeatureTypeStyle element not found." );
242  return nullptr;
243  }
244 
245  // create empty FeatureTypeStyle element to merge Rule's from all FeatureTypeStyle's
246  QDomElement mergedFeatTypeStyle = featTypeStyleElem.cloneNode( false ).toElement();
247 
248  // use the RuleRenderer when more rules are present or the rule
249  // has filters or min/max scale denominators set,
250  // otherwise use the SingleSymbol renderer
251  bool needRuleRenderer = false;
252  int ruleCount = 0;
253 
254  while ( !featTypeStyleElem.isNull() )
255  {
256  QDomElement ruleElem = featTypeStyleElem.firstChildElement( QStringLiteral( "Rule" ) );
257  while ( !ruleElem.isNull() )
258  {
259  // test rule children element to check if we need to create RuleRenderer
260  // and if the rule has a symbolizer
261  bool hasRendererSymbolizer = false;
262  bool hasRuleRenderer = false;
263  QDomElement ruleChildElem = ruleElem.firstChildElement();
264  while ( !ruleChildElem.isNull() )
265  {
266  // rule has filter or min/max scale denominator, use the RuleRenderer
267  if ( ruleChildElem.localName() == QLatin1String( "Filter" ) ||
268  ruleChildElem.localName() == QLatin1String( "MinScaleDenominator" ) ||
269  ruleChildElem.localName() == QLatin1String( "MaxScaleDenominator" ) )
270  {
271  hasRuleRenderer = true;
272  }
273  // rule has a renderer symbolizer, not a text symbolizer
274  else if ( ruleChildElem.localName().endsWith( QLatin1String( "Symbolizer" ) ) &&
275  ruleChildElem.localName() != QLatin1String( "TextSymbolizer" ) )
276  {
277  QgsDebugMsgLevel( QStringLiteral( "Symbolizer element found and not a TextSymbolizer" ), 2 );
278  hasRendererSymbolizer = true;
279  }
280 
281  ruleChildElem = ruleChildElem.nextSiblingElement();
282  }
283 
284  if ( hasRendererSymbolizer )
285  {
286  ruleCount++;
287 
288  // append a clone of all Rules to the merged FeatureTypeStyle element
289  mergedFeatTypeStyle.appendChild( ruleElem.cloneNode().toElement() );
290 
291  if ( hasRuleRenderer )
292  {
293  QgsDebugMsgLevel( QStringLiteral( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" ), 2 );
294  needRuleRenderer = true;
295  }
296  }
297 
298  // more rules present, use the RuleRenderer
299  if ( ruleCount > 1 )
300  {
301  QgsDebugMsgLevel( QStringLiteral( "more Rule elements found: need a RuleRenderer" ), 2 );
302  needRuleRenderer = true;
303  }
304 
305  ruleElem = ruleElem.nextSiblingElement( QStringLiteral( "Rule" ) );
306  }
307  featTypeStyleElem = featTypeStyleElem.nextSiblingElement( QStringLiteral( "FeatureTypeStyle" ) );
308  }
309 
310  QString rendererType;
311  if ( needRuleRenderer )
312  {
313  rendererType = QStringLiteral( "RuleRenderer" );
314  }
315  else
316  {
317  rendererType = QStringLiteral( "singleSymbol" );
318  }
319  QgsDebugMsgLevel( QStringLiteral( "Instantiating a '%1' renderer..." ).arg( rendererType ), 2 );
320 
321  // create the renderer and return it
323  if ( !m )
324  {
325  errorMessage = QStringLiteral( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
326  return nullptr;
327  }
328 
329  QgsFeatureRenderer *r = m->createRendererFromSld( mergedFeatTypeStyle, geomType );
330  return r;
331 }
332 
333 QDomElement QgsFeatureRenderer::writeSld( QDomDocument &doc, const QString &styleName, const QVariantMap &props ) const
334 {
335  QDomElement userStyleElem = doc.createElement( QStringLiteral( "UserStyle" ) );
336 
337  QDomElement nameElem = doc.createElement( QStringLiteral( "se:Name" ) );
338  nameElem.appendChild( doc.createTextNode( styleName ) );
339  userStyleElem.appendChild( nameElem );
340 
341  QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral( "se:FeatureTypeStyle" ) );
342  toSld( doc, featureTypeStyleElem, props );
343  userStyleElem.appendChild( featureTypeStyleElem );
344 
345  return userStyleElem;
346 }
347 
349 {
350  return false;
351 }
352 
354 {
355  Q_UNUSED( key )
356  return false;
357 }
358 
359 void QgsFeatureRenderer::checkLegendSymbolItem( const QString &key, bool state )
360 {
361  Q_UNUSED( key )
362  Q_UNUSED( state )
363 }
364 
365 void QgsFeatureRenderer::setLegendSymbolItem( const QString &key, QgsSymbol *symbol )
366 {
367  Q_UNUSED( key )
368  delete symbol;
369 }
370 
371 QString QgsFeatureRenderer::legendKeyToExpression( const QString &, QgsVectorLayer *, bool &ok ) const
372 {
373  ok = false;
374  return QString();
375 }
376 
378 {
379  return QgsLegendSymbolList();
380 }
381 
383 {
386 }
387 
389 {
390  return nullptr != symbolForFeature( feature, context );
391 }
392 
394 {
396  QgsSymbolLayerUtils::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
398  markerSize );
399 }
400 
402 {
403  const auto constPts = pts;
404  for ( const QPointF pt : constPts )
405  renderVertexMarker( pt, context );
406 }
407 
408 void QgsFeatureRenderer::renderVertexMarkerPolygon( QPolygonF &pts, QList<QPolygonF> *rings, QgsRenderContext &context )
409 {
410  const auto constPts = pts;
411  for ( const QPointF pt : constPts )
412  renderVertexMarker( pt, context );
413 
414  if ( rings )
415  {
416  const auto constRings = *rings;
417  for ( const QPolygonF &ring : constRings )
418  {
419  const auto constRing = ring;
420  for ( const QPointF pt : constRing )
421  renderVertexMarker( pt, context );
422  }
423  }
424 }
425 
427 {
428  QgsSymbolList lst;
429  QgsSymbol *s = symbolForFeature( feature, context );
430  if ( s ) lst.append( s );
431  return lst;
432 }
433 
435 {
436  Q_UNUSED( extent )
437  Q_UNUSED( context )
438 }
439 
441 {
442  QgsSymbolList lst;
443  QgsSymbol *s = originalSymbolForFeature( feature, context );
444  if ( s ) lst.append( s );
445  return lst;
446 }
447 
449 {
450  return mPaintEffect;
451 }
452 
454 {
455  delete mPaintEffect;
456  mPaintEffect = effect;
457 }
458 
460 {
461  return mOrderBy;
462 }
463 
465 {
466  mOrderBy = orderBy;
467 }
468 
470 {
471  return mOrderByEnabled;
472 }
473 
475 {
476  mOrderByEnabled = enabled;
477 }
478 
480 {
481  delete subRenderer;
482 }
483 
485 {
486  return nullptr;
487 }
488 
490 {
491  return true;
492 }
493 
495 {
496  if ( symbol->type() == Qgis:: SymbolType::Marker )
497  {
498  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
499  if ( Qgis::ScaleMethod::ScaleArea == method )
500  {
501  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(sqrt(" + QString::number( s->size() ) + " * (" + field + ")),0)" ) );
502  }
503  else
504  {
505  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(" + QString::number( s->size() ) + " * (" + field + "),0)" ) );
506  }
508  }
509  else if ( symbol->type() == Qgis::SymbolType::Line )
510  {
511  QgsLineSymbol *s = static_cast<QgsLineSymbol *>( symbol );
512  s->setDataDefinedWidth( QgsProperty::fromExpression( "coalesce(" + QString::number( s->width() ) + " * (" + field + "),0)" ) );
513  }
514 }
515 
517 {
518  if ( symbol->type() == Qgis::SymbolType::Marker )
519  {
520  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
522  ? QString::number( s->angle() ) + " + "
523  : QString() ) + field );
524  s->setDataDefinedAngle( dd );
525  }
526 }
527 
529 {
530  return mSymbol;
531 }
532 
534 {
535  return mLayer;
536 }
QgsFeatureRenderer::copyRendererData
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
Definition: qgsrenderer.cpp:52
QgsFeatureRenderer::mOrderByEnabled
bool mOrderByEnabled
Definition: qgsrenderer.h:625
QgsFeatureRenderer::setLegendSymbolItem
virtual void setLegendSymbolItem(const QString &key, QgsSymbol *symbol)
Sets the symbol to be used for a legend symbol item.
Definition: qgsrenderer.cpp:365
QgsApplication::rendererRegistry
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
Definition: qgsapplication.cpp:2320
QgsFeatureRenderer::mForceRaster
bool mForceRaster
Definition: qgsrenderer.h:607
QgsFeatureRenderer::defaultRenderer
static QgsFeatureRenderer * defaultRenderer(QgsWkbTypes::GeometryType geomType)
Returns a new renderer - used by default in vector layers.
Definition: qgsrenderer.cpp:79
QgsFeatureRenderer::originalSymbolForFeature
virtual QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns symbol for feature.
Definition: qgsrenderer.cpp:84
QgsMarkerSymbol::setDataDefinedAngle
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:77
QgsFeatureRenderer::mPaintEffect
QgsPaintEffect * mPaintEffect
Definition: qgsrenderer.h:605
QgsFeatureRenderer::mCurrentVertexMarkerSize
double mCurrentVertexMarkerSize
The current size of editing marker.
Definition: qgsrenderer.h:603
QgsSymbolLayerUtils::drawVertexMarker
static void drawVertexMarker(double x, double y, QPainter &p, Qgis::VertexMarkerType type, int markerSize)
Draws a vertex symbol at (painter) coordinates x, y.
Definition: qgssymbollayerutils.cpp:1090
QgsProperty
A store for object properties.
Definition: qgsproperty.h:230
Qgis::SymbolType::Line
@ Line
Line symbol.
QgsFeatureRenderer::writeSld
virtual QDomElement writeSld(QDomDocument &doc, const QString &styleName, const QVariantMap &props=QVariantMap()) const
create the SLD UserStyle element following the SLD v1.1 specs with the given name
Definition: qgsrenderer.cpp:333
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsSymbol::defaultSymbol
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Definition: qgssymbol.cpp:673
QgsFeatureRenderer::setOrderByEnabled
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer.
Definition: qgsrenderer.cpp:474
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
QgsMarkerSymbol::size
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
Definition: qgsmarkersymbol.cpp:197
qgswkbptr.h
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
qgssinglesymbolrenderer.h
QgsFeatureRequest::OrderBy::save
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
Definition: qgsfeaturerequest.cpp:523
QgsFeatureRenderer::accept
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Definition: qgsrenderer.cpp:489
QgsFeatureRenderer::mCurrentVertexMarkerType
Qgis::VertexMarkerType mCurrentVertexMarkerType
The current type of editing marker.
Definition: qgsrenderer.h:600
QgsFeatureRenderer::convertSymbolSizeScale
static void convertSymbolSizeScale(QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field)
Definition: qgsrenderer.cpp:494
QgsLineSymbol::width
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
Definition: qgslinesymbol.cpp:96
qgssymbollayerutils.h
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsFeatureRenderer::renderFeatureWithSymbol
void renderFeatureWithSymbol(const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker) SIP_THROW(QgsCsException)
Render the feature with the symbol using context.
Definition: qgsrenderer.cpp:141
qgsfeature.h
QgsFeatureRenderer::convertSymbolRotation
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
Definition: qgsrenderer.cpp:516
QgsFeatureRenderer::type
QString type() const
Definition: qgsrenderer.h:142
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsStyleEntityVisitorInterface
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
Definition: qgsstyleentityvisitor.h:33
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsFeatureRenderer::setForceRasterRender
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
Definition: qgsrenderer.h:450
QgsSingleSymbolRenderer
Definition: qgssinglesymbolrenderer.h:29
QgsFeatureRenderer::legendSymbolItems
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
Definition: qgsrenderer.cpp:377
qgspainteffectregistry.h
qgspoint.h
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:92
QgsFeatureRenderer::setEmbeddedRenderer
virtual void setEmbeddedRenderer(QgsFeatureRenderer *subRenderer)
Sets an embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.cpp:479
QgsProperty::fromExpression
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
Definition: qgsproperty.cpp:237
field
const QgsField & field
Definition: qgsfield.h:463
qgspainteffect.h
QgsMarkerSymbol::angle
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgsmarkersymbol.cpp:53
QgsRendererAbstractMetadata::createRenderer
virtual QgsFeatureRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
QgsPaintEffectRegistry::defaultStack
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
Definition: qgspainteffectregistry.cpp:114
QgsFeatureRenderer::load
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element
Definition: qgsrenderer.cpp:157
QgsFeatureRenderer::~QgsFeatureRenderer
virtual ~QgsFeatureRenderer()
Definition: qgsrenderer.cpp:74
Qgis::ScaleMethod::ScaleDiameter
@ ScaleDiameter
Calculate scale by the diameter.
QgsPaintEffect::saveProperties
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
Definition: qgspainteffect.cpp:55
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsSymbolLevelItem::layer
int layer() const
The layer of this symbol level.
Definition: qgsrenderer.cpp:533
QgsFeatureRenderer::stopRender
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
Definition: qgsrenderer.cpp:110
QgsMarkerSymbol::setDataDefinedSize
void setDataDefinedSize(const QgsProperty &property) const
Set data defined size for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:306
QgsSymbolLevelItem::symbol
QgsSymbol * symbol() const
The symbol of this symbol level.
Definition: qgsrenderer.cpp:528
QgsFeatureRenderer::willRenderFeature
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
Definition: qgsrenderer.cpp:388
QgsFeatureRenderer::legendSymbolItemChecked
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
Definition: qgsrenderer.cpp:353
QgsFeatureRenderer::orderBy
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
Definition: qgsrenderer.cpp:459
Qgis::ScaleMethod
ScaleMethod
Scale methods.
Definition: qgis.h:219
QgsFeatureRenderer::usesEmbeddedSymbols
virtual bool usesEmbeddedSymbols() const
Returns true if the renderer uses embedded symbols for features.
Definition: qgsrenderer.cpp:117
qgsapplication.h
QgsFeatureRenderer::legendSymbolItemsCheckable
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
Definition: qgsrenderer.cpp:348
QgsFeatureRenderer::QgsFeatureRenderer
QgsFeatureRenderer(const QString &type)
Definition: qgsrenderer.cpp:67
QgsFeatureRenderer::save
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
Stores renderer properties to an XML element.
Definition: qgsrenderer.cpp:193
QgsPaintEffectRegistry::isDefaultStack
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
Definition: qgspainteffectregistry.cpp:134
QgsFeatureRenderer::filterNeedsGeometry
virtual bool filterNeedsGeometry() const
Returns true if this renderer requires the geometry to apply the filter.
Definition: qgsrenderer.cpp:122
QgsSymbolLevelItem::mSymbol
QgsSymbol * mSymbol
Definition: qgsrenderer.h:79
QgsFeatureRenderer::checkLegendSymbolItem
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
Definition: qgsrenderer.cpp:359
QgsFeatureRenderer::setUsingSymbolLevels
void setUsingSymbolLevels(bool usingSymbolLevels)
Definition: qgsrenderer.h:293
QgsFeatureRenderer::_getPoint
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a wkb string in map coordinates.
Definition: qgsrenderer.cpp:47
QgsSymbol::type
Qgis::SymbolType type() const
Returns the symbol's type.
Definition: qgssymbol.h:152
Qgis::VertexMarkerType
VertexMarkerType
Editing vertex markers, used for showing vertices during a edit operation.
Definition: qgis.h:806
QgsSymbolList
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:44
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
QgsFeatureRenderer::saveRendererData
void saveRendererData(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context)
Saves generic renderer data into the specified element.
Definition: qgsrenderer.cpp:204
QgsFeatureRenderer::originalSymbolsForFeature
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
Definition: qgsrenderer.cpp:440
QgsFeatureRequest::OrderBy::load
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
Definition: qgsfeaturerequest.cpp:539
qgsrendererregistry.h
QgsPaintEffect::clone
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
QgsFeatureRenderer::toSld
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Definition: qgsrenderer.h:326
RENDERER_TAG_NAME
#define RENDERER_TAG_NAME
Definition: qgsrenderer.h:50
qgsrendercontext.h
QgsFeatureRenderer::symbols
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
Definition: qgsrenderer.cpp:151
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
QgsSymbolLevelItem::mLayer
int mLayer
Definition: qgsrenderer.h:80
QgsFeatureRenderer::symbolForFeature
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
QgsSymbol::renderFeature
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, Qgis::VertexMarkerType currentVertexMarkerType=Qgis::VertexMarkerType::SemiTransparentCircle, double currentVertexMarkerSize=0.0) SIP_THROW(QgsCsException)
Render a feature.
Definition: qgssymbol.cpp:1252
qgsrenderer.h
qgseffectstack.h
QgsPaintEffect::setEnabled
void setEnabled(bool enabled)
Sets whether the effect is enabled.
Definition: qgspainteffect.cpp:45
QgsFeatureRenderer::modifyRequestExtent
virtual void modifyRequestExtent(QgsRectangle &extent, QgsRenderContext &context)
Allows for a renderer to modify the extent of a feature request prior to rendering.
Definition: qgsrenderer.cpp:434
QgsMarkerSymbol::setScaleMethod
void setScaleMethod(Qgis::ScaleMethod scaleMethod) const
Sets the method to use for scaling the marker's size.
Definition: qgsmarkersymbol.cpp:399
qgsrulebasedrenderer.h
qgsclipper.h
QgsFeatureRenderer::mOrderBy
QgsFeatureRequest::OrderBy mOrderBy
Definition: qgsrenderer.h:623
qgsvectorlayer.h
QgsFeatureRenderer::legendKeyToExpression
virtual QString legendKeyToExpression(const QString &key, QgsVectorLayer *layer, bool &ok) const
Attempts to convert the specified legend rule key to a QGIS expression matching the features displaye...
Definition: qgsrenderer.cpp:371
QgsRenderContext::convertToPainterUnits
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
Definition: qgsrendercontext.cpp:367
QgsFeatureRenderer::mUsingSymbolLevels
bool mUsingSymbolLevels
Definition: qgsrenderer.h:597
QgsSymbol::_getPoint
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a QgsPoint in map coordinates.
Definition: qgssymbol.h:718
qgsgeometry.h
QgsFeatureRenderer::renderVertexMarkerPolyline
void renderVertexMarkerPolyline(QPolygonF &pts, QgsRenderContext &context)
render editing vertex marker for a polyline
Definition: qgsrenderer.cpp:401
QgsFeatureRenderer
Definition: qgsrenderer.h:101
QgsApplication::paintEffectRegistry
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
Definition: qgsapplication.cpp:2315
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
QgsFeatureRequest::OrderBy
Represents a list of OrderByClauses, with the most important first and the least important last.
Definition: qgsfeaturerequest.h:264
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsFeatureRenderer::orderByEnabled
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
Definition: qgsrenderer.cpp:469
qgsmarkersymbol.h
QgsFeatureRenderer::setReferenceScale
void setReferenceScale(double scale)
Sets the symbology reference scale.
Definition: qgsrenderer.h:482
QgsFeatureRenderer::renderFeature
virtual bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) SIP_THROW(QgsCsException)
Render a feature using this renderer in the given context.
Definition: qgsrenderer.cpp:127
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:52
Qgis::ScaleMethod::ScaleArea
@ ScaleArea
Calculate scale by the area.
qgsproperty.h
QgsFeatureRenderer::renderVertexMarker
void renderVertexMarker(QPointF pt, QgsRenderContext &context)
render editing vertex marker at specified point
Definition: qgsrenderer.cpp:393
QgsFeatureRenderer::setPaintEffect
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
Definition: qgsrenderer.cpp:453
QgsFeatureRenderer::setOrderBy
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
Definition: qgsrenderer.cpp:464
QgsFeatureRenderer::renderVertexMarkerPolygon
void renderVertexMarkerPolygon(QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
render editing vertex marker for a polygon
Definition: qgsrenderer.cpp:408
qgsgeometrycollection.h
QgsFeatureRenderer::dump
virtual QString dump() const
Returns debug information about this renderer.
Definition: qgsrenderer.cpp:146
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsFeatureRenderer::paintEffect
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
Definition: qgsrenderer.cpp:448
qgslogger.h
QgsFeatureRenderer::mReferenceScale
double mReferenceScale
Definition: qgsrenderer.h:609
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:112
QgsLineSymbol::setDataDefinedWidth
void setDataDefinedWidth(const QgsProperty &property) const
Set data defined width for whole symbol (including all symbol layers).
Definition: qgslinesymbol.cpp:142
QgsLegendSymbolList
QList< QgsLegendSymbolItem > QgsLegendSymbolList
Definition: qgslegendsymbolitem.h:144
QgsFeatureRenderer::startRender
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:96
QgsFeatureRenderer::setVertexMarkerAppearance
void setVertexMarkerAppearance(Qgis::VertexMarkerType type, double size)
Sets type and size of editing vertex markers for subsequent rendering.
Definition: qgsrenderer.cpp:382
QgsFeatureRenderer::loadSld
static QgsFeatureRenderer * loadSld(const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
Definition: qgsrenderer.cpp:222
QgsFeatureRenderer::symbolsForFeature
virtual QgsSymbolList symbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns list of symbols used for rendering the feature.
Definition: qgsrenderer.cpp:426
QgsRendererRegistry::rendererMetadata
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
Definition: qgsrendererregistry.cpp:132
QgsRendererAbstractMetadata
Stores metadata about one renderer class.
Definition: qgsrendererregistry.h:41
QgsFeatureRenderer::embeddedRenderer
virtual const QgsFeatureRenderer * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.cpp:484
qgssymbol.h
Qgis::SymbolType::Marker
@ Marker
Marker symbol.
QgsRendererAbstractMetadata::createRendererFromSld
virtual QgsFeatureRenderer * createRendererFromSld(QDomElement &elem, QgsWkbTypes::GeometryType geomType)
Definition: qgsrendererregistry.h:118
QgsFeatureRenderer::legendKeysForFeature
virtual QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns legend keys matching a specified feature.
Definition: qgsrenderer.cpp:89
qgslinesymbol.h