QGIS API Documentation  2.99.0-Master (a411669)
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 
37  enum Placement
38  {
39  Ring,
40  ConcentricRings
41  };
42 
47  QgsPointDisplacementRenderer( const QString &labelAttributeName = QString() );
48 
50  virtual void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
51  void stopRender( QgsRenderContext &context ) override;
52  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
53  virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
54 
56  static QgsFeatureRenderer *create( QDomElement &symbologyElem, const QgsReadWriteContext &context ) SIP_FACTORY;
57 
64  void setCircleWidth( double width ) { mCircleWidth = width; }
65 
71  double circleWidth() const { return mCircleWidth; }
72 
79  void setCircleColor( const QColor &color ) { mCircleColor = color; }
80 
86  QColor circleColor() const { return mCircleColor; }
87 
93  void setCircleRadiusAddition( double distance ) { mCircleRadiusAddition = distance; }
94 
99  double circleRadiusAddition() const { return mCircleRadiusAddition; }
100 
106  Placement placement() const { return mPlacement; }
107 
114  void setPlacement( Placement placement ) { mPlacement = placement; }
115 
120  QgsMarkerSymbol *centerSymbol();
121 
127  void setCenterSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
128 
134  static QgsPointDisplacementRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
135 
136  private:
137 #ifdef SIP_RUN
140 #endif
141 
143  std::unique_ptr< QgsMarkerSymbol > mCenterSymbol;
144 
146  Placement mPlacement = Ring;
147 
149  double mCircleWidth = 0.4;
151  QColor mCircleColor;
153  double mCircleRadiusAddition = 0;
154 
155  virtual void drawGroup( QPointF centerPoint, QgsRenderContext &context, const QgsPointDistanceRenderer::ClusteredGroup &group ) override SIP_FORCE;
156 
157  //helper functions
158  void calculateSymbolAndLabelPositions( QgsSymbolRenderContext &symbolContext, QPointF centerPoint, int nPosition, double symbolDiagonal, QList<QPointF> &symbolPositions, QList<QPointF> &labelShifts, double &circleRadius ) const;
159  void drawCircle( double radiusPainterUnits, QgsSymbolRenderContext &context, QPointF centerPoint, int nSymbols );
160  void drawSymbols( const ClusteredGroup &group, QgsRenderContext &context, const QList<QPointF> &symbolPositions );
161 };
162 
163 #endif // QGSPOINTDISPLACEMENTRENDERER_H
An abstract base class for distance based point renderers (e.g., clusterer and displacement renderers...
The class is used as a container of context for various read/write operations on other objects...
Placement
Placement methods for dispersing points.
double circleRadiusAddition() const
Returns the factor for increasing the ring size of displacement groups.
Container of fields for a vector layer.
Definition: qgsfields.h:42
void setCircleColor(const QColor &color)
Sets the color used for drawing the displacement group circle.
#define SIP_FORCE
Definition: qgis_sip.h:124
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QColor circleColor() const
Returns the color used for drawing the displacement group circle.
void setPlacement(Placement placement)
Sets the placement method used for dispersing the points.
#define SIP_FACTORY
Definition: qgis_sip.h:69
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.
QList< QgsPointDistanceRenderer::GroupedFeature > ClusteredGroup
A group of clustered points (ie features within the distance tolerance).
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.
double circleWidth() const
Returns the line width for the displacement group circle in mm.