32 mClusterSymbol->setSize( 4 );
33 mClusterSymbol->setColor( QColor( 245, 75, 80 ) );
37 fm->
setColor( QColor( 255, 255, 255 ) );
41 mClusterSymbol->insertSymbolLayer( 1, fm );
65 if ( group.size() > 1 )
67 mClusterSymbol->renderPoint( centerPoint, &( group.at( 0 ).feature ), context, -1,
false );
74 symbol->
renderPoint( centerPoint, &( group.at( 0 ).feature ), context, -1, group.at( 0 ).isSelected );
83 mClusterSymbol->startRender( context, fields );
93 mClusterSymbol->stopRender( context );
100 r->
setTolerance( symbologyElem.attribute( QStringLiteral(
"tolerance" ), QStringLiteral(
"0.00001" ) ).toDouble() );
105 QDomElement embeddedRendererElem = symbologyElem.firstChildElement( QStringLiteral(
"renderer-v2" ) );
106 if ( !embeddedRendererElem.isNull() )
112 QDomElement centerSymbolElem = symbologyElem.firstChildElement( QStringLiteral(
"symbol" ) );
113 if ( !centerSymbolElem.isNull() )
115 r->
setClusterSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( centerSymbolElem, context ) );
122 return mClusterSymbol.get();
128 rendererElement.setAttribute( QStringLiteral(
"forceraster" ), (
mForceRaster ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
129 rendererElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"pointCluster" ) );
130 rendererElement.setAttribute( QStringLiteral(
"tolerance" ), QString::number(
mTolerance ) );
136 QDomElement embeddedRendererElem =
mRenderer->save( doc, context );
137 rendererElement.appendChild( embeddedRendererElem );
139 if ( mClusterSymbol )
142 rendererElement.appendChild( centerSymbolElem );
150 QDomElement
orderBy = doc.createElement( QStringLiteral(
"orderby" ) );
152 rendererElement.appendChild( orderBy );
154 rendererElement.setAttribute( QStringLiteral(
"enableorderby" ), (
mOrderByEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
156 return rendererElement;
162 if ( mClusterSymbol )
163 attr.unite( mClusterSymbol->usedAttributes( context ) );
172 if ( mClusterSymbol )
184 mClusterSymbol.reset( symbol );
189 if ( renderer->
type() == QLatin1String(
"pointCluster" ) )
193 else if ( renderer->
type() == QLatin1String(
"singleSymbol" ) ||
194 renderer->
type() == QLatin1String(
"categorizedSymbol" ) ||
195 renderer->
type() == QLatin1String(
"graduatedSymbol" ) ||
196 renderer->
type() == QLatin1String(
"RuleRenderer" ) )
200 return pointRenderer;
202 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) )
211 if ( const_cast< QgsPointDisplacementRenderer * >( displacementRenderer )->centerSymbol() )
212 pointRenderer->
setClusterSymbol( const_cast< QgsPointDisplacementRenderer * >( displacementRenderer )->centerSymbol()->clone() );
213 return pointRenderer;
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
The class is used as a container of context for various read/write operations on other objects...
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
A symbol entity for QgsStyle databases.
QgsUnitTypes::RenderUnit mToleranceUnit
Unit for distance tolerance.
QgsFeatureRequest::OrderBy mOrderBy
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
void setClusterSymbol(QgsMarkerSymbol *symbol)
Sets the symbol for rendering clustered groups.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
store renderer info to XML element
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
void setLabelFont(const QFont &font)
Sets the font used for labeling points.
QgsMarkerSymbol * clusterSymbol()
Returns the symbol used for rendering clustered groups (but not ownership of the symbol).
QgsFeatureRequest::OrderBy orderBy() const
Gets the order in which features shall be processed by this renderer.
void setTolerance(double distance)
Sets the tolerance distance for grouping points.
static bool isDefaultStack(QgsPaintEffect *effect)
Tests whether a paint effect matches the default effects stack.
void setLabelColor(const QColor &color)
Sets the color to use for for labeling points.
void setToleranceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the distance tolerance.
void setToleranceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the tolerance distance.
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Container of fields for a vector layer.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
#define RENDERER_TAG_NAME
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsPaintEffect * mPaintEffect
An interface for classes which can visit style entity (e.g.
QgsUnitTypes::RenderUnit toleranceUnit() const
Returns the units for the tolerance distance.
A marker symbol type, for rendering Point and MultiPoint geometries.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
double mMinLabelScale
Maximum scale denominator for label display. A zero value indicates no scale limitation.
virtual void setColor(const QColor &color)
The fill color.
void renderPoint(QPointF point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
Renders the symbol at the specified point, using the given render context.
static QgsPointClusterRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
Creates a QgsPointClusterRenderer from an existing renderer.
QFont mLabelFont
Label font.
double mTolerance
Distance tolerance. Points that are closer together than this distance are considered clustered...
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element
static QgsFeatureRenderer * create(QDomElement &symbologyElem, const QgsReadWriteContext &context)
Creates a renderer from XML element.
A renderer that automatically clusters points with the same geographic position.
QColor mLabelColor
Label text color.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
QgsPointClusterRenderer * clone() const override
Create a deep copy of this renderer.
Character, eg for font marker symbol layers.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
QgsMapUnitScale mToleranceMapUnitScale
Map unit scale for distance tolerance.
double tolerance() const
Returns the tolerance distance for grouping points.
const QgsMapUnitScale & toleranceMapUnitScale() const
Returns the map unit scale object for the distance tolerance.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
A renderer that automatically displaces points with the same geographic location. ...
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
Contains information about the context of a rendering operation.
void setMinimumLabelScale(double scale)
Sets the minimum map scale (i.e.
std::unique_ptr< QgsFeatureRenderer > mRenderer
Embedded base renderer. This can be used for rendering individual, isolated points.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
virtual void setSize(double size)
Sets the symbol size.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
QList< QgsPointDistanceRenderer::GroupedFeature > ClusteredGroup
A group of clustered points (ie features within the distance tolerance).
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QgsPointClusterRenderer()
void setEmbeddedRenderer(QgsFeatureRenderer *r) override
Sets an embedded renderer (subrenderer) for this feature renderer.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
Contains information relating to the style entity currently being visited.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.