KChart

KChartRingDiagram.h
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef KCHARTRINGDIAGRAM_H
10#define KCHARTRINGDIAGRAM_H
11
12#include "KChartAbstractPieDiagram.h"
13
14namespace KChart {
15
16/**
17 * @brief RingDiagram defines a common ring diagram
18 */
19class KCHART_EXPORT RingDiagram : public AbstractPieDiagram
20{
21 Q_OBJECT
22
23 Q_DISABLE_COPY( RingDiagram )
24 KCHART_DECLARE_DERIVED_DIAGRAM( RingDiagram, PolarCoordinatePlane )
25
26public:
27 explicit RingDiagram(
28 QWidget* parent = nullptr, PolarCoordinatePlane* plane = nullptr );
29 ~RingDiagram() override;
30
31protected:
32 // Implement AbstractDiagram
33 /** \reimpl */
34 void paint( PaintContext* paintContext ) override;
35public:
36 /** \reimpl */
37 void resize( const QSizeF& area ) override;
38
39 // Implement AbstractPolarDiagram
40 /** \reimpl */
41 qreal valueTotals() const override;
42 /** \reimpl */
43 qreal numberOfValuesPerDataset() const override;
44 qreal numberOfDatasets() const override;
45 /** \reimpl */
46 qreal numberOfGridRings() const override;
47
48 qreal valueTotals( int dataset ) const;
49
50
51 /**
52 * Creates an exact copy of this diagram.
53 */
54 virtual RingDiagram * clone() const;
55
56 /**
57 * Returns true if both diagrams have the same settings.
58 */
59 bool compare( const RingDiagram* other ) const;
60
61 void setRelativeThickness( bool relativeThickness );
62 bool relativeThickness() const;
63
64 virtual void setExpandWhenExploded( bool expand );
65 virtual bool expandWhenExploded() const;
66
67protected:
68 /** \reimpl */
69 const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
70 void paintEvent( QPaintEvent* ) override;
71 void resizeEvent( QResizeEvent* ) override;
72
73private:
74
75 /**
76 \param painter the QPainter to draw in
77 \param dataset the dataset to draw the slice for
78 \param slice the slice to draw
79 */
80 void drawOneSlice( QPainter* painter, uint dataset, uint slice, qreal granularity );
81
82 /**
83 Internal method that draws the top surface of one of the slices in a ring chart.
84
85 \param painter the QPainter to draw in
86 \param dataset the dataset to draw the slice for
87 \param slice the slice to draw
88 */
89 void drawPieSurface( QPainter* painter, uint dataset, uint slice, qreal granularity );
90
91 /**
92 * Auxiliary method returning a point to a given boundary
93 * rectangle of the enclosed ellipse and an angle.
94 */
95 QPointF pointOnEllipse( const QRectF& rect, int dataset, int slice, bool outer, qreal angle,
96 qreal totalGapFactor, qreal totalExplodeFactor );
97}; // End of class RingDiagram
98
99}
100
101#endif // KCHARTRINGDIAGRAM_H
Base class for any diagram type.
Stores information about painting diagrams.
RingDiagram defines a common ring diagram.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.