KChart

KChartPieAttributes.cpp
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 #include "KChartPieAttributes.h"
10 #include "KChartPieAttributes_p.h"
11 
12 #include "KChartMath_p.h"
13 
14 #include <QDebug>
15 
16 #define d d_func()
17 
18 
19 using namespace KChart;
20 
21 
22 PieAttributes::Private::Private()
23  : explodeFactor( 0.0 )
24  , tangentialGapFactor( 0.0 )
25  , radialGapFactor( 0.0 )
26 {
27 }
28 
29 
30 PieAttributes::PieAttributes()
31  : _d( new Private() )
32 {
33 }
34 
35 PieAttributes::PieAttributes( const PieAttributes& r )
36  : _d( new Private( *r.d ) )
37 {
38 }
39 
40 PieAttributes& PieAttributes::operator= ( const PieAttributes& r )
41 {
42  if ( this == &r )
43  return *this;
44 
45  *d = *r.d;
46 
47  return *this;
48 }
49 
50 PieAttributes::~PieAttributes()
51 {
52  delete _d; _d = nullptr;
53 }
54 
55 
56 bool PieAttributes::operator==( const PieAttributes& r ) const
57 {
58  return
59  explodeFactor() == r.explodeFactor() &&
60  gapFactor( true ) == r.gapFactor( true ) &&
61  gapFactor( false) == r.gapFactor( false);
62 }
63 
64 
65 void PieAttributes::init( )
66 {
67 
68 }
69 
70 void PieAttributes::setExplode( bool enabled )
71 {
72  d->explodeFactor = (enabled ? 0.1 : 0.0);
73 }
74 
76 {
77  return (d->explodeFactor != 0.0);
78 }
79 
80 void PieAttributes::setExplodeFactor( qreal factor )
81 {
82  d->explodeFactor = factor;
83 }
84 
86 {
87  return d->explodeFactor;
88 }
89 
90 void PieAttributes::setGapFactor( bool circular, qreal factor )
91 {
92  if ( circular )
93  d->tangentialGapFactor = factor;
94  else
95  d->radialGapFactor = factor;
96 }
97 
98 qreal PieAttributes::gapFactor( bool circular ) const
99 {
100  return circular ? d->tangentialGapFactor : d->radialGapFactor;
101 }
102 
103 #if !defined(QT_NO_DEBUG_STREAM)
105 {
106  dbg << "KChart::PieAttributes(";
107  dbg << "explodeFactor="<< a.explodeFactor() << ")";
108  return dbg;
109 }
110 #endif /* QT_NO_DEBUG_STREAM */
111 
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-2021 The KDE developers.
Generated on Sat Sep 25 2021 22:37:38 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.