1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Charts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt Chart API. It exists purely as an
34// implementation detail. This header file may change from version to
35// version without notice, or even be removed.
36//
37// We mean it.
38
39#ifndef PIESLICEDATA_P_H
40#define PIESLICEDATA_P_H
41
42#include <QtCharts/QChartGlobal>
43#include <QtCharts/QPieSlice>
44#include <QtGui/QPen>
45#include <QtGui/QBrush>
46
47QT_CHARTS_BEGIN_NAMESPACE
48
49template <class T>
50class Themed : public T
51{
52public:
53 Themed(): m_isThemed(true) {}
54
55 inline T &operator=(const T &other) { return T::operator =(other); }
56
57 inline bool operator!=(const T &other) const { return T::operator !=(other); }
58 inline bool operator!=(const Themed &other) const
59 {
60 if (T::operator !=(other))
61 return true;
62
63 if (m_isThemed != other.m_isThemed)
64 return true;
65
66 return false;
67 }
68
69 inline void setThemed(bool state) { m_isThemed = state; }
70 inline bool isThemed() const { return m_isThemed; }
71
72private:
73 bool m_isThemed;
74};
75
76class PieSliceData
77{
78public:
79 PieSliceData() :
80 m_value(0),
81 m_isExploded(false),
82 m_explodeDistanceFactor(0.15),
83 m_isLabelVisible(false),
84 m_labelPosition(QPieSlice::LabelOutside),
85 m_labelArmLengthFactor(0.15),
86 m_percentage(0),
87 m_radius(0),
88 m_startAngle(0),
89 m_angleSpan(0),
90 m_holeRadius(0)
91 {
92 }
93
94 bool operator!=(const PieSliceData &other) const {
95 if (!qFuzzyIsNull(d: m_value - other.m_value))
96 return true;
97
98 if (m_slicePen != other.m_slicePen ||
99 m_sliceBrush != other.m_sliceBrush)
100 return true;
101
102 if (m_isExploded != other.m_isExploded ||
103 !qFuzzyIsNull(d: m_explodeDistanceFactor - other.m_explodeDistanceFactor))
104 return true;
105
106 if (m_isLabelVisible != other.m_isLabelVisible ||
107 m_labelText != other.m_labelText ||
108 m_labelFont != other.m_labelFont ||
109 m_labelPosition != other.m_labelPosition ||
110 !qFuzzyIsNull(d: m_labelArmLengthFactor - other.m_labelArmLengthFactor) ||
111 m_labelBrush != other.m_labelBrush)
112 return true;
113
114 if (!qFuzzyIsNull(d: m_percentage - other.m_percentage) ||
115 m_center != other.m_center ||
116 !qFuzzyIsNull(d: m_radius - other.m_radius) ||
117 !qFuzzyIsNull(d: m_startAngle - other.m_startAngle) ||
118 !qFuzzyIsNull(d: m_angleSpan - other.m_angleSpan))
119 return true;
120
121 return false;
122 }
123
124 qreal m_value;
125
126 Themed<QPen> m_slicePen;
127 Themed<QBrush> m_sliceBrush;
128
129 bool m_isExploded;
130 qreal m_explodeDistanceFactor;
131
132 bool m_isLabelVisible;
133 QString m_labelText;
134 Themed<QFont> m_labelFont;
135 QPieSlice::LabelPosition m_labelPosition;
136 qreal m_labelArmLengthFactor;
137 Themed<QBrush> m_labelBrush;
138
139 qreal m_percentage;
140 QPointF m_center;
141 qreal m_radius;
142 qreal m_startAngle;
143 qreal m_angleSpan;
144
145 qreal m_holeRadius;
146};
147
148QT_CHARTS_END_NAMESPACE
149
150#endif // PIESLICEDATA_P_H
151

source code of qtcharts/src/charts/piechart/pieslicedata_p.h