QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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.h"
22#include "qgis_core.h"
24
31{
32 public:
42
47 QgsPointDisplacementRenderer( const QString &labelAttributeName = QString() );
48
49 Qgis::FeatureRendererFlags flags() const override;
51 void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
52 void stopRender( QgsRenderContext &context ) override;
53 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
54 QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
55 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
56
58 static QgsFeatureRenderer *create( QDomElement &symbologyElem, const QgsReadWriteContext &context ) SIP_FACTORY;
59
66 void setCircleWidth( double width ) { mCircleWidth = width; }
67
73 double circleWidth() const { return mCircleWidth; }
74
81 void setCircleColor( const QColor &color ) { mCircleColor = color; }
82
88 QColor circleColor() const { return mCircleColor; }
89
95 void setCircleRadiusAddition( double distance ) { mCircleRadiusAddition = distance; }
96
101 double circleRadiusAddition() const { return mCircleRadiusAddition; }
102
109 void setLabelDistanceFactor( double factor ) { mLabelDistanceFactor = factor; }
110
116 double labelDistanceFactor() const { return mLabelDistanceFactor; }
117
122 Placement placement() const { return mPlacement; }
123
129 void setPlacement( Placement placement ) { mPlacement = placement; }
130
135 QgsMarkerSymbol *centerSymbol();
136
142 void setCenterSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
143
148 static QgsPointDisplacementRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
149
150 private:
151#ifdef SIP_RUN
154#endif
155
157 std::unique_ptr< QgsMarkerSymbol > mCenterSymbol;
158
160 Placement mPlacement = Ring;
161
163 double mCircleWidth = 0.4;
165 QColor mCircleColor;
167 double mCircleRadiusAddition = 0;
169 double mLabelDistanceFactor = 0.5;
170
171 void drawGroup( QPointF centerPoint, QgsRenderContext &context, const QgsPointDistanceRenderer::ClusteredGroup &group ) const override SIP_FORCE;
172
173 //helper functions
174 void calculateSymbolAndLabelPositions(
175 QgsSymbolRenderContext &symbolContext,
176 QPointF centerPoint,
177 int nPosition,
178 double symbolDiagonal,
179 QList<QPointF> &symbolPositions,
180 QList<QPointF> &labelShifts,
181 double &circleRadius,
182 double &gridRadius,
183 int &gridSize,
184 QVector<double> &diagonals
185 ) const;
186 void drawCircle( double radiusPainterUnits, QgsSymbolRenderContext &context, QPointF centerPoint, int nSymbols ) const;
187 void drawSymbols( const ClusteredGroup &group, QgsRenderContext &context, const QList<QPointF> &symbolPositions ) const;
188 void drawGrid( int gridSizeUnits, QgsSymbolRenderContext &context, QList<QPointF> pointSymbolPositions, int nSymbols ) const;
189 void centralizeGrid( QList<QPointF> &pointSymbolPositions, double radius, int size ) const;
190};
191
192#endif // QGSPOINTDISPLACEMENTRENDERER_H
QFlags< FeatureRendererFlag > FeatureRendererFlags
Flags controlling behavior of vector feature renderers.
Definition qgis.h:864
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.
QgsPointDisplacementRenderer(const QString &labelAttributeName=QString())
Constructor for QgsPointDisplacementRenderer.
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.
@ Grid
Place points in a grid 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.
void setCircleWidth(double width)
Sets the line width for the displacement group circle.
double labelDistanceFactor() const
Returns the factor for label distance from the symbol.
QgsPointDistanceRenderer(const QString &rendererName, const QString &labelAttributeName=QString())
Constructor for QgsPointDistanceRenderer.
QList< QgsPointDistanceRenderer::GroupedFeature > ClusteredGroup
A group of clustered points (ie features within the distance tolerance).
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
Encapsulates the context in which a symbol is being rendered.
#define SIP_FORCE
Definition qgis_sip.h:138
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83