QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "qgsdiagram.h"
21 #include "qgsfeature.h"
22 #include <QPen>
23 #include <QBrush>
24 
25 class QPainter;
26 class QPointF;
27 class QgsDiagramSettings;
29 
30 class QgsRenderContext;
31 
32 
33 class CORE_EXPORT QgsTextDiagram: public QgsDiagram
34 {
35  public:
36  enum Shape
37  {
38  Circle = 0,
40  Triangle
41  };
42 
44  {
45  Horizontal = 0,
46  Vertical
47  };
48 
50  ~QgsTextDiagram();
51  virtual QgsDiagram* clone() const override;
52 
53  void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ) override;
54 
55  QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s ) override;
56  QSizeF diagramSize( const QgsFeature& feature, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) override;
57 
58  QString diagramName() const override { return DIAGRAM_NAME_TEXT; }
59 
60  private:
61  Orientation mOrientation;
62  Shape mShape;
63  QBrush mBrush; //transparent brush
64  QPen mPen;
65 
68  void lineEllipseIntersection( const QPointF& lineStart, const QPointF& lineEnd, const QPointF& ellipseMid, double r1, double r2, QList<QPointF>& result ) const;
69 };
70 
71 #endif // QGSTEXTDIAGRAM_H