37 #include <QDomDocument> 
   38 #include <QDomElement> 
   68   mSymbol->startRender( context, fields );
 
   83   QSet<QString> attributes;
 
   85     attributes.unite( 
mSymbol->usedAttributes( context ) );
 
  112   return mSymbol ? QStringLiteral( 
"SINGLE: %1" ).arg( 
mSymbol->dump() ) : QString();
 
  125   QVariantMap newProps = props;
 
  127   QDomElement ruleElem = doc.createElement( QStringLiteral( 
"se:Rule" ) );
 
  128   element.appendChild( ruleElem );
 
  130   QDomElement nameElem = doc.createElement( QStringLiteral( 
"se:Name" ) );
 
  131   nameElem.appendChild( doc.createTextNode( QStringLiteral( 
"Single symbol" ) ) );
 
  132   ruleElem.appendChild( nameElem );
 
  150   QDomElement symbolsElem = element.firstChildElement( QStringLiteral( 
"symbols" ) );
 
  151   if ( symbolsElem.isNull() )
 
  156   if ( !symbolMap.contains( QStringLiteral( 
"0" ) ) )
 
  164   QDomElement rotationElem = element.firstChildElement( QStringLiteral( 
"rotation" ) );
 
  165   if ( !rotationElem.isNull() && !rotationElem.attribute( QStringLiteral( 
"field" ) ).isEmpty() )
 
  170   QDomElement sizeScaleElem = element.firstChildElement( QStringLiteral( 
"sizescale" ) );
 
  171   if ( !sizeScaleElem.isNull() && !sizeScaleElem.attribute( QStringLiteral( 
"field" ) ).isEmpty() )
 
  175                             sizeScaleElem.attribute( QStringLiteral( 
"field" ) ) );
 
  178   QDomElement ddsLegendSizeElem = element.firstChildElement( QStringLiteral( 
"data-defined-size-legend" ) );
 
  179   if ( !ddsLegendSizeElem.isNull() )
 
  193   QDomElement ruleElem = element.firstChildElement( QStringLiteral( 
"Rule" ) );
 
  194   if ( ruleElem.isNull() )
 
  196     QgsDebugMsg( QStringLiteral( 
"no Rule elements found!" ) );
 
  200   QString label, description;
 
  204   QDomElement childElem = ruleElem.firstChildElement();
 
  205   while ( !childElem.isNull() )
 
  207     if ( childElem.localName() == QLatin1String( 
"Name" ) )
 
  211       if ( label.isEmpty() )
 
  212         label = childElem.firstChild().nodeValue();
 
  214     else if ( childElem.localName() == QLatin1String( 
"Description" ) )
 
  217       QDomElement titleElem = childElem.firstChildElement( QStringLiteral( 
"Title" ) );
 
  218       if ( !titleElem.isNull() )
 
  220         label = titleElem.firstChild().nodeValue();
 
  223       QDomElement abstractElem = childElem.firstChildElement( QStringLiteral( 
"Abstract" ) );
 
  224       if ( !abstractElem.isNull() )
 
  226         description = abstractElem.firstChild().nodeValue();
 
  229     else if ( childElem.localName() == QLatin1String( 
"Abstract" ) )
 
  232       description = childElem.firstChild().nodeValue();
 
  234     else if ( childElem.localName() == QLatin1String( 
"Title" ) )
 
  237       label = childElem.firstChild().nodeValue();
 
  239     else if ( childElem.localName().endsWith( QLatin1String( 
"Symbolizer" ) ) )
 
  245     childElem = childElem.nextSiblingElement();
 
  248   if ( layers.isEmpty() )
 
  252   std::unique_ptr< QgsSymbol > 
symbol;
 
  256       symbol = std::make_unique< QgsLineSymbol >( layers );
 
  260       symbol = std::make_unique< QgsFillSymbol >( layers );
 
  264       symbol = std::make_unique< QgsMarkerSymbol >( layers );
 
  268       QgsDebugMsg( QStringLiteral( 
"invalid geometry type: found %1" ).arg( geomType ) );
 
  279   rendererElem.setAttribute( QStringLiteral( 
"type" ), QStringLiteral( 
"singleSymbol" ) );
 
  280   rendererElem.setAttribute( QStringLiteral( 
"symbollevels" ), ( 
mUsingSymbolLevels ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) ) );
 
  281   rendererElem.setAttribute( QStringLiteral( 
"forceraster" ), ( 
mForceRaster ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) ) );
 
  286   rendererElem.appendChild( symbolsElem );
 
  288   QDomElement rotationElem = doc.createElement( QStringLiteral( 
"rotation" ) );
 
  289   rendererElem.appendChild( rotationElem );
 
  291   QDomElement sizeScaleElem = doc.createElement( QStringLiteral( 
"sizescale" ) );
 
  292   rendererElem.appendChild( sizeScaleElem );
 
  299     QDomElement 
orderBy = doc.createElement( QStringLiteral( 
"orderby" ) );
 
  301     rendererElem.appendChild( 
orderBy );
 
  303   rendererElem.setAttribute( QStringLiteral( 
"enableorderby" ), ( 
mOrderByEnabled ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) ) );
 
  307     QDomElement ddsLegendElem = doc.createElement( QStringLiteral( 
"data-defined-size-legend" ) );
 
  309     rendererElem.appendChild( ddsLegendElem );
 
  338   return QSet< QString >() << QStringLiteral( 
"0" );
 
  350   if ( renderer->
type() == QLatin1String( 
"singleSymbol" ) )
 
  354   else if ( renderer->
type() == QLatin1String( 
"pointDisplacement" ) || renderer->
type() == QLatin1String( 
"pointCluster" ) )
 
  357     if ( pointDistanceRenderer )
 
  360   else if ( renderer->
type() == QLatin1String( 
"invertedPolygonRenderer" ) )
 
  363     if ( invertedPolygonRenderer )
 
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
static QgsDataDefinedSizeLegend * readXml(const QDomElement &elem, const QgsReadWriteContext &context) SIP_FACTORY
Creates instance from given element and returns it (caller takes ownership). Returns nullptr on error...
void updateFromSymbolAndProperty(const QgsMarkerSymbol *symbol, const QgsProperty &ddSize)
Updates the list of classes, source symbol and title label from given symbol and property.
QgsLegendSymbolList legendSymbolList() const
Generates legend symbol items according to the configuration.
void setOrderBy(const QgsFeatureRequest::OrderBy &orderBy)
Define the order in which features shall be processed by this renderer.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
void setOrderByEnabled(bool enabled)
Sets whether custom ordering should be applied before features are processed by this renderer.
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.
bool orderByEnabled() const
Returns whether custom ordering will be applied before features are processed by this renderer.
static void convertSymbolRotation(QgsSymbol *symbol, const QString &field)
QgsFeatureRequest::OrderBy mOrderBy
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
static void convertSymbolSizeScale(QgsSymbol *symbol, Qgis::ScaleMethod method, const QString &field)
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...
Container of fields for a vector layer.
QgsInvertedPolygonRenderer is a polygon-only feature renderer used to display features inverted,...
The class stores information about one class/rule of a vector layer renderer in a unified way that ca...
A marker symbol type, for rendering Point and MultiPoint geometries.
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
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.
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
A store for object properties.
bool isActive() const
Returns whether the property is currently active.
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.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
store renderer info to XML element
QgsSymbol * symbol() const
Returns the symbol which will be rendered for every feature.
void setSymbol(QgsSymbol *s)
Sets the symbol which will be rendered for every feature.
std::unique_ptr< QgsSymbol > mSymbol
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
void setLegendSymbolItem(const QString &key, QgsSymbol *symbol) override
Sets the symbol to be used for a legend symbol item.
static QgsFeatureRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates a new single symbol renderer from an XML element, using the supplied read/write context.
~QgsSingleSymbolRenderer() override
QSet< QString > legendKeysForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns legend keys matching a specified feature.
void setDataDefinedSizeLegend(QgsDataDefinedSizeLegend *settings)
Configures appearance of legend when renderer is configured to use data-defined size for marker symbo...
static QgsFeatureRenderer * createFromSld(QDomElement &element, QgsWkbTypes::GeometryType geomType)
Creates a new single symbol renderer from an SLD element.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsLegendSymbolList legendSymbolItems() const override
Returns a list of symbology items for the legend.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
QgsDataDefinedSizeLegend * dataDefinedSizeLegend() const
Returns configuration of appearance of legend when using data-defined size for marker symbols.
std::unique_ptr< QgsDataDefinedSizeLegend > mDataDefinedSizeLegend
QgsSymbol * originalSymbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
Returns symbol for feature.
static QgsSingleSymbolRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
Creates a new single symbol renderer from an existing renderer.
QgsSymbol * symbolForFeature(const QgsFeature &feature, QgsRenderContext &context) const override
To be overridden.
void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const override
used from subclasses to create SLD Rule elements following SLD v1.1 specs
QgsSingleSymbolRenderer * clone() const override
Create a deep copy of this renderer.
QgsSymbolList symbols(QgsRenderContext &context) const override
Returns list of symbols used by the renderer.
QString dump() const override
Returns debug information about this renderer.
QgsSingleSymbolRenderer(QgsSymbol *symbol)
Constructor for QgsSingleSymbolRenderer.
An interface for classes which can visit style entity (e.g.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
A symbol entity for QgsStyle databases.
static void applyScaleDependency(QDomDocument &doc, QDomElement &ruleElem, QVariantMap &props)
Checks if the properties contain scaleMinDenom and scaleMaxDenom, if available, they are added into t...
static Qgis::ScaleMethod decodeScaleMethod(const QString &str)
Decodes a symbol scale method from a string.
static bool createSymbolLayerListFromSld(QDomElement &element, QgsWkbTypes::GeometryType geomType, QList< QgsSymbolLayer * > &layers)
Creates a symbol layer list from a DOM element.
static void clearSymbolMap(QgsSymbolMap &symbols)
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.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QList< QgsLegendSymbolItem > QgsLegendSymbolList
#define RENDERER_TAG_NAME
QMap< QString, QgsSymbol * > QgsSymbolMap
QList< QgsSymbol * > QgsSymbolList
QList< QgsSymbolLayer * > QgsSymbolLayerList
Contains information relating to the style entity currently being visited.