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