QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
20#include "qgssinglesymbolrenderer.h" // for default renderer
21
22#include "qgsrendererregistry.h"
23
24#include "qgsrendercontext.h"
25#include "qgsfeature.h"
26#include "qgslogger.h"
27#include "qgsvectorlayer.h"
28#include "qgspainteffect.h"
30#include "qgspoint.h"
31#include "qgsproperty.h"
32#include "qgsapplication.h"
33#include "qgsmarkersymbol.h"
34#include "qgslinesymbol.h"
35
36#include <QDomElement>
37#include <QDomDocument>
38#include <QPolygonF>
39#include <QThread>
40
42{
43 return QgsSymbol::_getPoint( context, point );
44}
45
47{
48 if ( !destRenderer )
49 return;
50
51 if ( mPaintEffect )
52 destRenderer->setPaintEffect( mPaintEffect->clone() );
53
54 destRenderer->setForceRasterRender( mForceRaster );
56 destRenderer->mOrderBy = mOrderBy;
57 destRenderer->mOrderByEnabled = mOrderByEnabled;
58 destRenderer->mReferenceScale = mReferenceScale;
59}
60
62 : mType( type )
63{
65 mPaintEffect->setEnabled( false );
66}
67
69{
70 delete mPaintEffect;
71}
72
74{
75 return new QgsSingleSymbolRenderer( QgsSymbol::defaultSymbol( geomType ) );
76}
77
79{
80 return symbolForFeature( feature, context );
81}
82
83QSet< QString > QgsFeatureRenderer::legendKeysForFeature( const QgsFeature &feature, QgsRenderContext &context ) const
84{
85 Q_UNUSED( feature )
86 Q_UNUSED( context )
87 return QSet< QString >();
88}
89
91{
92#ifdef QGISDEBUG
93 if ( !mThread )
94 {
95 mThread = QThread::currentThread();
96 }
97 else
98 {
99 Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::startRender", "startRender called in a different thread - use a cloned renderer instead" );
100 }
101#endif
102}
103
105{
106 return false;
107}
108
110{
111#ifdef QGISDEBUG
112 Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::stopRender", "stopRender called in a different thread - use a cloned renderer instead" );
113#endif
114}
115
117{
118 return false;
119}
120
122{
123 return false;
124}
125
126bool QgsFeatureRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
127{
128#ifdef QGISDEBUG
129 Q_ASSERT_X( mThread == QThread::currentThread(), "QgsFeatureRenderer::renderFeature", "renderFeature called in a different thread - use a cloned renderer instead" );
130#endif
131
132 QgsSymbol *symbol = symbolForFeature( feature, context );
133 if ( !symbol )
134 return false;
135
136 renderFeatureWithSymbol( feature, symbol, context, layer, selected, drawVertexMarker );
137 return true;
138}
139
140void QgsFeatureRenderer::renderFeatureWithSymbol( const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker )
141{
142 symbol->renderFeature( feature, context, layer, selected, drawVertexMarker, mCurrentVertexMarkerType, mCurrentVertexMarkerSize );
143}
144
146{
147 return QStringLiteral( "UNKNOWN RENDERER\n" );
148}
149
151{
152 Q_UNUSED( context )
153 return QgsSymbolList();
154}
155
157{
158 // <renderer-v2 type=""> ... </renderer-v2>
159
160 if ( element.isNull() )
161 return nullptr;
162
163 // load renderer
164 const QString rendererType = element.attribute( QStringLiteral( "type" ) );
165
167 if ( !m )
168 return nullptr;
169
170 QgsFeatureRenderer *r = m->createRenderer( element, context );
171 if ( r )
172 {
173 r->setUsingSymbolLevels( element.attribute( QStringLiteral( "symbollevels" ), QStringLiteral( "0" ) ).toInt() );
174 r->setForceRasterRender( element.attribute( QStringLiteral( "forceraster" ), QStringLiteral( "0" ) ).toInt() );
175 r->setReferenceScale( element.attribute( QStringLiteral( "referencescale" ), QStringLiteral( "-1" ) ).toDouble() );
176
177 //restore layer effect
178 const QDomElement effectElem = element.firstChildElement( QStringLiteral( "effect" ) );
179 if ( !effectElem.isNull() )
180 {
181 r->setPaintEffect( QgsApplication::paintEffectRegistry()->createEffect( effectElem ) );
182 }
183
184 // restore order by
185 const QDomElement orderByElem = element.firstChildElement( QStringLiteral( "orderby" ) );
186 r->mOrderBy.load( orderByElem );
187 r->setOrderByEnabled( element.attribute( QStringLiteral( "enableorderby" ), QStringLiteral( "0" ) ).toInt() );
188 }
189 return r;
190}
191
192QDomElement QgsFeatureRenderer::save( QDomDocument &doc, const QgsReadWriteContext &context )
193{
194 Q_UNUSED( context )
195 // create empty renderer element
196 QDomElement rendererElem = doc.createElement( RENDERER_TAG_NAME );
197
198 saveRendererData( doc, rendererElem, context );
199
200 return rendererElem;
201}
202
203void QgsFeatureRenderer::saveRendererData( QDomDocument &doc, QDomElement &rendererElem, const QgsReadWriteContext & )
204{
205 rendererElem.setAttribute( QStringLiteral( "forceraster" ), ( mForceRaster ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
206 rendererElem.setAttribute( QStringLiteral( "symbollevels" ), ( mUsingSymbolLevels ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
207 rendererElem.setAttribute( QStringLiteral( "referencescale" ), mReferenceScale );
208
210 mPaintEffect->saveProperties( doc, rendererElem );
211
212 if ( !mOrderBy.isEmpty() )
213 {
214 QDomElement orderBy = doc.createElement( QStringLiteral( "orderby" ) );
216 rendererElem.appendChild( orderBy );
217 }
218 rendererElem.setAttribute( QStringLiteral( "enableorderby" ), ( mOrderByEnabled ? QStringLiteral( "1" ) : QStringLiteral( "0" ) ) );
219}
220
221QgsFeatureRenderer *QgsFeatureRenderer::loadSld( const QDomNode &node, Qgis::GeometryType geomType, QString &errorMessage )
222{
223 const QDomElement element = node.toElement();
224 if ( element.isNull() )
225 return nullptr;
226
227 // get the UserStyle element
228 const QDomElement userStyleElem = element.firstChildElement( QStringLiteral( "UserStyle" ) );
229 if ( userStyleElem.isNull() )
230 {
231 // UserStyle element not found, nothing will be rendered
232 errorMessage = QStringLiteral( "Info: UserStyle element not found." );
233 return nullptr;
234 }
235
236 // get the FeatureTypeStyle element
237 QDomElement featTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral( "FeatureTypeStyle" ) );
238 if ( featTypeStyleElem.isNull() )
239 {
240 errorMessage = QStringLiteral( "Info: FeatureTypeStyle element not found." );
241 return nullptr;
242 }
243
244 // create empty FeatureTypeStyle element to merge Rule's from all FeatureTypeStyle's
245 QDomElement mergedFeatTypeStyle = featTypeStyleElem.cloneNode( false ).toElement();
246
247 // use the RuleRenderer when more rules are present or the rule
248 // has filters or min/max scale denominators set,
249 // otherwise use the SingleSymbol renderer
250 bool needRuleRenderer = false;
251 int ruleCount = 0;
252
253 while ( !featTypeStyleElem.isNull() )
254 {
255 QDomElement ruleElem = featTypeStyleElem.firstChildElement( QStringLiteral( "Rule" ) );
256 while ( !ruleElem.isNull() )
257 {
258 // test rule children element to check if we need to create RuleRenderer
259 // and if the rule has a symbolizer
260 bool hasRendererSymbolizer = false;
261 bool hasRuleRenderer = false;
262 QDomElement ruleChildElem = ruleElem.firstChildElement();
263 while ( !ruleChildElem.isNull() )
264 {
265 // rule has filter or min/max scale denominator, use the RuleRenderer
266 if ( ruleChildElem.localName() == QLatin1String( "Filter" ) ||
267 ruleChildElem.localName() == QLatin1String( "ElseFilter" ) ||
268 ruleChildElem.localName() == QLatin1String( "MinScaleDenominator" ) ||
269 ruleChildElem.localName() == QLatin1String( "MaxScaleDenominator" ) )
270 {
271 hasRuleRenderer = true;
272 }
273 // rule has a renderer symbolizer, not a text symbolizer
274 else if ( ruleChildElem.localName().endsWith( QLatin1String( "Symbolizer" ) ) &&
275 ruleChildElem.localName() != QLatin1String( "TextSymbolizer" ) )
276 {
277 QgsDebugMsgLevel( QStringLiteral( "Symbolizer element found and not a TextSymbolizer" ), 2 );
278 hasRendererSymbolizer = true;
279 }
280
281 ruleChildElem = ruleChildElem.nextSiblingElement();
282 }
283
284 if ( hasRendererSymbolizer )
285 {
286 ruleCount++;
287
288 // append a clone of all Rules to the merged FeatureTypeStyle element
289 mergedFeatTypeStyle.appendChild( ruleElem.cloneNode().toElement() );
290
291 if ( hasRuleRenderer )
292 {
293 QgsDebugMsgLevel( QStringLiteral( "Filter or Min/MaxScaleDenominator element found: need a RuleRenderer" ), 2 );
294 needRuleRenderer = true;
295 }
296 }
297
298 // more rules present, use the RuleRenderer
299 if ( ruleCount > 1 )
300 {
301 QgsDebugMsgLevel( QStringLiteral( "more Rule elements found: need a RuleRenderer" ), 2 );
302 needRuleRenderer = true;
303 }
304
305 ruleElem = ruleElem.nextSiblingElement( QStringLiteral( "Rule" ) );
306 }
307 featTypeStyleElem = featTypeStyleElem.nextSiblingElement( QStringLiteral( "FeatureTypeStyle" ) );
308 }
309
310 QString rendererType;
311 if ( needRuleRenderer )
312 {
313 rendererType = QStringLiteral( "RuleRenderer" );
314 }
315 else
316 {
317 rendererType = QStringLiteral( "singleSymbol" );
318 }
319 QgsDebugMsgLevel( QStringLiteral( "Instantiating a '%1' renderer..." ).arg( rendererType ), 2 );
320
321 // create the renderer and return it
323 if ( !m )
324 {
325 errorMessage = QStringLiteral( "Error: Unable to get metadata for '%1' renderer." ).arg( rendererType );
326 return nullptr;
327 }
328
329 QgsFeatureRenderer *r = m->createRendererFromSld( mergedFeatTypeStyle, geomType );
330 return r;
331}
332
334{
335 // build up a list of unique legend keys
336 const QgsLegendSymbolList allLegendSymbols = legendSymbolItems();
337 QSet< QString > keys;
338 keys.reserve( allLegendSymbols.size() );
339 for ( const QgsLegendSymbolItem &symbol : allLegendSymbols )
340 {
341 keys.insert( symbol.ruleKey() );
342 }
343 return keys;
344}
345
346QDomElement QgsFeatureRenderer::writeSld( QDomDocument &doc, const QString &styleName, const QVariantMap &props ) const
347{
348 QDomElement userStyleElem = doc.createElement( QStringLiteral( "UserStyle" ) );
349
350 QDomElement nameElem = doc.createElement( QStringLiteral( "se:Name" ) );
351 nameElem.appendChild( doc.createTextNode( styleName ) );
352 userStyleElem.appendChild( nameElem );
353
354 QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral( "se:FeatureTypeStyle" ) );
355 toSld( doc, featureTypeStyleElem, props );
356 userStyleElem.appendChild( featureTypeStyleElem );
357
358 return userStyleElem;
359}
360
362{
363 return false;
364}
365
367{
368 Q_UNUSED( key )
369 return false;
370}
371
372void QgsFeatureRenderer::checkLegendSymbolItem( const QString &key, bool state )
373{
374 Q_UNUSED( key )
375 Q_UNUSED( state )
376}
377
378void QgsFeatureRenderer::setLegendSymbolItem( const QString &key, QgsSymbol *symbol )
379{
380 Q_UNUSED( key )
381 delete symbol;
382}
383
384QString QgsFeatureRenderer::legendKeyToExpression( const QString &, QgsVectorLayer *, bool &ok ) const
385{
386 ok = false;
387 return QString();
388}
389
391{
392 return QgsLegendSymbolList();
393}
394
396{
399}
400
402{
403 return nullptr != symbolForFeature( feature, context );
404}
405
407{
409 QgsSymbolLayerUtils::drawVertexMarker( pt.x(), pt.y(), *context.painter(),
411 markerSize );
412}
413
415{
416 const auto constPts = pts;
417 for ( const QPointF pt : constPts )
418 renderVertexMarker( pt, context );
419}
420
421void QgsFeatureRenderer::renderVertexMarkerPolygon( QPolygonF &pts, QList<QPolygonF> *rings, QgsRenderContext &context )
422{
423 const auto constPts = pts;
424 for ( const QPointF pt : constPts )
425 renderVertexMarker( pt, context );
426
427 if ( rings )
428 {
429 const auto constRings = *rings;
430 for ( const QPolygonF &ring : constRings )
431 {
432 const auto constRing = ring;
433 for ( const QPointF pt : constRing )
434 renderVertexMarker( pt, context );
435 }
436 }
437}
438
440{
441 QgsSymbolList lst;
442 QgsSymbol *s = symbolForFeature( feature, context );
443 if ( s ) lst.append( s );
444 return lst;
445}
446
448{
449 Q_UNUSED( extent )
450 Q_UNUSED( context )
451}
452
454{
455 QgsSymbolList lst;
456 QgsSymbol *s = originalSymbolForFeature( feature, context );
457 if ( s ) lst.append( s );
458 return lst;
459}
460
462{
463 return mPaintEffect;
464}
465
467{
468 delete mPaintEffect;
469 mPaintEffect = effect;
470}
471
473{
474 return mOrderBy;
475}
476
478{
480}
481
483{
484 return mOrderByEnabled;
485}
486
488{
489 mOrderByEnabled = enabled;
490}
491
493{
494 delete subRenderer;
495}
496
498{
499 return nullptr;
500}
501
503{
504 return true;
505}
506
507void QgsFeatureRenderer::convertSymbolSizeScale( QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field )
508{
509 if ( symbol->type() == Qgis:: SymbolType::Marker )
510 {
511 QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
512 if ( Qgis::ScaleMethod::ScaleArea == method )
513 {
514 s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(sqrt(" + QString::number( s->size() ) + " * (" + field + ")),0)" ) );
515 }
516 else
517 {
518 s->setDataDefinedSize( QgsProperty::fromExpression( "coalesce(" + QString::number( s->size() ) + " * (" + field + "),0)" ) );
519 }
521 }
522 else if ( symbol->type() == Qgis::SymbolType::Line )
523 {
524 QgsLineSymbol *s = static_cast<QgsLineSymbol *>( symbol );
525 s->setDataDefinedWidth( QgsProperty::fromExpression( "coalesce(" + QString::number( s->width() ) + " * (" + field + "),0)" ) );
526 }
527}
528
529void QgsFeatureRenderer::convertSymbolRotation( QgsSymbol *symbol, const QString &field )
530{
531 if ( symbol->type() == Qgis::SymbolType::Marker )
532 {
533 QgsMarkerSymbol *s = static_cast<QgsMarkerSymbol *>( symbol );
535 ? QString::number( s->angle() ) + " + "
536 : QString() ) + field );
537 s->setDataDefinedAngle( dd );
538 }
539}
540
542{
543 return mSymbol;
544}
545
547{
548 return mLayer;
549}
ScaleMethod
Scale methods.
Definition: qgis.h:415
@ ScaleDiameter
Calculate scale by the diameter.
@ ScaleArea
Calculate scale by the area.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition: qgis.h:255
@ Millimeters
Millimeters.
VertexMarkerType
Editing vertex markers, used for showing vertices during a edit operation.
Definition: qgis.h:1420
@ Marker
Marker symbol.
@ Line
Line symbol.
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
virtual bool canSkipRender()
Returns true if the renderer can be entirely skipped, i.e.
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a wkb string in map coordinates.
Definition: qgsrenderer.cpp:41
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.
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer.
virtual bool legendSymbolItemsCheckable() const
Returns true if symbology items in legend are checkable.
virtual void modifyRequestExtent(QgsRectangle &extent, QgsRenderContext &context)
Allows for a renderer to modify the extent of a feature request prior to rendering.
virtual bool legendSymbolItemChecked(const QString &key)
Returns true if the legend symbology item with the specified key is checked.
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:61
static QgsFeatureRenderer * defaultRenderer(Qgis::GeometryType geomType)
Returns a new renderer - used by default in vector layers.
Definition: qgsrenderer.cpp:73
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:467
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:331
virtual QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns legend keys matching a specified feature.
Definition: qgsrenderer.cpp:83
QgsPaintEffect * mPaintEffect
Definition: qgsrenderer.h:616
QString type() const
Definition: qgsrenderer.h:142
virtual bool usesEmbeddedSymbols() const
Returns true if the renderer uses embedded symbols for features.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
Definition: qgsrenderer.cpp:46
virtual bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false)
Render a feature using this renderer in the given context.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
Stores renderer properties to an XML element.
void setReferenceScale(double scale)
Sets the symbology reference scale.
Definition: qgsrenderer.h:499
virtual QString dump() const
Returns debug information about this renderer.
void setUsingSymbolLevels(bool usingSymbolLevels)
Definition: qgsrenderer.h:299
virtual ~QgsFeatureRenderer()
Definition: qgsrenderer.cpp:68
virtual QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const =0
To be overridden.
virtual void checkLegendSymbolItem(const QString &key, bool state=true)
Sets whether the legend symbology item with the specified ley should be checked.
virtual QString legendKeyToExpression(const QString &key, QgsVectorLayer *layer, bool &ok) const
Attempts to convert the specified legend rule key to a QGIS expression matching the features displaye...
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...
QgsFeatureRequest::OrderBy mOrderBy
Definition: qgsrenderer.h:634
virtual QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns symbol for feature.
Definition: qgsrenderer.cpp:78
Qgis::VertexMarkerType mCurrentVertexMarkerType
The current type of editing marker.
Definition: qgsrenderer.h:611
QSet< QString > legendKeys() const
Returns the set of all legend keys used by the renderer.
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
void saveRendererData(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context)
Saves generic renderer data into the specified element.
void renderFeatureWithSymbol(const QgsFeature &feature, QgsSymbol *symbol, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker)
Render the feature with the symbol using context.
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:614
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:90
static void convertSymbolSizeScale(QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field)
void setVertexMarkerAppearance(Qgis::VertexMarkerType type, double size)
Sets type and size of editing vertex markers for subsequent rendering.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
static QgsFeatureRenderer * loadSld(const QDomNode &node, Qgis::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
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 unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Container of fields for a vector layer.
Definition: qgsfields.h:45
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
void setDataDefinedWidth(const QgsProperty &property) const
Set data defined width for whole symbol (including all symbol layers).
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
A marker symbol type, for rendering Point and MultiPoint geometries.
void setScaleMethod(Qgis::ScaleMethod scaleMethod) const
Sets the method to use for scaling the marker's size.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
double angle() const
Returns the marker angle for the whole symbol.
void setDataDefinedSize(const QgsProperty &property) const
Set data defined size for whole symbol (including all symbol layers).
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
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:49
A store for object properties.
Definition: qgsproperty.h:228
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.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
QPainter * painter()
Returns the destination QPainter for the render operation.
Stores metadata about one renderer class.
virtual QgsFeatureRenderer * createRenderer(QDomElement &elem, const QgsReadWriteContext &context)=0
Returns new instance of the renderer given the DOM element.
virtual QgsFeatureRenderer * createRendererFromSld(QDomElement &elem, Qgis::GeometryType geomType)
Returns a new instance of the renderer, converted from an SLD XML element.
QgsRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
An interface for classes which can visit style entity (e.g.
static void drawVertexMarker(double x, double y, QPainter &p, Qgis::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:79
QgsSymbol * symbol() const
The symbol of this symbol level.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:94
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, Qgis::VertexMarkerType currentVertexMarkerType=Qgis::VertexMarkerType::SemiTransparentCircle, double currentVertexMarkerSize=0.0)
Render a feature.
Definition: qgssymbol.cpp:1302
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a QgsPoint in map coordinates.
Definition: qgssymbol.h:715
Qgis::SymbolType type() const
Returns the symbol's type.
Definition: qgssymbol.h:156
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
Definition: qgssymbol.cpp:705
Represents a vector layer which manages a vector based data sets.
QList< QgsLegendSymbolItem > QgsLegendSymbolList
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
#define RENDERER_TAG_NAME
Definition: qgsrenderer.h:50
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:44