QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsdiagram.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdiagram.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 QGSDIAGRAM_H
16 #define QGSDIAGRAM_H
17 
18 #include "qgsfeature.h"
19 #include <QPen>
20 #include <QBrush>
21 
22 class QPainter;
23 class QPointF;
24 class QgsDiagramSettings;
26 
27 class QgsRenderContext;
28 
29 class QgsExpression;
30 
31 
32 
34 class CORE_EXPORT QgsDiagram
35 {
36  public:
37  virtual ~QgsDiagram() { clearCache(); }
40  virtual QgsDiagram* clone() const = 0;
41 
42  void clearCache();
43  QgsExpression* getExpression( const QString& expression, const QgsFields* fields );
45  virtual Q_DECL_DEPRECATED void renderDiagram( const QgsAttributes& att, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position );
47  virtual void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QgsDiagramSettings& s, const QPointF& position ) = 0;
48  virtual QString diagramName() const = 0;
50  virtual QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s ) = 0;
52  virtual Q_DECL_DEPRECATED QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is );
54  virtual QSizeF diagramSize( const QgsFeature& feature, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) = 0;
55 
56  protected:
57  QgsDiagram();
58  QgsDiagram( const QgsDiagram& other );
59 
65  void setPenWidth( QPen& pen, const QgsDiagramSettings& s, const QgsRenderContext& c );
66 
74  QSizeF sizePainterUnits( const QSizeF& size, const QgsDiagramSettings& s, const QgsRenderContext& c );
75 
83  float sizePainterUnits( float l, const QgsDiagramSettings& s, const QgsRenderContext& c );
84 
91  QFont scaledFont( const QgsDiagramSettings& s, const QgsRenderContext& c );
92 
93  private:
94  QMap<QString, QgsExpression*> mExpressions;
95 };
96 
97 #endif // QGSDIAGRAM_H