QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgspiechartplot.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspiechartplot.h
3 -----------------
4 begin : September 2025
5 copyright : (C) 2025 by Mathieu Pellerin
6 email : mathieu at opengis dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSPIECHARTPLOT_H
18#define QGSPIECHARTPLOT_H
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgscolorramp.h"
23#include "qgsfillsymbol.h"
24#include "qgsnumericformat.h"
25#include "qgsplot.h"
26
28
29
38class CORE_EXPORT QgsPieChartPlot : public Qgs2DPlot
39{
40 public:
41
43 ~QgsPieChartPlot() override = default;
44
45 QString type() const override { return QStringLiteral( "pie" ); }
46
47 void renderContent( QgsRenderContext &context, QgsPlotRenderContext &plotContext, const QRectF &plotArea, const QgsPlotData &plotData = QgsPlotData() ) override;
48
49 bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
50 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
51
55 QgsFillSymbol *fillSymbolAt( int index ) const;
56
60 void setFillSymbolAt( int index, QgsFillSymbol *symbol SIP_TRANSFER );
61
65 QgsColorRamp *colorRampAt( int index ) const;
66
70 void setColorRampAt( int index, QgsColorRamp *ramp SIP_TRANSFER );
71
75 int fillSymbolCount() const { return mFillSymbols.size(); }
76
80 int colorRampCount() const { return mColorRamps.size(); }
81
87 QgsTextFormat textFormat() const { return mLabelTextFormat; }
88
94 void setTextFormat( const QgsTextFormat &format );
95
101 QgsNumericFormat *numericFormat() const { return mNumericFormat.get(); }
102
110 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
111
115 Qgis::PieChartLabelType labelType() const { return mLabelType; }
116
120 void setLabelType( Qgis::PieChartLabelType type );
121
123 static QgsPieChartPlot *create() SIP_FACTORY;
124
126 static QgsVectorLayerAbstractPlotDataGatherer *createDataGatherer( QgsPlot *plot ) SIP_TRANSFERBACK;
127
128 private:
129
130 std::vector<std::unique_ptr<QgsFillSymbol>> mFillSymbols;
131 std::vector<std::unique_ptr<QgsColorRamp>> mColorRamps;
132
133 std::unique_ptr< QgsNumericFormat > mNumericFormat;
134
135 QgsTextFormat mLabelTextFormat;
136 Qgis::PieChartLabelType mLabelType = Qgis::PieChartLabelType::NoLabels;
137};
138
139#endif // QGSLINECHARTPLOT_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
PieChartLabelType
Pie chart label types.
Definition qgis.h:3346
bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
Writes the plot's properties into an XML element.
Definition qgsplot.cpp:234
virtual void renderContent(QgsRenderContext &context, QgsPlotRenderContext &plotContext, const QRectF &plotArea, const QgsPlotData &plotData=QgsPlotData())
Renders the plot content.
Definition qgsplot.cpp:263
Qgs2DPlot()
Constructor for Qgs2DPlot.
Definition qgsplot.cpp:229
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the plot's properties from an XML element.
Definition qgsplot.cpp:243
Abstract base class for color ramps.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Abstract base class for numeric formatters, which allow for formatting a numeric value for display.
A simple pie chart class.
QgsTextFormat textFormat() const
Returns the text format used for the pie chart labels.
~QgsPieChartPlot() override=default
QgsNumericFormat * numericFormat() const
Returns the numeric format used for the pie chart labels.
Qgis::PieChartLabelType labelType() const
Returns the pie chart label type.
int fillSymbolCount() const
Returns the fill symbols list count.
int colorRampCount() const
Returns the color ramps list count.
QString type() const override
Returns the plot's type.
Encapsulates one or more plot series.
Definition qgsplot.h:300
Contains information about the context of a plot rendering operation.
Definition qgsplot.h:184
Base class for plot/chart/graphs.
Definition qgsplot.h:48
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
Container for all settings relating to text rendering.
An abstract vector layer plot data gatherer base class.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_TRANSFERBACK
Definition qgis_sip.h:48
#define SIP_FACTORY
Definition qgis_sip.h:84