31 mClusterSymbol->setSize( 4 );
32 mClusterSymbol->setColor( QColor( 245, 75, 80 ) );
36 fm->
setColor( QColor( 255, 255, 255 ) );
40 mClusterSymbol->insertSymbolLayer( 1, fm );
64 if ( group.size() > 1 )
66 mClusterSymbol->renderPoint( centerPoint, &( group.at( 0 ).feature ), context, -1,
false );
73 symbol->
renderPoint( centerPoint, &( group.at( 0 ).feature ), context, -1, group.at( 0 ).isSelected );
82 mClusterSymbol->startRender( context, fields );
92 mClusterSymbol->stopRender( context );
99 r->
setTolerance( symbologyElem.attribute( QStringLiteral(
"tolerance" ), QStringLiteral(
"0.00001" ) ).toDouble() );
104 QDomElement embeddedRendererElem = symbologyElem.firstChildElement( QStringLiteral(
"renderer-v2" ) );
105 if ( !embeddedRendererElem.isNull() )
111 QDomElement centerSymbolElem = symbologyElem.firstChildElement( QStringLiteral(
"symbol" ) );
112 if ( !centerSymbolElem.isNull() )
114 r->
setClusterSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( centerSymbolElem, context ) );
121 return mClusterSymbol.get();
127 rendererElement.setAttribute( QStringLiteral(
"forceraster" ), (
mForceRaster ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
128 rendererElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"pointCluster" ) );
129 rendererElement.setAttribute( QStringLiteral(
"tolerance" ), QString::number(
mTolerance ) );
135 QDomElement embeddedRendererElem =
mRenderer->save( doc, context );
136 rendererElement.appendChild( embeddedRendererElem );
138 if ( mClusterSymbol )
141 rendererElement.appendChild( centerSymbolElem );
149 QDomElement
orderBy = doc.createElement( QStringLiteral(
"orderby" ) );
151 rendererElement.appendChild( orderBy );
153 rendererElement.setAttribute( QStringLiteral(
"enableorderby" ), (
mOrderByEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) ) );
155 return rendererElement;
161 if ( mClusterSymbol )
162 attr.unite( mClusterSymbol->usedAttributes( context ) );
168 mClusterSymbol.reset( symbol );
173 if ( renderer->
type() == QLatin1String(
"pointCluster" ) )
177 else if ( renderer->
type() == QLatin1String(
"singleSymbol" ) ||
178 renderer->
type() == QLatin1String(
"categorizedSymbol" ) ||
179 renderer->
type() == QLatin1String(
"graduatedSymbol" ) ||
180 renderer->
type() == QLatin1String(
"RuleRenderer" ) )
184 return pointRenderer;
186 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) )
195 if ( const_cast< QgsPointDisplacementRenderer * >( displacementRenderer )->centerSymbol() )
196 pointRenderer->
setClusterSymbol( const_cast< QgsPointDisplacementRenderer * >( displacementRenderer )->centerSymbol()->clone() );
197 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.
QgsUnitTypes::RenderUnit mToleranceUnit
Unit for distance tolerance.
QgsFeatureRequest::OrderBy mOrderBy
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
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsPaintEffect * mPaintEffect
QgsUnitTypes::RenderUnit toleranceUnit() const
Returns the units for the tolerance distance.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
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)
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
void setSize(double size)
Sets the symbol size.
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.
void CORE_EXPORT save(QDomElement &elem) const
Serialize to XML.
static QDomElement saveSymbol(const QString &symbolName, QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
void setFontFamily(const QString &family)
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.
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.