QGIS API Documentation  2.99.0-Master (7d4f81d)
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 
30 {
31  public:
32 
35  enum Placement
36  {
37  Ring,
38  ConcentricRings
39  };
40 
44  QgsPointDisplacementRenderer( const QString &labelAttributeName = QString() );
45 
47  virtual void startRender( QgsRenderContext &context, const QgsFields &fields ) override;
48  void stopRender( QgsRenderContext &context ) override;
49  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override;
50  virtual QSet<QString> usedAttributes( const QgsRenderContext &context ) const override;
51 
53  static QgsFeatureRenderer *create( QDomElement &symbologyElem, const QgsReadWriteContext &context ) SIP_FACTORY;
54 
60  void setCircleWidth( double width ) { mCircleWidth = width; }
61 
66  double circleWidth() const { return mCircleWidth; }
67 
73  void setCircleColor( const QColor &color ) { mCircleColor = color; }
74 
79  QColor circleColor() const { return mCircleColor; }
80 
85  void setCircleRadiusAddition( double distance ) { mCircleRadiusAddition = distance; }
86 
90  double circleRadiusAddition() const { return mCircleRadiusAddition; }
91 
96  Placement placement() const { return mPlacement; }
97 
103  void setPlacement( Placement placement ) { mPlacement = placement; }
104 
108  QgsMarkerSymbol *centerSymbol();
109 
114  void setCenterSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
115 
120  static QgsPointDisplacementRenderer *convertFromRenderer( const QgsFeatureRenderer *renderer ) SIP_FACTORY;
121 
122  private:
123 #ifdef SIP_RUN
126 #endif
127 
129  std::unique_ptr< QgsMarkerSymbol > mCenterSymbol;
130 
132  Placement mPlacement;
133 
135  double mCircleWidth;
137  QColor mCircleColor;
139  double mCircleRadiusAddition;
140 
141  virtual void drawGroup( QPointF centerPoint, QgsRenderContext &context, const QgsPointDistanceRenderer::ClusteredGroup &group ) override SIP_FORCE;
142 
143  //helper functions
144  void calculateSymbolAndLabelPositions( QgsSymbolRenderContext &symbolContext, QPointF centerPoint, int nPosition, double symbolDiagonal, QList<QPointF> &symbolPositions, QList<QPointF> &labelShifts, double &circleRadius ) const;
145  void drawCircle( double radiusPainterUnits, QgsSymbolRenderContext &context, QPointF centerPoint, int nSymbols );
146  void drawSymbols( const ClusteredGroup &group, QgsRenderContext &context, const QList<QPointF> &symbolPositions );
147 };
148 
149 #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:41
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.