25 , mDefaultSymbol( defaultSymbol )
27 Q_ASSERT( mDefaultSymbol );
37 return mDefaultSymbol.get();
46 return mDefaultSymbol.get();
53 mDefaultSymbol->startRender( context, fields );
60 std::unique_ptr< QgsSymbol >
clone( symbol->clone() );
76 mDefaultSymbol->stopRender( context );
81 QSet<QString> attributes;
83 attributes.unite( mDefaultSymbol->usedAttributes( context ) );
106 QDomElement symbolsElem = element.firstChildElement( QStringLiteral(
"symbols" ) );
107 if ( symbolsElem.isNull() )
112 if ( !symbolMap.contains( QStringLiteral(
"0" ) ) )
121 if ( renderer->
type() == QLatin1String(
"embeddedSymbol" ) )
125 else if ( renderer->
type() == QLatin1String(
"singleSymbol" ) )
127 std::unique_ptr< QgsEmbeddedSymbolRenderer > symbolRenderer = std::make_unique< QgsEmbeddedSymbolRenderer >(
static_cast< const QgsSingleSymbolRenderer *
>( renderer )->symbol()->
clone() );
129 return symbolRenderer.release();
140 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"embeddedSymbol" ) );
143 symbols[QStringLiteral(
"0" )] = mDefaultSymbol.get();
145 rendererElem.appendChild( symbolsElem );
156 lst.append( mDefaultSymbol.get() );
162 return mDefaultSymbol.get();
168 mDefaultSymbol.reset( symbol );
A vector feature renderer which uses embedded feature symbology to render per-feature symbols.
bool usesEmbeddedSymbols() const override
Returns true if the renderer uses embedded symbols for features.
QgsSymbol * defaultSymbol() const
Returns the default symbol which will be rendered for any feature which does not have embedded symbol...
QgsEmbeddedSymbolRenderer * clone() const override
Create a deep copy of this renderer.
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
QgsEmbeddedSymbolRenderer(QgsSymbol *defaultSymbol)
Constructor for QgsEmbeddedSymbolRenderer.
static QgsEmbeddedSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
Creates a QgsEmbeddedSymbolRenderer from an existing renderer.
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
void setDefaultSymbol(QgsSymbol *symbol)
Sets the default symbol which will be rendered for any feature which does not have embedded symbology...
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsFeatureRenderer::Capabilities capabilities() override
Returns details about internals of this renderer.
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates a new embedded symbol renderer from an XML element, using the supplied read/write context.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) override
Render a feature using this renderer in the given context.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
~QgsEmbeddedSymbolRenderer() override
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
Stores renderer properties to an XML element.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
@ SymbolLevels
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
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.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
const QgsSymbol * embeddedSymbol() const
Returns the feature's embedded symbology, or nullptr if the feature has no embedded symbol.
Container of fields for a vector layer.
The class is used as a container of context for various read/write operations on other objects.
Contains information about the context of a rendering operation.
static QgsSymbolMap loadSymbols(QDomElement &element, const QgsReadWriteContext &context)
Reads a collection of symbols from XML and returns them in a map. Caller is responsible for deleting ...
static QDomElement saveSymbols(QgsSymbolMap &symbols, const QString &tagName, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a collection of symbols to XML with specified tagName for the top-level element.
Abstract base class for all rendered symbols.
#define RENDERER_TAG_NAME
QMap< QString, QgsSymbol * > QgsSymbolMap
QList< QgsSymbol * > QgsSymbolList