KD Chart 2  [rev.2.7]
KDChartPieAttributes.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2020 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #include "KDChartPieAttributes.h"
24 #include "KDChartPieAttributes_p.h"
25 
26 #include <QDebug>
27 
28 #include <KDABLibFakes>
29 
30 #define d d_func()
31 
32 
33 using namespace KDChart;
34 
35 
36 PieAttributes::Private::Private()
37  : explodeFactor( 0.0 )
38  , tangentialGapFactor( 0.0 )
39  , radialGapFactor( 0.0 )
40 {
41 }
42 
43 
44 PieAttributes::PieAttributes()
45  : _d( new Private() )
46 {
47 }
48 
50  : _d( new Private( *r.d ) )
51 {
52 }
53 
55 {
56  if ( this == &r )
57  return *this;
58 
59  *d = *r.d;
60 
61  return *this;
62 }
63 
65 {
66  delete _d; _d = 0;
67 }
68 
69 
71 {
72  return
73  explodeFactor() == r.explodeFactor() &&
74  gapFactor( true ) == r.gapFactor( true ) &&
75  gapFactor( false) == r.gapFactor( false);
76 }
77 
78 
79 void PieAttributes::init( )
80 {
81 
82 }
83 
84 void PieAttributes::setExplode( bool enabled )
85 {
86  d->explodeFactor = (enabled ? 0.1 : 0.0);
87 }
88 
90 {
91  return (d->explodeFactor != 0.0);
92 }
93 
94 void PieAttributes::setExplodeFactor( qreal factor )
95 {
96  d->explodeFactor = factor;
97 }
98 
100 {
101  return d->explodeFactor;
102 }
103 
104 void PieAttributes::setGapFactor( bool circular, qreal factor )
105 {
106  if ( circular )
107  d->tangentialGapFactor = factor;
108  else
109  d->radialGapFactor = factor;
110 }
111 
112 qreal PieAttributes::gapFactor( bool circular ) const
113 {
114  return circular ? d->tangentialGapFactor : d->radialGapFactor;
115 }
116 
117 #if !defined(QT_NO_DEBUG_STREAM)
118 QDebug operator<<(QDebug dbg, const KDChart::PieAttributes& a)
119 {
120  dbg << "KDChart::PieAttributes(";
121  dbg << "explodeFactor="<< a.explodeFactor() << ")";
122  return dbg;
123 }
124 #endif /* QT_NO_DEBUG_STREAM */
125 
void setGapFactor(bool circular, qreal factor)
PieAttributes & operator=(const PieAttributes &)
bool operator==(const PieAttributes &) const
A set of attributes controlling the appearance of pie charts.
void setExplode(bool explode)
Enable or disable exploding the respective pie piece(s).
QDebug operator<<(QDebug stream, const DataDimension &r)
#define d
void setExplodeFactor(qreal factor)
Set the explode factor.
qreal gapFactor(bool circular) const

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/