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() );
128 return symbolRenderer.release();
139 rendererElem.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"embeddedSymbol" ) );
140 rendererElem.setAttribute( QStringLiteral(
"symbollevels" ), (
mUsingSymbolLevels ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
141 rendererElem.setAttribute( QStringLiteral(
"forceraster" ), (
mForceRaster ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
144 symbols[QStringLiteral(
"0" )] = mDefaultSymbol.get();
146 rendererElem.appendChild( symbolsElem );
153 QDomElement
orderBy = doc.createElement( QStringLiteral(
"orderby" ) );
155 rendererElem.appendChild(
orderBy );
157 rendererElem.setAttribute( QStringLiteral(
"enableorderby" ), (
mOrderByEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
166 lst.append( mDefaultSymbol.get() );
172 return mDefaultSymbol.get();
178 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.
bool renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false) SIP_THROW(QgsCsException) override
Render a feature using this renderer in the given context.
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.
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
store renderer info to XML element
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
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 void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsPaintEffect * mPaintEffect
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
@ SymbolLevels
Rendering with symbol levels (i.e. implements symbols(), symbolForFeature())
QgsFeatureRequest::OrderBy mOrderBy
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
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...
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.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
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