File indexing completed on 2024-05-26 04:23:56

0001 /*
0002  * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #include "KChartPieAttributes.h"
0010 #include "KChartPieAttributes_p.h"
0011 
0012 #include "KChartMath_p.h"
0013 
0014 #include <QDebug>
0015 
0016 #define d d_func()
0017 
0018 
0019 using namespace KChart;
0020 
0021 
0022 PieAttributes::Private::Private()
0023     : explodeFactor( 0.0 )
0024     , tangentialGapFactor( 0.0 )
0025     , radialGapFactor( 0.0 )
0026 {
0027 }
0028 
0029 
0030 PieAttributes::PieAttributes()
0031     : _d( new Private() )
0032 {
0033 }
0034 
0035 PieAttributes::PieAttributes( const PieAttributes& r )
0036     : _d( new Private( *r.d ) )
0037 {
0038 }
0039 
0040 PieAttributes& PieAttributes::operator= ( const PieAttributes& r )
0041 {
0042     if ( this == &r )
0043         return *this;
0044 
0045     *d = *r.d;
0046 
0047     return *this;
0048 }
0049 
0050 PieAttributes::~PieAttributes()
0051 {
0052     delete _d; _d = nullptr;
0053 }
0054 
0055 
0056 bool PieAttributes::operator==( const PieAttributes& r ) const
0057 {
0058     return 
0059         explodeFactor()   == r.explodeFactor() &&
0060         gapFactor( true ) == r.gapFactor( true ) &&
0061         gapFactor( false) == r.gapFactor( false);
0062 }
0063 
0064 
0065 void PieAttributes::init( )
0066 {
0067 
0068 }
0069 
0070 void PieAttributes::setExplode( bool enabled )
0071 {
0072     d->explodeFactor = (enabled ? 0.1 : 0.0);
0073 }
0074 
0075 bool PieAttributes::explode() const
0076 {
0077     return (d->explodeFactor != 0.0);
0078 }
0079 
0080 void PieAttributes::setExplodeFactor( qreal factor )
0081 {
0082     d->explodeFactor = factor;
0083 }
0084 
0085 qreal PieAttributes::explodeFactor() const
0086 {
0087     return d->explodeFactor;
0088 }
0089 
0090 void PieAttributes::setGapFactor( bool circular, qreal factor )
0091 {
0092     if ( circular )
0093         d->tangentialGapFactor = factor;
0094     else
0095         d->radialGapFactor = factor;
0096 }
0097 
0098 qreal PieAttributes::gapFactor( bool circular ) const
0099 {
0100     return circular ? d->tangentialGapFactor : d->radialGapFactor;
0101 }
0102 
0103 #if !defined(QT_NO_DEBUG_STREAM)
0104 QDebug operator<<(QDebug dbg, const KChart::PieAttributes& a)
0105 {
0106     dbg << "KChart::PieAttributes(";
0107     dbg << "explodeFactor="<< a.explodeFactor() << ")";
0108     return dbg;
0109 }
0110 #endif /* QT_NO_DEBUG_STREAM */
0111