QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
32
33
42class CORE_EXPORT QgsPieChartPlot : public Qgs2DPlot
43{
44 public:
46 ~QgsPieChartPlot() override = default;
47
48 QString type() const override { return u"pie"_s; }
49
50 void renderContent( QgsRenderContext &context, QgsPlotRenderContext &plotContext, const QRectF &plotArea, const QgsPlotData &plotData = QgsPlotData() ) override;
51
52 bool writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const override;
53 bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
54
58 QgsFillSymbol *fillSymbolAt( int index ) const;
59
63 void setFillSymbolAt( int index, QgsFillSymbol *symbol SIP_TRANSFER );
64
68 QgsColorRamp *colorRampAt( int index ) const;
69
73 void setColorRampAt( int index, QgsColorRamp *ramp SIP_TRANSFER );
74
78 int fillSymbolCount() const { return mFillSymbols.size(); }
79
83 int colorRampCount() const { return mColorRamps.size(); }
84
90 QgsTextFormat textFormat() const { return mLabelTextFormat; }
91
97 void setTextFormat( const QgsTextFormat &format );
98
104 QgsNumericFormat *numericFormat() const { return mNumericFormat.get(); }
105
113 void setNumericFormat( QgsNumericFormat *format SIP_TRANSFER );
114
118 Qgis::PieChartLabelType labelType() const { return mLabelType; }
119
123 void setLabelType( Qgis::PieChartLabelType type );
124
126 static QgsPieChartPlot *create() SIP_FACTORY;
127
129 static QgsVectorLayerAbstractPlotDataGatherer *createDataGatherer( QgsPlot *plot ) SIP_TRANSFERBACK;
130
135 void initFromPlot( const QgsPlot *plot ) override;
136
137 private:
138 std::vector<std::unique_ptr<QgsFillSymbol>> mFillSymbols;
139 std::vector<std::unique_ptr<QgsColorRamp>> mColorRamps;
140
141 std::unique_ptr< QgsNumericFormat > mNumericFormat;
142
143 QgsTextFormat mLabelTextFormat;
144 Qgis::PieChartLabelType mLabelType = Qgis::PieChartLabelType::NoLabels;
145};
146
147#endif // QGSLINECHARTPLOT_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
PieChartLabelType
Pie chart label types.
Definition qgis.h:3460
bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const override
Writes the plot's properties into an XML element.
Definition qgsplot.cpp:281
virtual void renderContent(QgsRenderContext &context, QgsPlotRenderContext &plotContext, const QRectF &plotArea, const QgsPlotData &plotData=QgsPlotData())
Renders the plot content.
Definition qgsplot.cpp:310
Qgs2DPlot()
Constructor for Qgs2DPlot.
Definition qgsplot.cpp:277
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the plot's properties from an XML element.
Definition qgsplot.cpp:290
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:303
Contains information about the context of a plot rendering operation.
Definition qgsplot.h:191
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:35
#define SIP_TRANSFERBACK
Definition qgis_sip.h:47
#define SIP_FACTORY
Definition qgis_sip.h:83