00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved. 00003 ** 00004 ** This file is part of the KD Chart library. 00005 ** 00006 ** Licensees holding valid commercial KD Chart licenses may use this file in 00007 ** accordance with the KD Chart Commercial License Agreement provided with 00008 ** the Software. 00009 ** 00010 ** 00011 ** This file may be distributed and/or modified under the terms of the 00012 ** GNU General Public License version 2 and version 3 as published by the 00013 ** Free Software Foundation and appearing in the file LICENSE.GPL included. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** Contact info@kdab.com if any conditions of this licensing are not 00019 ** clear to you. 00020 ** 00021 **********************************************************************/ 00022 00023 #include "KDChartPieAttributes.h" 00024 #include "KDChartPieAttributes_p.h" 00025 00026 #include <QDebug> 00027 00028 #include <KDABLibFakes> 00029 00030 #define d d_func() 00031 00032 00033 using namespace KDChart; 00034 00035 00036 PieAttributes::Private::Private() 00037 : explodeFactor( 0.0 ) 00038 , tangentialGapFactor( 0.0 ) 00039 , radialGapFactor( 0.0 ) 00040 { 00041 } 00042 00043 00044 PieAttributes::PieAttributes() 00045 : _d( new Private() ) 00046 { 00047 } 00048 00049 PieAttributes::PieAttributes( const PieAttributes& r ) 00050 : _d( new Private( *r.d ) ) 00051 { 00052 } 00053 00054 PieAttributes& PieAttributes::operator= ( const PieAttributes& r ) 00055 { 00056 if( this == &r ) 00057 return *this; 00058 00059 *d = *r.d; 00060 00061 return *this; 00062 } 00063 00064 PieAttributes::~PieAttributes() 00065 { 00066 delete _d; _d = 0; 00067 } 00068 00069 00070 bool PieAttributes::operator==( const PieAttributes& r ) const 00071 { 00072 return 00073 explodeFactor() == r.explodeFactor() && 00074 gapFactor( true ) == r.gapFactor( true ) && 00075 gapFactor( false) == r.gapFactor( false); 00076 } 00077 00078 00079 void PieAttributes::init( ) 00080 { 00081 00082 } 00083 00084 void PieAttributes::setExplode( bool enabled ) 00085 { 00086 d->explodeFactor = (enabled ? 0.1 : 0.0); 00087 } 00088 00089 bool PieAttributes::explode() const 00090 { 00091 return (d->explodeFactor != 0.0); 00092 } 00093 00094 void PieAttributes::setExplodeFactor( qreal factor ) 00095 { 00096 d->explodeFactor = factor; 00097 } 00098 00099 qreal PieAttributes::explodeFactor() const 00100 { 00101 return d->explodeFactor; 00102 } 00103 00104 void PieAttributes::setGapFactor( bool circular, qreal factor ) 00105 { 00106 if ( circular ) 00107 d->tangentialGapFactor = factor; 00108 else 00109 d->radialGapFactor = factor; 00110 } 00111 00112 qreal PieAttributes::gapFactor( bool circular ) const 00113 { 00114 return circular ? d->tangentialGapFactor : d->radialGapFactor; 00115 } 00116 00117 #if !defined(QT_NO_DEBUG_STREAM) 00118 QDebug operator<<(QDebug dbg, const KDChart::PieAttributes& a) 00119 { 00120 dbg << "KDChart::PieAttributes("; 00121 dbg << "explodeFactor="<< a.explodeFactor() << ")"; 00122 return dbg; 00123 } 00124 #endif /* QT_NO_DEBUG_STREAM */ 00125