QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 "qgis.h"
20 #include <QPen>
21 #include <QBrush>
22 #include "qgsexpression.h" //for QMap with QgsExpression
23 
24 class QPainter;
25 class QPointF;
26 class QgsDiagramSettings;
28 class QgsFeature;
29 class QgsRenderContext;
31 class QgsFields;
32 class QgsAttributes;
33 
34 
38 class CORE_EXPORT QgsDiagram SIP_NODEFAULTCTORS
39 {
40  public:
41 
42 #ifdef SIP_RUN
44  if ( sipCpp->diagramName() == QStringLiteral( "Pie" ) )
45  sipType = sipType_QgsPieDiagram;
46  else if ( sipCpp->diagramName() == QStringLiteral( "Histogram" ) )
47  sipType = sipType_QgsHistogramDiagram;
48  else if ( sipCpp->diagramName() == QStringLiteral( "Text" ) )
49  sipType = sipType_QgsTextDiagram;
50  else if ( sipCpp->diagramName() == QStringLiteral( "Stacked" ) )
51  sipType = sipType_QgsStackedBarDiagram;
52  else
53  sipType = NULL;
54  SIP_END
55 #endif
56 
57  virtual ~QgsDiagram() { clearCache(); }
58 
62  virtual QgsDiagram *clone() const = 0 SIP_FACTORY;
63 
64  void clearCache();
65 
72  QgsExpression *getExpression( const QString &expression, const QgsExpressionContext &context );
73 
75  virtual void renderDiagram( const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position ) = 0;
76 
80  virtual QString diagramName() const = 0;
82  virtual QSizeF diagramSize( const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s ) = 0;
84  virtual QSizeF diagramSize( const QgsFeature &feature, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) = 0;
85 
93  virtual double legendSize( double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) const = 0;
94 
95  protected:
96 
100  QgsDiagram() = default;
101  QgsDiagram( const QgsDiagram &other );
102 
109  void setPenWidth( QPen &pen, const QgsDiagramSettings &s, const QgsRenderContext &c );
110 
119  QSizeF sizePainterUnits( QSizeF size, const QgsDiagramSettings &s, const QgsRenderContext &c );
120 
129  double sizePainterUnits( double l, const QgsDiagramSettings &s, const QgsRenderContext &c );
130 
138  QFont scaledFont( const QgsDiagramSettings &s, const QgsRenderContext &c );
139 
147  QSizeF sizeForValue( double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &is ) const;
148 
149  private:
150  QMap<QString, QgsExpression *> mExpressions;
151  QgsDiagram &operator= ( const QgsDiagram & ) = delete;
152 };
153 
154 #endif // QGSDIAGRAM_H
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
QgsDiagram
Definition: qgsdiagram.h:38
qgsexpression.h
QgsFields
Definition: qgsfields.h:44
qgis.h
QgsRenderContext
Definition: qgsrendercontext.h:57
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
QgsDiagram::~QgsDiagram
virtual ~QgsDiagram()
Definition: qgsdiagram.h:57
QgsDiagramInterpolationSettings
Definition: qgsdiagramrenderer.h:661
SIP_NODEFAULTCTORS
#define SIP_NODEFAULTCTORS
Definition: qgis_sip.h:101
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsAttributes
Definition: qgsattributes.h:57
QgsFeature
Definition: qgsfeature.h:55
QgsExpression
Definition: qgsexpression.h:113
SIP_END
#define SIP_END
Definition: qgis_sip.h:189
QgsDiagramSettings
Stores the settings for rendering a single diagram.
Definition: qgsdiagramrenderer.h:380