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
19using namespace KChart;
20
21
22PieAttributes::Private::Private()
23 : explodeFactor( 0.0 )
24 , tangentialGapFactor( 0.0 )
25 , radialGapFactor( 0.0 )
26{
27}
28
29
30PieAttributes::PieAttributes()
31 : _d( new Private() )
32{
33}
34
35PieAttributes::PieAttributes( const PieAttributes& r )
36 : _d( new Private( *r.d ) )
37{
38}
39
40PieAttributes& PieAttributes::operator= ( const PieAttributes& r )
41{
42 if ( this == &r )
43 return *this;
44
45 *d = *r.d;
46
47 return *this;
48}
49
50PieAttributes::~PieAttributes()
51{
52 delete _d; _d = nullptr;
53}
54
55
56bool PieAttributes::operator==( const PieAttributes& r ) const
57{
58 return
60 gapFactor( true ) == r.gapFactor( true ) &&
61 gapFactor( false) == r.gapFactor( false);
62}
63
64
65void PieAttributes::init( )
66{
67
68}
69
70void PieAttributes::setExplode( bool enabled )
71{
72 d->explodeFactor = (enabled ? 0.1 : 0.0);
73}
74
76{
77 return (d->explodeFactor != 0.0);
78}
79
81{
82 d->explodeFactor = factor;
83}
84
86{
87 return d->explodeFactor;
88}
89
90void PieAttributes::setGapFactor( bool circular, qreal factor )
91{
92 if ( circular )
93 d->tangentialGapFactor = factor;
94 else
95 d->radialGapFactor = factor;
96}
97
98qreal PieAttributes::gapFactor( bool circular ) const
99{
100 return circular ? d->tangentialGapFactor : d->radialGapFactor;
101}
102
103#if !defined(QT_NO_DEBUG_STREAM)
104QDebug operator<<(QDebug dbg, const KChart::PieAttributes& a)
105{
106 dbg << "KChart::PieAttributes(";
107 dbg << "explodeFactor="<< a.explodeFactor() << ")";
108 return dbg;
109}
110#endif /* QT_NO_DEBUG_STREAM */
111
A set of attributes controlling the appearance of pie charts.
void setExplodeFactor(qreal factor)
Set the explode factor.
void setExplode(bool explode)
Enable or disable exploding the respective pie piece(s).
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:56:24 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.