QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgspointdisplacementrenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspointdisplacementrenderer.cpp
3 --------------------------------
4 begin : January 26, 2010
5 copyright : (C) 2010 by Marco Hugentobler
6 email : marco at hugis dot net
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSPOINTDISPLACEMENTRENDERER_H
19#define QGSPOINTDISPLACEMENTRENDERER_H
20
21#include "qgis_core.h"
22#include "qgis.h"
24
31{
32 public:
33
38 {
41 Grid
42 };
43
48 QgsPointDisplacementRenderer( const QString &labelAttributeName = QString() );
49
50 Qgis::FeatureRendererFlags flags() const override;
52 void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
53 void stopRender( QgsRenderContext &context ) override;
54 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
55 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
56 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
57
59 static QgsFeatureRenderer *create( QDomElement &symbologyElem, const QgsReadWriteContext &context ) SIP_FACTORY;
60
67 void setCircleWidth( double width ) { mCircleWidth = width; }
68
74 double circleWidth() const { return mCircleWidth; }
75
82 void setCircleColor( const QColor &color ) { mCircleColor = color; }
83
89 QColor circleColor() const { return mCircleColor; }
90
96 void setCircleRadiusAddition( double distance ) { mCircleRadiusAddition = distance; }
97
102 double circleRadiusAddition() const { return mCircleRadiusAddition; }
103
110 void setLabelDistanceFactor( double factor ) { mLabelDistanceFactor = factor; }
111
117 double labelDistanceFactor() const { return mLabelDistanceFactor; }
118
123 Placement placement() const { return mPlacement; }
124
130 void setPlacement( Placement placement ) { mPlacement = placement; }
131
136 QgsMarkerSymbol *centerSymbol();
137
143 void setCenterSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
144
149 static QgsPointDisplacementRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
150
151 private:
152#ifdef SIP_RUN
155#endif
156
158 std::unique_ptr< QgsMarkerSymbol > mCenterSymbol;
159
161 Placement mPlacement = Ring;
162
164 double mCircleWidth = 0.4;
166 QColor mCircleColor;
168 double mCircleRadiusAddition = 0;
170 double mLabelDistanceFactor = 0.5;
171
172 void drawGroup( QPointF centerPoint, QgsRenderContext &context, const QgsPointDistanceRenderer::ClusteredGroup &group ) const override SIP_FORCE;
173
174 //helper functions
175 void calculateSymbolAndLabelPositions( QgsSymbolRenderContext &symbolContext, QPointF centerPoint, int nPosition, double symbolDiagonal, QList<QPointF> &symbolPositions, QList<QPointF> &labelShifts, double &circleRadius,
176 double &gridRadius, int &gridSize, QVector<double> &diagonals ) const;
177 void drawCircle( double radiusPainterUnits, QgsSymbolRenderContext &context, QPointF centerPoint, int nSymbols ) const;
178 void drawSymbols( const ClusteredGroup &group, QgsRenderContext &context, const QList<QPointF> &symbolPositions ) const;
179 void drawGrid( int gridSizeUnits, QgsSymbolRenderContext &context,
180 QList<QPointF> pointSymbolPositions, int nSymbols ) const;
181 void centralizeGrid( QList<QPointF> &pointSymbolPositions, double radius, int size ) const;
182};
183
184#endif // QGSPOINTDISPLACEMENTRENDERER_H
QFlags< FeatureRendererFlag > FeatureRendererFlags
Flags controlling behavior of vector feature renderers.
Definition qgis.h:772
Abstract base class for all 2D vector feature renderers.
virtual Qgis::FeatureRendererFlags flags() const
Returns flags associated with the renderer.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
Container of fields for a vector layer.
Definition qgsfields.h:46
A marker symbol type, for rendering Point and MultiPoint geometries.
A renderer that automatically displaces points with the same geographic location.
void setPlacement(Placement placement)
Sets the placement method used for dispersing the points.
void setLabelDistanceFactor(double factor)
Sets a factor for increasing the label distances from the symbol.
void setCircleColor(const QColor &color)
Sets the color used for drawing the displacement group circle.
Placement placement() const
Returns the placement method used for dispersing the points.
double circleWidth() const
Returns the line width for the displacement group circle in mm.
Placement
Placement methods for dispersing points.
@ ConcentricRings
Place points in concentric rings around group.
@ Ring
Place points in a single ring around group.
void setCircleRadiusAddition(double distance)
Sets a factor for increasing the ring size of displacement groups.
double circleRadiusAddition() const
Returns the factor for increasing the ring size of displacement groups.
QColor circleColor() const
Returns the color used for drawing the displacement group circle.
double labelDistanceFactor() const
Returns the factor for label distance from the symbol.
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
QList< QgsPointDistanceRenderer::GroupedFeature > ClusteredGroup
A group of clustered points (ie features within the distance tolerance).
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.
An interface for classes which can visit style entity (e.g.
#define SIP_FORCE
Definition qgis_sip.h:131
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76