QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
34 mClusterSymbol->setSize( 4 );
35 mClusterSymbol->setColor( QColor( 245, 75, 80 ) );
39 fm->
setColor( QColor( 255, 255, 255 ) );
43 mClusterSymbol->insertSymbolLayer( 1, fm );
65 void QgsPointClusterRenderer::drawGroup( QPointF centerPoint,
QgsRenderContext &context,
const ClusteredGroup &group )
const
67 if ( group.size() > 1 )
69 mClusterSymbol->renderPoint( centerPoint, &( group.at( 0 ).feature ), context, -1,
false );
76 symbol->
renderPoint( centerPoint, &( group.at( 0 ).feature ), context, -1, group.at( 0 ).isSelected );
85 mClusterSymbol->startRender( context, fields );
95 mClusterSymbol->stopRender( context );
102 r->
setTolerance( symbologyElem.attribute( QStringLiteral(
"tolerance" ), QStringLiteral(
"0.00001" ) ).toDouble() );
107 QDomElement embeddedRendererElem = symbologyElem.firstChildElement( QStringLiteral(
"renderer-v2" ) );
108 if ( !embeddedRendererElem.isNull() )
114 const QDomElement centerSymbolElem = symbologyElem.firstChildElement( QStringLiteral(
"symbol" ) );
115 if ( !centerSymbolElem.isNull() )
117 r->
setClusterSymbol( QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( centerSymbolElem, context ) );
124 return mClusterSymbol.get();
130 rendererElement.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"pointCluster" ) );
131 rendererElement.setAttribute( QStringLiteral(
"tolerance" ), QString::number(
mTolerance ) );
137 const QDomElement embeddedRendererElem =
mRenderer->save( doc, context );
138 rendererElement.appendChild( embeddedRendererElem );
140 if ( mClusterSymbol )
143 rendererElement.appendChild( centerSymbolElem );
148 return rendererElement;
154 if ( mClusterSymbol )
155 attr.unite( mClusterSymbol->usedAttributes( context ) );
164 if ( mClusterSymbol )
176 mClusterSymbol.reset( symbol );
181 if ( renderer->
type() == QLatin1String(
"pointCluster" ) )
185 else if ( renderer->
type() == QLatin1String(
"singleSymbol" ) ||
186 renderer->
type() == QLatin1String(
"categorizedSymbol" ) ||
187 renderer->
type() == QLatin1String(
"graduatedSymbol" ) ||
188 renderer->
type() == QLatin1String(
"RuleRenderer" ) )
193 return pointRenderer;
195 else if ( renderer->
type() == QLatin1String(
"pointDisplacement" ) )
207 return pointRenderer;
void copyRendererData(QgsFeatureRenderer *destRenderer) const
Clones generic renderer data to another renderer.
virtual void setColor(const QColor &color)
Sets the "representative" color for the symbol layer.
QgsUnitTypes::RenderUnit mToleranceUnit
Unit for distance tolerance.
The class is used as a container of context for various read/write operations on other objects.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
A symbol entity for QgsStyle databases.
Container of fields for a vector layer.
Contains information about the context of a rendering operation.
static QgsPointClusterRenderer * convertFromRenderer(const QgsFeatureRenderer *renderer)
Creates a QgsPointClusterRenderer from an existing renderer.
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
static QgsFeatureRenderer * create(QDomElement &symbologyElem, const QgsReadWriteContext &context)
Creates a renderer from XML element.
const QgsFeatureRenderer * embeddedRenderer() const override
Returns the current embedded renderer (subrenderer) for this feature renderer.
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
QFont mLabelFont
Label font.
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) override
Stores renderer properties to an XML element.
const QgsMapUnitScale & toleranceMapUnitScale() const
Returns the map unit scale object for the distance tolerance.
QgsPointClusterRenderer * clone() const override
Create a deep copy of this renderer.
Contains information relating to the style entity currently being visited.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
double mMinLabelScale
Maximum scale denominator for label display. A zero value indicates no scale limitation.
QgsMarkerSymbol * clusterSymbol()
Returns the symbol used for rendering clustered groups (but not ownership of the symbol).
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
std::unique_ptr< QgsFeatureRenderer > mRenderer
Embedded base renderer. This can be used for rendering individual, isolated points.
A renderer that automatically clusters points with the same geographic position.
QgsUnitTypes::RenderUnit toleranceUnit() const
Returns the units for the tolerance distance.
QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Returns a list of attributes required by this renderer.
QgsMarkerSymbol * centerSymbol()
Returns the symbol for the center of a displacement group (but not ownership of the symbol).
@ PropertyCharacter
Character, eg for font marker symbol layers.
void setLabelColor(const QColor &color)
Sets the color to use for for labeling points.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
void stopRender(QgsRenderContext &context)
Ends the rendering process.
A marker symbol type, for rendering Point and MultiPoint geometries.
void saveRendererData(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context)
Saves generic renderer data into the specified element.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
#define RENDERER_TAG_NAME
QColor mLabelColor
Label text color.
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
void setEmbeddedRenderer(QgsFeatureRenderer *r) override
Sets an embedded renderer (subrenderer) for this feature renderer.
QgsMapUnitScale mToleranceMapUnitScale
Map unit scale for distance tolerance.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
QgsPointClusterRenderer()
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
void setToleranceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale object for the distance tolerance.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
double tolerance() const
Returns the tolerance distance for grouping points.
void setToleranceUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the tolerance distance.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
A renderer that automatically displaces points with the same geographic location.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.
void setLabelFont(const QFont &font)
Sets the font used for labeling points.
void setMinimumLabelScale(double scale)
Sets the minimum map scale (i.e.
void setTolerance(double distance)
Sets the tolerance distance for grouping points.
virtual bool visit(const QgsStyleEntityVisitorInterface::StyleLeaf &entity)
Called when the visitor will visit a style entity.
virtual void setSize(double size)
Sets the symbol size.
void setClusterSymbol(QgsMarkerSymbol *symbol)
Sets the symbol for rendering clustered groups.
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
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 QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
double mTolerance
Distance tolerance. Points that are closer together than this distance are considered clustered.
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.
void stopRender(QgsRenderContext &context) override
Must be called when a render cycle has finished, to allow the renderer to clean up.