| 1 | // Copyright (C) 2020 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only | 
| 3 |  | 
| 4 | //  W A R N I N G | 
| 5 | //  ------------- | 
| 6 | // | 
| 7 | // This file is not part of the Qt Chart API.  It exists purely as an | 
| 8 | // implementation detail.  This header file may change from version to | 
| 9 | // version without notice, or even be removed. | 
| 10 | // | 
| 11 | // We mean it. | 
| 12 |  | 
| 13 | #ifndef PIESLICEDATA_P_H | 
| 14 | #define PIESLICEDATA_P_H | 
| 15 |  | 
| 16 | #include <QtCharts/QChartGlobal> | 
| 17 | #include <QtCharts/QPieSlice> | 
| 18 | #include <QtGui/QPen> | 
| 19 | #include <QtGui/QBrush> | 
| 20 | #include <QtCore/private/qglobal_p.h> | 
| 21 |  | 
| 22 | QT_BEGIN_NAMESPACE | 
| 23 |  | 
| 24 | template <class T> | 
| 25 | class Themed : public T | 
| 26 | { | 
| 27 | public: | 
| 28 |     Themed(): m_isThemed(true) {} | 
| 29 |  | 
| 30 |     inline T &operator=(const T &other) { return T::operator =(other); } | 
| 31 |  | 
| 32 |     inline bool operator!=(const T &other) const { return T::operator !=(other); } | 
| 33 |     inline bool operator!=(const Themed &other) const | 
| 34 |     { | 
| 35 |         if (T::operator !=(other)) | 
| 36 |             return true; | 
| 37 |  | 
| 38 |         if (m_isThemed != other.m_isThemed) | 
| 39 |             return true; | 
| 40 |  | 
| 41 |         return false; | 
| 42 |     } | 
| 43 |  | 
| 44 |     inline void setThemed(bool state) { m_isThemed = state; } | 
| 45 |     inline bool isThemed() const { return m_isThemed; } | 
| 46 |  | 
| 47 | private: | 
| 48 |     bool m_isThemed; | 
| 49 | }; | 
| 50 |  | 
| 51 | class PieSliceData | 
| 52 | { | 
| 53 | public: | 
| 54 |     PieSliceData() : | 
| 55 |         m_value(0), | 
| 56 |         m_isExploded(false), | 
| 57 |         m_explodeDistanceFactor(0.15), | 
| 58 |         m_isLabelVisible(false), | 
| 59 |         m_labelPosition(QPieSlice::LabelOutside), | 
| 60 |         m_labelArmLengthFactor(0.15), | 
| 61 |         m_percentage(0), | 
| 62 |         m_radius(0), | 
| 63 |         m_startAngle(0), | 
| 64 |         m_angleSpan(0), | 
| 65 |         m_holeRadius(0) | 
| 66 |     { | 
| 67 |     } | 
| 68 |  | 
| 69 |     bool operator!=(const PieSliceData &other) const { | 
| 70 |         if (!qFuzzyIsNull(d: m_value - other.m_value)) | 
| 71 |             return true; | 
| 72 |  | 
| 73 |         if (m_slicePen != other.m_slicePen || | 
| 74 |             m_sliceBrush != other.m_sliceBrush) | 
| 75 |             return true; | 
| 76 |  | 
| 77 |         if (m_isExploded != other.m_isExploded || | 
| 78 |             !qFuzzyIsNull(d: m_explodeDistanceFactor - other.m_explodeDistanceFactor)) | 
| 79 |             return true; | 
| 80 |  | 
| 81 |         if (m_isLabelVisible != other.m_isLabelVisible || | 
| 82 |             m_labelText != other.m_labelText || | 
| 83 |             m_labelFont != other.m_labelFont || | 
| 84 |             m_labelPosition != other.m_labelPosition || | 
| 85 |             !qFuzzyIsNull(d: m_labelArmLengthFactor - other.m_labelArmLengthFactor) || | 
| 86 |             m_labelBrush != other.m_labelBrush) | 
| 87 |             return true; | 
| 88 |  | 
| 89 |         if (!qFuzzyIsNull(d: m_percentage - other.m_percentage) || | 
| 90 |             m_center != other.m_center || | 
| 91 |             !qFuzzyIsNull(d: m_radius - other.m_radius) || | 
| 92 |             !qFuzzyIsNull(d: m_startAngle - other.m_startAngle) || | 
| 93 |             !qFuzzyIsNull(d: m_angleSpan - other.m_angleSpan)) | 
| 94 |             return true; | 
| 95 |  | 
| 96 |         return false; | 
| 97 |     } | 
| 98 |  | 
| 99 |     qreal m_value; | 
| 100 |  | 
| 101 |     Themed<QPen> m_slicePen; | 
| 102 |     Themed<QBrush> m_sliceBrush; | 
| 103 |  | 
| 104 |     bool m_isExploded; | 
| 105 |     qreal m_explodeDistanceFactor; | 
| 106 |  | 
| 107 |     bool m_isLabelVisible; | 
| 108 |     QString m_labelText; | 
| 109 |     Themed<QFont> m_labelFont; | 
| 110 |     QPieSlice::LabelPosition m_labelPosition; | 
| 111 |     qreal m_labelArmLengthFactor; | 
| 112 |     Themed<QBrush> m_labelBrush; | 
| 113 |  | 
| 114 |     qreal m_percentage; | 
| 115 |     QPointF m_center; | 
| 116 |     qreal m_radius; | 
| 117 |     qreal m_startAngle; | 
| 118 |     qreal m_angleSpan; | 
| 119 |  | 
| 120 |     qreal m_holeRadius; | 
| 121 | }; | 
| 122 |  | 
| 123 | QT_END_NAMESPACE | 
| 124 |  | 
| 125 | #endif // PIESLICEDATA_P_H | 
| 126 |  |