KD Chart API Documentation 3.1
Loading...
Searching...
No Matches
KDChartPieDiagram.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Chart library.
4**
5** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
10
11#ifndef KDCHARTPIEDIAGRAM_H
12#define KDCHARTPIEDIAGRAM_H
13
15
16namespace KDChart {
17
18class LabelPaintCache;
19
23class KDCHART_EXPORT PieDiagram : public AbstractPieDiagram
24{
25 Q_OBJECT
26
27 Q_DISABLE_COPY(PieDiagram)
29
30public:
31 explicit PieDiagram(
32 QWidget *parent = nullptr, PolarCoordinatePlane *plane = nullptr);
33 ~PieDiagram() override;
34
35protected:
36 // Implement AbstractDiagram
38 void paint(PaintContext *paintContext) override;
39
40public:
45 {
46 NoDecoration = 0,
47 FrameDecoration = 1,
48 LineFromSliceDecoration = 2
49 };
50 Q_DECLARE_FLAGS(LabelDecorations, LabelDecoration)
52 void setLabelDecorations(LabelDecorations decorations);
54 LabelDecorations labelDecorations() const;
55
60 void setLabelCollisionAvoidanceEnabled(bool enabled);
62 bool isLabelCollisionAvoidanceEnabled() const;
63
65 void resize(const QSizeF &area) override;
66
67 // Implement AbstractPolarDiagram
69 qreal valueTotals() const override;
71 qreal numberOfValuesPerDataset() const override;
73 qreal numberOfGridRings() const override;
74
75 virtual PieDiagram *clone() const;
76
77protected:
79 const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
80 void paintEvent(QPaintEvent *) override;
81 void resizeEvent(QResizeEvent *) override;
82
83private:
84 // ### move to private class?
85 void placeLabels(PaintContext *paintContext);
86 // Solve problems with label overlap by changing label positions inside d->labelPaintCache.
87 void shuffleLabels(QRectF *textBoundingRect);
88 void paintInternal(PaintContext *paintContext);
89 void drawSlice(QPainter *painter, const QRectF &drawPosition, uint slice);
90 void drawSliceSurface(QPainter *painter, const QRectF &drawPosition, uint slice);
91 void addSliceLabel(LabelPaintCache *lpc, const QRectF &drawPosition, uint slice);
92 void draw3DEffect(QPainter *painter, const QRectF &drawPosition, uint slice);
93 void draw3dCutSurface(QPainter *painter,
94 const QRectF &rect,
95 qreal threeDHeight,
96 qreal angle);
97 void draw3dOuterRim(QPainter *painter,
98 const QRectF &rect,
99 qreal threeDHeight,
100 qreal startAngle,
101 qreal endAngle);
102 void calcSliceAngles();
103 void calcPieSize(const QRectF &contentsRect);
104 QRectF twoDPieRect(const QRectF &contentsRect, const ThreeDPieAttributes &threeDAttrs) const;
105 QRectF explodedDrawPosition(const QRectF &drawPosition, uint slice) const;
106 uint findSliceAt(qreal angle, int columnCount);
107 uint findLeftSlice(uint slice, int columnCount);
108 uint findRightSlice(uint slice, int columnCount);
109 QPointF pointOnEllipse(const QRectF &boundingBox, qreal angle);
110}; // End of class KDChartPieDiagram
111
112Q_DECLARE_OPERATORS_FOR_FLAGS(PieDiagram::LabelDecorations)
113}
114#endif // KDCHARTPIEDIAGRAM_H
#define KDCHART_DECLARE_DERIVED_DIAGRAM(X, PLANE)
Base class for any diagram type.
Stores information about painting diagrams.
PieDiagram defines a common pie diagram.
T qobject_cast(QObject *object)

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated on Wed May 1 2024 00:01:10 for KD Chart API Documentation by doxygen 1.9.8