KChart

KChartPieAttributes.cpp
1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #include "KChartPieAttributes.h"
21 #include "KChartPieAttributes_p.h"
22 
23 #include "KChartMath_p.h"
24 
25 #include <QDebug>
26 
27 #define d d_func()
28 
29 
30 using namespace KChart;
31 
32 
33 PieAttributes::Private::Private()
34  : explodeFactor( 0.0 )
35  , tangentialGapFactor( 0.0 )
36  , radialGapFactor( 0.0 )
37 {
38 }
39 
40 
41 PieAttributes::PieAttributes()
42  : _d( new Private() )
43 {
44 }
45 
46 PieAttributes::PieAttributes( const PieAttributes& r )
47  : _d( new Private( *r.d ) )
48 {
49 }
50 
51 PieAttributes& PieAttributes::operator= ( const PieAttributes& r )
52 {
53  if ( this == &r )
54  return *this;
55 
56  *d = *r.d;
57 
58  return *this;
59 }
60 
61 PieAttributes::~PieAttributes()
62 {
63  delete _d; _d = nullptr;
64 }
65 
66 
67 bool PieAttributes::operator==( const PieAttributes& r ) const
68 {
69  return
70  explodeFactor() == r.explodeFactor() &&
71  gapFactor( true ) == r.gapFactor( true ) &&
72  gapFactor( false) == r.gapFactor( false);
73 }
74 
75 
76 void PieAttributes::init( )
77 {
78 
79 }
80 
81 void PieAttributes::setExplode( bool enabled )
82 {
83  d->explodeFactor = (enabled ? 0.1 : 0.0);
84 }
85 
87 {
88  return (d->explodeFactor != 0.0);
89 }
90 
91 void PieAttributes::setExplodeFactor( qreal factor )
92 {
93  d->explodeFactor = factor;
94 }
95 
97 {
98  return d->explodeFactor;
99 }
100 
101 void PieAttributes::setGapFactor( bool circular, qreal factor )
102 {
103  if ( circular )
104  d->tangentialGapFactor = factor;
105  else
106  d->radialGapFactor = factor;
107 }
108 
109 qreal PieAttributes::gapFactor( bool circular ) const
110 {
111  return circular ? d->tangentialGapFactor : d->radialGapFactor;
112 }
113 
114 #if !defined(QT_NO_DEBUG_STREAM)
116 {
117  dbg << "KChart::PieAttributes(";
118  dbg << "explodeFactor="<< a.explodeFactor() << ")";
119  return dbg;
120 }
121 #endif /* QT_NO_DEBUG_STREAM */
122 
void setExplode(bool explode)
Enable or disable exploding the respective pie piece(s).
A set of attributes controlling the appearance of pie charts.
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
void setExplodeFactor(qreal factor)
Set the explode factor.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:37:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.