QGIS API Documentation  2.99.0-Master (37c43df)
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 
22 
28 {
29  public:
30 
33  enum Placement
34  {
35  Ring,
36  ConcentricRings
37  };
38 
42  QgsPointDisplacementRenderer( const QString& labelAttributeName = QString() );
43 
44  QgsPointDisplacementRenderer* clone() const override;
45  virtual void startRender( QgsRenderContext& context, const QgsFields& fields ) override;
46  void stopRender( QgsRenderContext& context ) override;
47  QDomElement save( QDomDocument& doc ) override;
48  virtual QSet<QString> usedAttributes() const override;
49 
51  static QgsFeatureRenderer* create( QDomElement& symbologyElem );
52 
58  void setCircleWidth( double width ) { mCircleWidth = width; }
59 
64  double circleWidth() const { return mCircleWidth; }
65 
71  void setCircleColor( const QColor& color ) { mCircleColor = color; }
72 
77  QColor circleColor() const { return mCircleColor; }
78 
83  void setCircleRadiusAddition( double distance ) { mCircleRadiusAddition = distance; }
84 
88  double circleRadiusAddition() const { return mCircleRadiusAddition; }
89 
94  Placement placement() const { return mPlacement; }
95 
101  void setPlacement( Placement placement ) { mPlacement = placement; }
102 
106  QgsMarkerSymbol* centerSymbol();
107 
112  void setCenterSymbol( QgsMarkerSymbol* symbol );
113 
118  static QgsPointDisplacementRenderer* convertFromRenderer( const QgsFeatureRenderer *renderer );
119 
120  private:
121 
123  QScopedPointer< QgsMarkerSymbol > mCenterSymbol;
124 
126  Placement mPlacement;
127 
129  double mCircleWidth;
131  QColor mCircleColor;
133  double mCircleRadiusAddition;
134 
135  virtual void drawGroup( QPointF centerPoint, QgsRenderContext& context, const QgsPointDistanceRenderer::ClusteredGroup& group ) override;
136 
137  //helper functions
138  void calculateSymbolAndLabelPositions( QgsSymbolRenderContext &symbolContext, QPointF centerPoint, int nPosition, double symbolDiagonal, QList<QPointF>& symbolPositions, QList<QPointF>& labelShifts , double &circleRadius ) const;
139  void drawCircle( double radiusPainterUnits, QgsSymbolRenderContext& context, QPointF centerPoint, int nSymbols );
140  void drawSymbols( const ClusteredGroup& group, QgsRenderContext& context, const QList<QPointF>& symbolPositions );
141 };
142 
143 #endif // QGSPOINTDISPLACEMENTRENDERER_H
An abstract base class for distance based point renderers (eg 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:36
void stopRender(QgsRenderContext &context) override
Needs to be called when a render cycle has finished to clean up.
virtual QSet< QString > usedAttributes() const override
Return a list of attributes required by this renderer.
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.