KD Chart 2
[rev.2.5]
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2012 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.txt 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 "KDChartAbstractThreeDAttributes.h" 00024 #include "KDChartAbstractThreeDAttributes_p.h" 00025 00026 #include <QDebug> 00027 #include <QBrush> 00028 #include <KDABLibFakes> 00029 00030 #define d d_func() 00031 00032 00033 using namespace KDChart; 00034 00035 00036 AbstractThreeDAttributes::Private::Private() 00037 : enabled( false ), 00038 depth( 20 ), 00039 threeDBrushEnabled( false ) 00040 { 00041 } 00042 00043 00044 AbstractThreeDAttributes::AbstractThreeDAttributes() 00045 : _d( new Private() ) 00046 { 00047 } 00048 00049 AbstractThreeDAttributes::AbstractThreeDAttributes( const AbstractThreeDAttributes& r ) 00050 : _d( new Private( *r.d ) ) 00051 { 00052 } 00053 00054 AbstractThreeDAttributes& AbstractThreeDAttributes::operator= ( const AbstractThreeDAttributes& r ) 00055 { 00056 if( this == &r ) 00057 return *this; 00058 00059 *d = *r.d; 00060 00061 return *this; 00062 } 00063 00064 AbstractThreeDAttributes::~AbstractThreeDAttributes() 00065 { 00066 delete _d; _d = 0; 00067 } 00068 00069 00070 bool AbstractThreeDAttributes::operator==( const AbstractThreeDAttributes& r ) const 00071 { 00072 return isEnabled() == r.isEnabled() && 00073 depth() == r.depth() && 00074 isThreeDBrushEnabled() == r.isThreeDBrushEnabled(); 00075 } 00076 00077 00078 void AbstractThreeDAttributes::init( ) 00079 { 00080 00081 } 00082 00083 void AbstractThreeDAttributes::setEnabled( bool enabled ) 00084 { 00085 d->enabled = enabled; 00086 } 00087 00088 bool AbstractThreeDAttributes::isEnabled() const 00089 { 00090 return d->enabled; 00091 } 00092 00093 void AbstractThreeDAttributes::setDepth( qreal depth ) 00094 { 00095 d->depth = depth; 00096 } 00097 00098 00099 qreal AbstractThreeDAttributes::depth() const 00100 { 00101 return d->depth; 00102 } 00103 00104 00105 qreal AbstractThreeDAttributes::validDepth() const 00106 { 00107 return isEnabled() ? d->depth : 0.0; 00108 } 00109 00110 bool AbstractThreeDAttributes::isThreeDBrushEnabled() const 00111 { 00112 return d->threeDBrushEnabled; 00113 } 00114 00115 void AbstractThreeDAttributes::setThreeDBrushEnabled( bool enabled ) 00116 { 00117 d->threeDBrushEnabled = enabled; 00118 } 00119 00120 QBrush AbstractThreeDAttributes::threeDBrush( const QBrush& brush, const QRectF& rect ) const 00121 { 00122 if( isThreeDBrushEnabled() ) { 00123 QLinearGradient gr(rect.topLeft(), rect.bottomRight()); 00124 gr.setColorAt(0.0, brush.color()); 00125 gr.setColorAt(0.5, brush.color().lighter(180)); 00126 gr.setColorAt(1.0, brush.color()); 00127 return QBrush(gr); 00128 } 00129 return brush; 00130 } 00131 00132 #if !defined(QT_NO_DEBUG_STREAM) 00133 QDebug operator<<(QDebug dbg, const KDChart::AbstractThreeDAttributes& a) 00134 { 00135 dbg << "enabled="<<a.isEnabled() 00136 << "depth="<<a.depth(); 00137 return dbg; 00138 } 00139 #endif /* QT_NO_DEBUG_STREAM */