QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
39 #include <QDomElement>
40 #include <QDomDocument>
41 #include <QPolygonF>
42 
43 QPointF QgsFeatureRenderer::_getPoint( QgsRenderContext &context, const QgsPoint &point )
44 {
45  return QgsSymbol::_getPoint( context, point );
46 }
47 
49 {
50  if ( !destRenderer || !mPaintEffect )
51  return;
52 
53  destRenderer->setPaintEffect( mPaintEffect->clone() );
54  destRenderer->mOrderBy = mOrderBy;
55  destRenderer->mOrderByEnabled = mOrderByEnabled;
56 }
57 
59  : mType( type )
60  , mUsingSymbolLevels( false )
63  , mForceRaster( false )
64  , mOrderByEnabled( false )
65 {
67  mPaintEffect->setEnabled( false );
68 }
69 
71 {
72  delete mPaintEffect;
73 }
74 
76 {
77  return new QgsSingleSymbolRenderer( QgsSymbol::defaultSymbol( geomType ) );
78 }
79 
81 {
82  return symbolForFeature( feature, context );
83 }
84 
85 QSet< QString > QgsFeatureRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
86 {
87  Q_UNUSED( feature );
88  Q_UNUSED( context );
89  return QSet< QString >();
90 }
91 
93 {
94 #ifdef QGISDEBUG
95  if ( !mThread )
96  {
97  mThread = QThread::currentThread();
98  }
99  else
100  {
101  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
102  }
103 #endif
104 }
105 
107 {
108 #ifdef QGISDEBUG
109  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::stopRender", "stopRender called in a different thread - use a cloned renderer instead" );
110 #endif
111 }
112 
114 {
115  return false;
116 }
117 
118 bool QgsFeatureRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
119 {
120 #ifdef QGISDEBUG
121  Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::renderFeature", "renderFeature called in a different thread - use a cloned renderer instead" );
122 #endif
123 
124  QgsSymbol *symbol = symbolForFeature( feature, context );
125  if ( !symbol )
126  return false;
127 
128  renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
129  return true;
130 }
131 
132 void QgsFeatureRenderer::renderFeatureWithSymbol( const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
133 {
134  symbol->renderFeature( feature, context, layer, selected, drawVertexMarker, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
135 }
136 
138 {
139  return QStringLiteral( "UNKNOWN RENDERER\n" );
140 }
141 
143 {
144  Q_UNUSED( context );
145  return QgsSymbolList();
146 }
147 
148 QgsFeatureRenderer *QgsFeatureRenderer::load( QDomElement &element, const QgsReadWriteContext &context )
149 {
150  // <renderer-v2 type=""> ... </renderer-v2>
151 
152  if ( element.isNull() )
153  return nullptr;
154 
155  // load renderer
156  QString rendererType = element.attribute( QStringLiteral( "type" ) );
157 
159  if ( !m )
160  return nullptr;
161 
162  QgsFeatureRenderer *r = m->createRenderer( element, context );
163  if ( r )
164  {
165  r->setUsingSymbolLevels( element.attribute( QStringLiteral( "symbollevels" ), QStringLiteral( "0" ) ).toInt() );
166  r->setForceRasterRender( element.attribute( QStringLiteral( "forceraster" ), QStringLiteral( "0" ) ).toInt() );
167 
168  //restore layer effect
169  QDomElement effectElem = element.firstChildElement( QStringLiteral( "effect" ) );
170  if ( !effectElem.isNull() )
171  {
172  r->setPaintEffect( QgsApplication::paintEffectRegistry()->createEffect( effectElem ) );
173  }
174 
175  // restore order by
176  QDomElement orderByElem = element.firstChildElement( QStringLiteral( "orderby" ) );
177  r->mOrderBy.load( orderByElem );
178  r->setOrderByEnabled( element.attribute( QStringLiteral( "enableorderby" ), QStringLiteral( "0" ) ).toInt() );
179  }
180  return r;
181 }
182 
183 QDomElement QgsFeatureRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context )
184 {
185  Q_UNUSED( context );
186  // create empty renderer element
187  QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
188  rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
189 
191  mPaintEffect->saveProperties( doc, rendererElem );
192 
193  if ( !mOrderBy.isEmpty() )
194  {
195  QDomElement orderBy = doc.createElement( QStringLiteral( "orderby" ) );
196  mOrderBy.save( orderBy );
197  rendererElem.appendChild( orderBy );
198  }
199  rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
200  return rendererElem;
201 }
202 
203 QgsFeatureRenderer *QgsFeatureRenderer::loadSld( const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage )
204 {
205  QDomElement element = node.toElement();
206  if ( element.isNull() )
207  return nullptr;
208 
209  // get the UserStyle element
210  QDomElement userStyleElem = element.firstChildElement( QStringLiteral( "UserStyle" ) );
211  if ( userStyleElem.isNull() )
212  {
213  // UserStyle element not found, nothing will be rendered
214  errorMessage = QStringLiteral( "Info: UserStyle element not found." );
215  return nullptr;
216  }
217 
218  // get the FeatureTypeStyle element
219  QDomElement featTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral( "FeatureTypeStyle" ) );
220  if ( featTypeStyleElem.isNull() )
221  {
222  errorMessage = QStringLiteral( "Info: FeatureTypeStyle element not found." );
223  return nullptr;
224  }
225 
226  // create empty FeatureTypeStyle element to merge Rule's from all FeatureTypeStyle's
227  QDomElement mergedFeatTypeStyle = featTypeStyleElem.cloneNode( false ).toElement();
228 
229  // use the RuleRenderer when more rules are present or the rule
230  // has filters or min/max scale denominators set,
231  // otherwise use the SingleSymbol renderer
232  bool needRuleRenderer = false;
233  int ruleCount = 0;
234 
235  while ( !featTypeStyleElem.isNull() )
236  {
237  QDomElement ruleElem = featTypeStyleElem.firstChildElement( QStringLiteral( "Rule" ) );
238  while ( !ruleElem.isNull() )
239  {
240  ruleCount++;
241 
242  // append a clone of all Rules to the merged FeatureTypeStyle element
243  mergedFeatTypeStyle.appendChild( ruleElem.cloneNode().toElement() );
244  // more rules present, use the RuleRenderer
245 
246  if ( ruleCount > 1 )
247  {
248  QgsDebugMsg( QStringLiteral( "more Rule elements found: need a RuleRenderer" ) );
249  needRuleRenderer = true;
250  }
251 
252  QDomElement ruleChildElem = ruleElem.firstChildElement();
253  while ( !ruleChildElem.isNull() )
254  {
255  // rule has filter or min/max scale denominator, use the RuleRenderer
256  if ( ruleChildElem.localName() == QLatin1String( "Filter" ) ||
257  ruleChildElem.localName() == QLatin1String( "MinScaleDenominator" ) ||
258  ruleChildElem.localName() == QLatin1String( "MaxScaleDenominator" ) )
259  {
260  QgsDebugMsg( QStringLiteral( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" ) );
261  needRuleRenderer = true;
262  break;
263  }
264 
265  ruleChildElem = ruleChildElem.nextSiblingElement();
266  }
267 
268  ruleElem = ruleElem.nextSiblingElement( QStringLiteral( "Rule" ) );
269  }
270  featTypeStyleElem = featTypeStyleElem.nextSiblingElement( QStringLiteral( "FeatureTypeStyle" ) );
271  }
272 
273  QString rendererType;
274  if ( needRuleRenderer )
275  {
276  rendererType = QStringLiteral( "RuleRenderer" );
277  }
278  else
279  {
280  rendererType = QStringLiteral( "singleSymbol" );
281  }
282  QgsDebugMsg( QStringLiteral( "Instantiating a '%1' renderer..." ).arg( rendererType ) );
283 
284  // create the renderer and return it
286  if ( !m )
287  {
288  errorMessage = QStringLiteral( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
289  return nullptr;
290  }
291 
292  QgsFeatureRenderer *r = m->createRendererFromSld( mergedFeatTypeStyle, geomType );
293  return r;
294 }
295 
296 QDomElement QgsFeatureRenderer::writeSld( QDomDocument &doc, const QString &styleName, const QgsStringMap &props ) const
297 {
298  QDomElement userStyleElem = doc.createElement( QStringLiteral( "UserStyle" ) );
299 
300  QDomElement nameElem = doc.createElement( QStringLiteral( "se:Name" ) );
301  nameElem.appendChild( doc.createTextNode( styleName ) );
302  userStyleElem.appendChild( nameElem );
303 
304  QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral( "se:FeatureTypeStyle" ) );
305  toSld( doc, featureTypeStyleElem, props );
306  userStyleElem.appendChild( featureTypeStyleElem );
307 
308  return userStyleElem;
309 }
310 
312 {
313  return false;
314 }
315 
317 {
318  Q_UNUSED( key );
319  return false;
320 }
321 
322 void QgsFeatureRenderer::checkLegendSymbolItem( const QString &key, bool state )
323 {
324  Q_UNUSED( key );
325  Q_UNUSED( state );
326 }
327 
328 void QgsFeatureRenderer::setLegendSymbolItem( const QString &key, QgsSymbol *symbol )
329 {
330  Q_UNUSED( key );
331  delete symbol;
332 }
333 
335 {
336  return QgsLegendSymbolList();
337 }
338 
340 {
343 }
344 
346 {
347  return nullptr != symbolForFeature( feature, context );
348 }
349 
351 {
353  QgsSymbolLayerUtils::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
355  markerSize );
356 }
357 
359 {
360  Q_FOREACH ( QPointF pt, pts )
361  renderVertexMarker( pt, context );
362 }
363 
364 void QgsFeatureRenderer::renderVertexMarkerPolygon( QPolygonF &pts, QList<QPolygonF> *rings, QgsRenderContext &context )
365 {
366  Q_FOREACH ( QPointF pt, pts )
367  renderVertexMarker( pt, context );
368 
369  if ( rings )
370  {
371  Q_FOREACH ( const QPolygonF &ring, *rings )
372  {
373  Q_FOREACH ( QPointF pt, ring )
374  renderVertexMarker( pt, context );
375  }
376  }
377 }
378 
380 {
381  QgsSymbolList lst;
382  QgsSymbol *s = symbolForFeature( feature, context );
383  if ( s ) lst.append( s );
384  return lst;
385 }
386 
388 {
389  Q_UNUSED( extent );
390  Q_UNUSED( context );
391 }
392 
394 {
395  QgsSymbolList lst;
396  QgsSymbol *s = originalSymbolForFeature( feature, context );
397  if ( s ) lst.append( s );
398  return lst;
399 }
400 
402 {
403  return mPaintEffect;
404 }
405 
407 {
408  delete mPaintEffect;
409  mPaintEffect = effect;
410 }
411 
413 {
414  return mOrderBy;
415 }
416 
418 {
419  mOrderBy = orderBy;
420 }
421 
423 {
424  return mOrderByEnabled;
425 }
426 
428 {
429  mOrderByEnabled = enabled;
430 }
431 
433 {
434  delete subRenderer;
435 }
436 
438 {
439  return nullptr;
440 }
441 
443 {
444  if ( symbol->type() == QgsSymbol::Marker )
445  {
446  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
447  if ( QgsSymbol::ScaleArea == QgsSymbol::ScaleMethod( method ) )
448  {
449  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(sqrt(" + QString::number( s->size() ) + " * (" + field + ")),0)" ) );
450  }
451  else
452  {
453  s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(" + QString::number( s->size() ) + " * (" + field + "),0)" ) );
454  }
456  }
457  else if ( symbol->type() == QgsSymbol::Line )
458  {
459  QgsLineSymbol *s = static_cast<QgsLineSymbol *>( symbol );
460  s->setDataDefinedWidth( QgsProperty::fromExpression( "coalesce(" + QString::number( s->width() ) + " * (" + field + "),0)" ) );
461  }
462 }
463 
464 void QgsFeatureRenderer::convertSymbolRotation( QgsSymbol *symbol, const QString &field )
465 {
466  if ( symbol->type() == QgsSymbol::Marker )
467  {
468  QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
470  ? QString::number( s->angle() ) + " + "
471  : QString() ) + field );
472  s->setDataDefinedAngle( dd );
473  }
474 }
The class is used as a container of context for various read/write operations on other objects...
QString type() const
Definition: qgsrenderer.h:129
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
A rectangle specified with double values.
Definition: qgsrectangle.h:40
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgssymbol.cpp:1182
QList< QgsLegendSymbolItem > QgsLegendSymbolList
QgsFeatureRequest::OrderBy mOrderBy
Definition: qgsrenderer.h:521
Calculate scale by the diameter.
Definition: qgssymbol.h:97
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
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 symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
virtual QgsFeatureRenderer * createRendererFromSld(QDomElement &elem, QgsWkbTypes::GeometryType geomType)
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.
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
Definition: qgssymbol.cpp:1639
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a QgsPoint in map coordinates.
Definition: qgssymbol.h:447
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
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:49
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
void setUsingSymbolLevels(bool usingSymbolLevels)
Definition: qgsrenderer.h:272
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1205
QgsPaintEffect * mPaintEffect
Definition: qgsrenderer.h:505
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
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a wkb string in map coordinates.
Definition: qgsrenderer.cpp:43
virtual QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns symbol for feature.
Definition: qgsrenderer.cpp:80
QMap< QString, QString > QgsStringMap
Definition: qgis.h:577
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:732
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:920
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application&#39;s paint effect registry, used for managing paint effects. ...
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.
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
void setEnabled(bool enabled)
Sets whether the effect is enabled.
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:43
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Definition: qgssymbol.cpp:275
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects. ...
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
Definition: qgsrenderer.h:410
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
virtual QgsFeatureRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
virtual ~QgsFeatureRenderer()
Definition: qgsrenderer.cpp:70
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
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:1485
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 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:300
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
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:1673
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer...
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
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:138
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
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
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:734
virtual const QgsFeatureRenderer * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
virtual QString dump() const
Returns debug information about this renderer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:92
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 copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
Definition: qgsrenderer.cpp:48
SymbolType type() const
Returns the symbol&#39;s type.
Definition: qgssymbol.h:120
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
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.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
Definition: qgssymbol.cpp:1302
virtual QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns legend keys matching a specified feature.
Definition: qgsrenderer.cpp:85
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1394
int mCurrentVertexMarkerType
The current type of editing marker.
Definition: qgsrenderer.h:501
static QgsFeatureRenderer * defaultRenderer(QgsWkbTypes::GeometryType geomType)
Returns a new renderer - used by default in vector layers.
Definition: qgsrenderer.cpp:75
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:503
QgsFeatureRenderer(const QString &type)
Definition: qgsrenderer.cpp:58
virtual QgsSymbolList symbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns list of symbols used for rendering the feature.
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.
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