QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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  ruleCount++;
242 
243  // append a clone of all Rules to the merged FeatureTypeStyle element
244  mergedFeatTypeStyle.appendChild( ruleElem.cloneNode().toElement() );
245  // more rules present, use the RuleRenderer
246 
247  if ( ruleCount > 1 )
248  {
249  QgsDebugMsg( QStringLiteral( "more Rule elements found: need a RuleRenderer" ) );
250  needRuleRenderer = true;
251  }
252 
253  QDomElement ruleChildElem = ruleElem.firstChildElement();
254  while ( !ruleChildElem.isNull() )
255  {
256  // rule has filter or min/max scale denominator, use the RuleRenderer
257  if ( ruleChildElem.localName() == QLatin1String( "Filter" ) ||
258  ruleChildElem.localName() == QLatin1String( "MinScaleDenominator" ) ||
259  ruleChildElem.localName() == QLatin1String( "MaxScaleDenominator" ) )
260  {
261  QgsDebugMsg( QStringLiteral( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" ) );
262  needRuleRenderer = true;
263  break;
264  }
265 
266  ruleChildElem = ruleChildElem.nextSiblingElement();
267  }
268 
269  ruleElem = ruleElem.nextSiblingElement( QStringLiteral( "Rule" ) );
270  }
271  featTypeStyleElem = featTypeStyleElem.nextSiblingElement( QStringLiteral( "FeatureTypeStyle" ) );
272  }
273 
274  QString rendererType;
275  if ( needRuleRenderer )
276  {
277  rendererType = QStringLiteral( "RuleRenderer" );
278  }
279  else
280  {
281  rendererType = QStringLiteral( "singleSymbol" );
282  }
283  QgsDebugMsg( QStringLiteral( "Instantiating a '%1' renderer..." ).arg( rendererType ) );
284 
285  // create the renderer and return it
287  if ( !m )
288  {
289  errorMessage = QStringLiteral( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
290  return nullptr;
291  }
292 
293  QgsFeatureRenderer *r = m->createRendererFromSld( mergedFeatTypeStyle, geomType );
294  return r;
295 }
296 
297 QDomElement QgsFeatureRenderer::writeSld( QDomDocument &doc, const QString &styleName, const QgsStringMap &props ) const
298 {
299  QDomElement userStyleElem = doc.createElement( QStringLiteral( "UserStyle" ) );
300 
301  QDomElement nameElem = doc.createElement( QStringLiteral( "se:Name" ) );
302  nameElem.appendChild( doc.createTextNode( styleName ) );
303  userStyleElem.appendChild( nameElem );
304 
305  QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral( "se:FeatureTypeStyle" ) );
306  toSld( doc, featureTypeStyleElem, props );
307  userStyleElem.appendChild( featureTypeStyleElem );
308 
309  return userStyleElem;
310 }
311 
313 {
314  return false;
315 }
316 
318 {
319  Q_UNUSED( key )
320  return false;
321 }
322 
323 void QgsFeatureRenderer::checkLegendSymbolItem( const QString &key, bool state )
324 {
325  Q_UNUSED( key )
326  Q_UNUSED( state )
327 }
328 
329 void QgsFeatureRenderer::setLegendSymbolItem( const QString &key, QgsSymbol *symbol )
330 {
331  Q_UNUSED( key )
332  delete symbol;
333 }
334 
336 {
337  return QgsLegendSymbolList();
338 }
339 
341 {
344 }
345 
347 {
348  return nullptr != symbolForFeature( feature, context );
349 }
350 
352 {
354  QgsSymbolLayerUtils::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
356  markerSize );
357 }
358 
360 {
361  const auto constPts = pts;
362  for ( QPointF pt : constPts )
363  renderVertexMarker( pt, context );
364 }
365 
366 void QgsFeatureRenderer::renderVertexMarkerPolygon( QPolygonF &pts, QList<QPolygonF> *rings, QgsRenderContext &context )
367 {
368  const auto constPts = pts;
369  for ( QPointF pt : constPts )
370  renderVertexMarker( pt, context );
371 
372  if ( rings )
373  {
374  const auto constRings = *rings;
375  for ( const QPolygonF &ring : constRings )
376  {
377  const auto constRing = ring;
378  for ( QPointF pt : constRing )
379  renderVertexMarker( pt, context );
380  }
381  }
382 }
383 
385 {
386  QgsSymbolList lst;
387  QgsSymbol *s = symbolForFeature( feature, context );
388  if ( s ) lst.append( s );
389  return lst;
390 }
391 
393 {
394  Q_UNUSED( extent )
395  Q_UNUSED( context )
396 }
397 
399 {
400  QgsSymbolList lst;
401  QgsSymbol *s = originalSymbolForFeature( feature, context );
402  if ( s ) lst.append( s );
403  return lst;
404 }
405 
407 {
408  return mPaintEffect;
409 }
410 
412 {
413  delete mPaintEffect;
414  mPaintEffect = effect;
415 }
416 
418 {
419  return mOrderBy;
420 }
421 
423 {
424  mOrderBy = orderBy;
425 }
426 
428 {
429  return mOrderByEnabled;
430 }
431 
433 {
434  mOrderByEnabled = enabled;
435 }
436 
438 {
439  delete subRenderer;
440 }
441 
443 {
444  return nullptr;
445 }
446 
448 {
449  return true;
450 }
451 
453 {
454  if ( symbol->type() == QgsSymbol::Marker )
455  {
456  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
457  if ( QgsSymbol::ScaleArea == QgsSymbol::ScaleMethod( method ) )
458  {
459  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(sqrt(" + QString::number( s->size() ) + " * (" + field + ")),0)" ) );
460  }
461  else
462  {
463  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(" + QString::number( s->size() ) + " * (" + field + "),0)" ) );
464  }
466  }
467  else if ( symbol->type() == QgsSymbol::Line )
468  {
469  QgsLineSymbol *s = static_cast<QgsLineSymbol *>( symbol );
470  s->setDataDefinedWidth( QgsProperty::fromExpression( "coalesce(" + QString::number( s->width() ) + " * (" + field + "),0)" ) );
471  }
472 }
473 
474 void QgsFeatureRenderer::convertSymbolRotation( QgsSymbol *symbol, const QString &field )
475 {
476  if ( symbol->type() == QgsSymbol::Marker )
477  {
478  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
480  ? QString::number( s->angle() ) + " + "
481  : QString() ) + field );
482  s->setDataDefinedAngle( dd );
483  }
484 }
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:533
Calculate scale by the diameter.
Definition: qgssymbol.h:97
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
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:301
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
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:541
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:50
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
void setUsingSymbolLevels(bool usingSymbolLevels)
Definition: qgsrenderer.h:273
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1309
QgsPaintEffect * mPaintEffect
Definition: qgsrenderer.h:517
Line symbol.
Definition: qgssymbol.h:86
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:612
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:860
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1060
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:44
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:130
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
Definition: qgsrenderer.h:411
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:96
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
Definition: qgssymbol.cpp:1758
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:1599
ScaleMethod
Scale method.
Definition: qgssymbol.h:94
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:1793
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:85
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:120
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:792
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:1409
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:1506
int mCurrentVertexMarkerType
The current type of editing marker.
Definition: qgsrenderer.h:513
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:515
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:1284
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.