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