QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 )
62  , mCurrentVertexMarkerType( QgsVectorLayer::Cross )
63  , mCurrentVertexMarkerSize( 2 )
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 
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 }
QgsFeatureRenderer::copyRendererData
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
Definition: qgsrenderer.cpp:49
QgsFeatureRenderer::mOrderByEnabled
bool mOrderByEnabled
Definition: qgsrenderer.h:547
QgsFeatureRenderer::writeSld
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
Definition: qgsrenderer.cpp:315
QgsFeatureRenderer::setLegendSymbolItem
virtual void setLegendSymbolItem(const QString &key, QgsSymbol *symbol)
Sets the symbol to be used for a legend symbol item.
Definition: qgsrenderer.cpp:347
QgsApplication::rendererRegistry
static QgsRendererRegistry * rendererRegistry()
Returns the application's renderer registry, used for managing vector layer renderers.
Definition: qgsapplication.cpp:2148
QgsFeatureRenderer::mForceRaster
bool mForceRaster
Definition: qgsrenderer.h:531
QgsFeatureRenderer::defaultRenderer
static QgsFeatureRenderer * defaultRenderer(QgsWkbTypes::GeometryType geomType)
Returns a new renderer - used by default in vector layers.
Definition: qgsrenderer.cpp:76
QgsFeatureRenderer::originalSymbolForFeature
virtual QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns symbol for feature.
Definition: qgsrenderer.cpp:81
QgsMarkerSymbol::setDataDefinedAngle
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1538
QgsRenderContext::convertToPainterUnits
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
Definition: qgsrendercontext.cpp:318
QgsFeatureRenderer::mPaintEffect
QgsPaintEffect * mPaintEffect
Definition: qgsrenderer.h:529
QgsFeatureRenderer::mCurrentVertexMarkerSize
double mCurrentVertexMarkerSize
The current size of editing marker.
Definition: qgsrenderer.h:527
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsSymbol::defaultSymbol
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Definition: qgssymbol.cpp:320
QgsFeatureRenderer::setOrderByEnabled
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer.
Definition: qgsrenderer.cpp:450
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
QgsMarkerSymbol::size
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
Definition: qgssymbol.cpp:1638
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:448
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:465
QgsLineSymbol::width
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
Definition: qgssymbol.cpp:2000
qgssymbollayerutils.h
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:45
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:133
qgsfeature.h
QgsFeatureRenderer::convertSymbolRotation
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
Definition: qgsrenderer.cpp:492
QgsFeatureRenderer::type
QString type() const
Definition: qgsrenderer.h:141
QgsSymbol::ScaleDiameter
@ ScaleDiameter
Calculate scale by the diameter.
Definition: qgssymbol.h:99
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsStyleEntityVisitorInterface
An interface for classes which can visit style entity (e.g.
Definition: qgsstyleentityvisitor.h:34
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsMarkerSymbol::setDataDefinedSize
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1735
QgsFeatureRenderer::setForceRasterRender
void setForceRasterRender(bool forceRaster)
Sets whether the renderer should be rendered to a raster destination.
Definition: qgsrenderer.h:422
QgsSingleSymbolRenderer
Definition: qgssinglesymbolrenderer.h:30
QgsFeatureRenderer::legendSymbolItems
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
Definition: qgsrenderer.cpp:353
qgspainteffectregistry.h
QgsSymbol::ScaleMethod
ScaleMethod
Scale method.
Definition: qgssymbol.h:97
qgspoint.h
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:64
QgsFeatureRenderer::setEmbeddedRenderer
virtual void setEmbeddedRenderer(QgsFeatureRenderer *subRenderer)
Sets an embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.cpp:455
QgsProperty::fromExpression
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
Definition: qgsproperty.cpp:212
field
const QgsField & field
Definition: qgsfield.h:456
qgspainteffect.h
QgsMarkerSymbol::angle
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgssymbol.cpp:1514
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::toSld
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
QgsFeatureRenderer::load
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element
Definition: qgsrenderer.cpp:149
QgsFeatureRenderer::~QgsFeatureRenderer
virtual ~QgsFeatureRenderer()
Definition: qgsrenderer.cpp:71
QgsPaintEffect::saveProperties
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
Definition: qgspainteffect.cpp:54
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsSymbolLevelItem::layer
int layer() const
The layer of this symbol level.
Definition: qgsrenderer.cpp:509
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:107
QgsFeatureRenderer::setVertexMarkerAppearance
void setVertexMarkerAppearance(int type, double size)
Sets type and size of editing vertex markers for subsequent rendering.
Definition: qgsrenderer.cpp:358
QgsSymbolLevelItem::symbol
QgsSymbol * symbol() const
The symbol of this symbol level.
Definition: qgsrenderer.cpp:504
QgsFeatureRenderer::willRenderFeature
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
Definition: qgsrenderer.cpp:364
QgsFeatureRenderer::legendSymbolItemChecked
virtual bool legendSymbolItemChecked(const QString &key)
items of symbology items in legend is checked
Definition: qgsrenderer.cpp:335
QgsFeatureRenderer::orderBy
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
Definition: qgsrenderer.cpp:435
qgsapplication.h
QgsFeatureRenderer::legendSymbolItemsCheckable
virtual bool legendSymbolItemsCheckable() const
items of symbology items in legend should be checkable
Definition: qgsrenderer.cpp:330
QgsFeatureRenderer::mCurrentVertexMarkerType
int mCurrentVertexMarkerType
The current type of editing marker.
Definition: qgsrenderer.h:525
QgsFeatureRenderer::QgsFeatureRenderer
QgsFeatureRenderer(const QString &type)
Definition: qgsrenderer.cpp:59
QgsFeatureRenderer::save
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
Definition: qgsrenderer.cpp:184
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:114
QgsSymbolLevelItem::mSymbol
QgsSymbol * mSymbol
Definition: qgsrenderer.h:80
QgsFeatureRenderer::checkLegendSymbolItem
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
item in symbology was checked
Definition: qgsrenderer.cpp:341
QgsFeatureRenderer::setUsingSymbolLevels
void setUsingSymbolLevels(bool usingSymbolLevels)
Definition: qgsrenderer.h:284
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:44
QgsSymbolList
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:45
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:931
QgsSymbol::renderFeature
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:838
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:416
QgsFeatureRequest::OrderBy::load
void CORE_EXPORT load(const QDomElement &elem)
Deserialize from XML.
Definition: qgsfeaturerequest.cpp:464
qgsrendererregistry.h
QgsPaintEffect::clone
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
RENDERER_TAG_NAME
#define RENDERER_TAG_NAME
Definition: qgsrenderer.h:51
QgsMarkerSymbol::setScaleMethod
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Definition: qgssymbol.cpp:1828
qgsrendercontext.h
QgsFeatureRenderer::symbols
virtual QgsSymbolList symbols(QgsRenderContext &context) const
Returns list of symbols used by the renderer.
Definition: qgsrenderer.cpp:143
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1131
QgsSymbolLevelItem::mLayer
int mLayer
Definition: qgsrenderer.h:81
QgsFeatureRenderer::symbolForFeature
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
qgsrenderer.h
qgseffectstack.h
QgsPaintEffect::setEnabled
void setEnabled(bool enabled)
Sets whether the effect is enabled.
Definition: qgspainteffect.cpp:44
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:410
qgsrulebasedrenderer.h
qgsclipper.h
QgsFeatureRenderer::mOrderBy
QgsFeatureRequest::OrderBy mOrderBy
Definition: qgsrenderer.h:545
qgsvectorlayer.h
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
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:566
qgsgeometry.h
QgsLineSymbol::setDataDefinedWidth
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:2035
QgsFeatureRenderer::renderVertexMarkerPolyline
void renderVertexMarkerPolyline(QPolygonF &pts, QgsRenderContext &context)
render editing vertex marker for a polyline
Definition: qgsrenderer.cpp:377
QgsFeatureRenderer
Definition: qgsrenderer.h:103
QgsApplication::paintEffectRegistry
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
Definition: qgsapplication.cpp:2143
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:141
QgsFeatureRequest::OrderBy
Represents a list of OrderByClauses, with the most important first and the least important last.
Definition: qgsfeaturerequest.h:230
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsFeatureRenderer::orderByEnabled
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
Definition: qgsrenderer.cpp:445
QgsFeatureRenderer::convertSymbolSizeScale
static void convertSymbolSizeScale(QgsSymbol *symbol, QgsSymbol::ScaleMethod method, const QString &field)
Definition: qgsrenderer.cpp:470
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:119
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:54
qgsproperty.h
QgsSymbol::Line
@ Line
Line symbol.
Definition: qgssymbol.h:88
QgsFeatureRenderer::renderVertexMarker
void renderVertexMarker(QPointF pt, QgsRenderContext &context)
render editing vertex marker at specified point
Definition: qgsrenderer.cpp:369
QgsSymbolLayerUtils::VertexMarkerType
VertexMarkerType
Editing vertex markers.
Definition: qgssymbollayerutils.h:60
QgsSymbol::type
SymbolType type() const
Returns the symbol's type.
Definition: qgssymbol.h:122
QgsSymbol::Marker
@ Marker
Marker symbol.
Definition: qgssymbol.h:87
QgsFeatureRenderer::setPaintEffect
void setPaintEffect(QgsPaintEffect *effect)
Sets the current paint effect for the renderer.
Definition: qgsrenderer.cpp:429
QgsFeatureRenderer::setOrderBy
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
Definition: qgsrenderer.cpp:440
QgsFeatureRenderer::renderVertexMarkerPolygon
void renderVertexMarkerPolygon(QPolygonF &pts, QList< QPolygonF > *rings, QgsRenderContext &context)
render editing vertex marker for a polygon
Definition: qgsrenderer.cpp:384
qgsgeometrycollection.h
QgsFeatureRenderer::dump
virtual QString dump() const
Returns debug information about this renderer.
Definition: qgsrenderer.cpp:138
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsFeatureRenderer::paintEffect
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the renderer.
Definition: qgsrenderer.cpp:424
qgslogger.h
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:179
QgsSymbol::ScaleArea
@ ScaleArea
Calculate scale by the area.
Definition: qgssymbol.h:98
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:93
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:204
QgsFeatureRenderer::symbolsForFeature
virtual QgsSymbolList symbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns list of symbols used for rendering the feature.
Definition: qgsrenderer.cpp:402
QgsRendererRegistry::rendererMetadata
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
Definition: qgsrendererregistry.cpp:118
QgsRendererAbstractMetadata
Stores metadata about one renderer class.
Definition: qgsrendererregistry.h:42
QgsFeatureRenderer::embeddedRenderer
virtual const QgsFeatureRenderer * embeddedRenderer() const
Returns the current embedded renderer (subrenderer) for this feature renderer.
Definition: qgsrenderer.cpp:460
qgssymbol.h
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:86
QgsSymbolLayerUtils::drawVertexMarker
static void drawVertexMarker(double x, double y, QPainter &p, QgsSymbolLayerUtils::VertexMarkerType type, int markerSize)
Draws a vertex symbol at (painter) coordinates x, y.
Definition: qgssymbollayerutils.cpp:919