QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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.h"
19#include "qgis_core.h"
20#include "qgsexpression.h"
21
22#include <QBrush>
23#include <QPen>
24#include <QString>
25
26using namespace Qt::StringLiterals;
27
28class QPainter;
29class QPointF;
32class QgsFeature;
35class QgsFields;
36class QgsAttributes;
37
38
44{
45 public:
46#ifdef SIP_RUN
48 if ( sipCpp->diagramName() == "Pie"_L1 )
49 sipType = sipType_QgsPieDiagram;
50 else if ( sipCpp->diagramName() == "Histogram"_L1 )
51 sipType = sipType_QgsHistogramDiagram;
52 else if ( sipCpp->diagramName() == "Text"_L1 )
53 sipType = sipType_QgsTextDiagram;
54 else if ( sipCpp->diagramName() == "Stacked"_L1 )
55 sipType = sipType_QgsStackedBarDiagram;
56 else if ( sipCpp->diagramName() == "StackedDiagram"_L1 )
57 sipType = sipType_QgsStackedDiagram;
58 else
59 sipType = NULL;
61#endif
62
63 virtual ~QgsDiagram()
64 {
65 clearCache();
66 }
67
71 virtual QgsDiagram *clone() const = 0 SIP_FACTORY;
72
73 void clearCache();
74
80 QgsExpression *getExpression( const QString &expression, const QgsExpressionContext &context );
81
83 virtual void renderDiagram( const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position ) = 0;
84
88 virtual QString diagramName() const = 0;
90 virtual QSizeF diagramSize( const QgsAttributes &attributes, const QgsRenderContext &c, const QgsDiagramSettings &s ) = 0;
92 virtual QSizeF diagramSize( const QgsFeature &feature, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings ) = 0;
93
100 virtual double legendSize( double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings ) const = 0;
101
102 protected:
103 QgsDiagram() = default;
104 QgsDiagram( const QgsDiagram &other );
105
112 void setPenWidth( QPen &pen, const QgsDiagramSettings &s, const QgsRenderContext &c );
113
122 QSizeF sizePainterUnits( QSizeF size, const QgsDiagramSettings &s, const QgsRenderContext &c );
123
132 double sizePainterUnits( double l, const QgsDiagramSettings &s, const QgsRenderContext &c );
133
141 QFont scaledFont( const QgsDiagramSettings &s, const QgsRenderContext &c );
142
149 QSizeF sizeForValue( double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings ) const;
150
151 private:
152 QMap<QString, QgsExpression *> mExpressions;
153 QgsDiagram &operator=( const QgsDiagram & ) = delete;
154};
155
156#endif // QGSDIAGRAM_H
A vector of attributes.
Additional diagram settings for interpolated size rendering.
Stores the settings for rendering a single diagram.
virtual QString diagramName() const =0
Gets a descriptive name for this diagram type.
void setPenWidth(QPen &pen, const QgsDiagramSettings &s, const QgsRenderContext &c)
Changes the pen width to match the current settings and rendering context.
void clearCache()
QSizeF sizePainterUnits(QSizeF size, const QgsDiagramSettings &s, const QgsRenderContext &c)
Calculates a size to match the current settings and rendering context.
QgsDiagram()=default
QgsExpression * getExpression(const QString &expression, const QgsExpressionContext &context)
Returns a prepared expression for the specified context.
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.
virtual QSizeF diagramSize(const QgsFeature &feature, const QgsRenderContext &c, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings)=0
Returns the size in map units the diagram will use to render. Interpolate size.
QSizeF sizeForValue(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings) const
Returns the scaled size of a diagram for a value, respecting the specified diagram interpolation sett...
QFont scaledFont(const QgsDiagramSettings &s, const QgsRenderContext &c)
Calculates a size to match the current settings and rendering context.
virtual double legendSize(double value, const QgsDiagramSettings &s, const QgsDiagramInterpolationSettings &interpolationSettings) const =0
Returns the size of the legend item for the diagram corresponding to a specified value.
virtual ~QgsDiagram()
Definition qgsdiagram.h:63
virtual QgsDiagram * clone() const =0
Returns an instance that is equivalent to this one.
virtual void renderDiagram(const QgsFeature &feature, QgsRenderContext &c, const QgsDiagramSettings &s, QPointF position)=0
Draws the diagram at the given position (in pixel coordinates).
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Handles parsing and evaluation of expressions (formerly called "search strings").
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Container of fields for a vector layer.
Definition qgsfields.h:46
Contains information about the context of a rendering operation.
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
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:198
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_NODEFAULTCTORS
Definition qgis_sip.h:108
#define SIP_END
Definition qgis_sip.h:215