QGIS API Documentation  2.99.0-Master (75367e4)
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"
23 
29 {
30  public:
31 
34  enum Placement
35  {
36  Ring,
37  ConcentricRings
38  };
39 
43  QgsPointDisplacementRenderer( const QString& labelAttributeName = QString() );
44 
45  QgsPointDisplacementRenderer* clone() const override;
46  virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
47  void stopRender( QgsRenderContext& context ) override;
48  QDomElement save( QDomDocument& doc ) override;
49  virtual QSet<QString> usedAttributes( const QgsRenderContext& context ) const override;
50 
52  static QgsFeatureRenderer* create( QDomElement& symbologyElem );
53 
59  void setCircleWidth( double width ) { mCircleWidth = width; }
60 
65  double circleWidth() const { return mCircleWidth; }
66 
72  void setCircleColor( const QColor& color ) { mCircleColor = color; }
73 
78  QColor circleColor() const { return mCircleColor; }
79 
84  void setCircleRadiusAddition( double distance ) { mCircleRadiusAddition = distance; }
85 
89  double circleRadiusAddition() const { return mCircleRadiusAddition; }
90 
95  Placement placement() const { return mPlacement; }
96 
102  void setPlacement( Placement placement ) { mPlacement = placement; }
103 
107  QgsMarkerSymbol* centerSymbol();
108 
113  void setCenterSymbol( QgsMarkerSymbol* symbol );
114 
119  static QgsPointDisplacementRenderer* convertFromRenderer( const QgsFeatureRenderer *renderer );
120 
121  private:
122 
124  std::unique_ptr< QgsMarkerSymbol > mCenterSymbol;
125 
127  Placement mPlacement;
128 
130  double mCircleWidth;
132  QColor mCircleColor;
134  double mCircleRadiusAddition;
135 
136  virtual void drawGroup( QPointF centerPoint, QgsRenderContext& context, const QgsPointDistanceRenderer::ClusteredGroup& group ) override;
137 
138  //helper functions
139  void calculateSymbolAndLabelPositions( QgsSymbolRenderContext &symbolContext, QPointF centerPoint, int nPosition, double symbolDiagonal, QList<QPointF>& symbolPositions, QList<QPointF>& labelShifts , double &circleRadius ) const;
140  void drawCircle( double radiusPainterUnits, QgsSymbolRenderContext& context, QPointF centerPoint, int nSymbols );
141  void drawSymbols( const ClusteredGroup& group, QgsRenderContext& context, const QList<QPointF>& symbolPositions );
142 };
143 
144 #endif // QGSPOINTDISPLACEMENTRENDERER_H
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
Placement
Placement methods for dispersing points.
QList< GroupedFeature > ClusteredGroup
A group of clustered points (ie features within the distance tolerance).
double circleRadiusAddition() const
Returns the factor for increasing the ring size of displacement groups.
Container of fields for a vector layer.
Definition: qgsfields.h:39
void stopRender(QgsRenderContext &context) override
Needs to be called when a render cycle has finished to clean up.
void setCircleColor(const QColor &color)
Sets the color used for drawing the displacement group circle.
QColor circleColor() const
Returns the color used for drawing the displacement group circle.
virtual QDomElement save(QDomDocument &doc)
store renderer info to XML element
void setPlacement(Placement placement)
Sets the placement method used for dispersing the points.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields) override
Needs to be called when a new render cycle is started.
Place points in a single ring around group.
A renderer that automatically displaces points with the same geographic location. ...
Contains information about the context of a rendering operation.
Placement placement() const
Returns the placement method used for dispersing the points.
void setCircleRadiusAddition(double distance)
Sets a factor for increasing the ring size of displacement groups.
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
void setCircleWidth(double width)
Sets the line width for the displacement group circle.
double circleWidth() const
Returns the line width for the displacement group circle in mm.
virtual QSet< QString > usedAttributes(const QgsRenderContext &context) const override
Return a list of attributes required by this renderer.