QGIS API Documentation  2.99.0-Master (b681b7b)
qgstextdiagram.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgstextdiagram.h
3  ---------------------
4  begin : March 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSTEXTDIAGRAM_H
16 #define QGSTEXTDIAGRAM_H
17 
18 #define DIAGRAM_NAME_TEXT "Text"
19 
20 #include "qgis_core.h"
21 #include "qgsdiagram.h"
22 #include <QPen>
23 #include <QBrush>
24 
25 class QPainter;
26 class QPointF;
27 class QgsDiagramSettings;
29 class QgsFeature;
30 class QgsRenderContext;
31 
35 class CORE_EXPORT QgsTextDiagram: public QgsDiagram
36 {
37  public:
38  enum Shape
39  {
40  Circle = 0,
42  Triangle
43  };
44 
46  {
47  Horizontal = 0,
48  Vertical
49  };
50 
52  virtual QgsTextDiagram* clone() const override;
53 
54  void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QgsDiagramSettings& s, QPointF position ) override;
55 
56  QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s ) override;
57  QSizeF diagramSize( const QgsFeature& feature, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) override;
58  double legendSize( double value, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) const override;
59 
60  QString diagramName() const override { return DIAGRAM_NAME_TEXT; }
61 
62  private:
63  Orientation mOrientation;
64  Shape mShape;
65  QBrush mBrush; //transparent brush
66  QPen mPen;
67 
70  void lineEllipseIntersection( QPointF lineStart, QPointF lineEnd, QPointF ellipseMid, double r1, double r2, QList<QPointF>& result ) const;
71 };
72 
73 #endif // QGSTEXTDIAGRAM_H
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:136
virtual double legendSize(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is) const =0
Returns the size of the legend item for the diagram corresponding to a specified value.
virtual void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position)=0
Draws the diagram at the given position (in pixel coordinates)
virtual QSizeF diagramSize(const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s)=0
Returns the size in map units the diagram will use to render.
Base class for all diagram types.
Definition: qgsdiagram.h:36
virtual QgsDiagram * clone() const =0
Returns an instance that is equivalent to this one.
QString diagramName() const override
Get a descriptive name for this diagram type.
Additional diagram settings for interpolated size rendering.
Contains information about the context of a rendering operation.
#define DIAGRAM_NAME_TEXT
A vector of attributes.
Definition: qgsfeature.h:56
Stores the settings for rendering a single diagram.