QGIS API Documentation  2.99.0-Master (b681b7b)
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 "qgis_core.h"
19 #include <QPen>
20 #include <QBrush>
21 #include "qgsexpression.h" //for QMap with QgsExpression
22 
23 class QPainter;
24 class QPointF;
25 class QgsDiagramSettings;
27 class QgsFeature;
28 class QgsRenderContext;
30 class QgsFields;
31 class QgsAttributes;
32 
33 
36 class CORE_EXPORT QgsDiagram
37 {
38  public:
39  virtual ~QgsDiagram() { clearCache(); }
40 
43  virtual QgsDiagram* clone() const = 0;
44 
45  void clearCache();
46 
52  QgsExpression* getExpression( const QString& expression, const QgsExpressionContext& context );
53 
55  virtual void renderDiagram( const QgsFeature& feature, QgsRenderContext& c, const QgsDiagramSettings& s, QPointF position ) = 0;
56 
60  virtual QString diagramName() const = 0;
62  virtual QSizeF diagramSize( const QgsAttributes& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s ) = 0;
64  virtual QSizeF diagramSize( const QgsFeature& feature, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) = 0;
65 
72  virtual double legendSize( double value, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) const = 0;
73 
74  protected:
75  QgsDiagram();
76  QgsDiagram( const QgsDiagram& other );
77 
83  void setPenWidth( QPen& pen, const QgsDiagramSettings& s, const QgsRenderContext& c );
84 
92  QSizeF sizePainterUnits( QSizeF size, const QgsDiagramSettings& s, const QgsRenderContext& c );
93 
101  double sizePainterUnits( double l, const QgsDiagramSettings& s, const QgsRenderContext& c );
102 
109  QFont scaledFont( const QgsDiagramSettings& s, const QgsRenderContext& c );
110 
117  QSizeF sizeForValue( double value, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is ) const;
118 
119  private:
120  QMap<QString, QgsExpression*> mExpressions;
121 };
122 
123 #endif // QGSDIAGRAM_H
Class for parsing and evaluation of expressions (formerly called "search strings").
virtual ~QgsDiagram()
Definition: qgsdiagram.h:39
Container of fields for a vector layer.
Definition: qgsfields.h:39
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:136
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Base class for all diagram types.
Definition: qgsdiagram.h:36
Additional diagram settings for interpolated size rendering.
Contains information about the context of a rendering operation.
A vector of attributes.
Definition: qgsfeature.h:56
Stores the settings for rendering a single diagram.