# KDChartBarAttributes.cpp

Go to the documentation of this file.

    00001 /****************************************************************************
    00002  ** Copyright (C) 2006 Klarälvdalens Datakonsult AB.  All rights reserved.
    00003  **
    00004  ** This file is part of the KD Chart library.
    00005  **
    00006  ** This file may be distributed and/or modified under the terms of the
    00007  ** GNU General Public License version 2 as published by the Free Software
    00008  ** Foundation and appearing in the file LICENSE.GPL included in the
    00009  ** packaging of this file.
    00010  **
    00011  ** Licensees holding valid commercial KD Chart licenses may use this file in
    00012  ** accordance with the KD Chart Commercial License Agreement provided with
    00013  ** the Software.
    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  ** See http://www.kdab.net/kdchart for
    00019  **   information about KDChart Commercial License Agreements.
    00020  **
    00021  ** Contact info@kdab.net if any conditions of this
    00022  ** licensing are not clear to you.
    00023  **
    00024  **********************************************************************/
    00025
    00026 #include "KDChartBarAttributes.h"
    00027 #include <qglobal.h>
    00028
    00029 #include <KDABLibFakes>
    00030
    00031 #define d d_func()
    00032
    00033
    00034 using namespace KDChart;
    00035
    00036 class BarAttributes::Private
    00037 {
    00038     friend class BarAttributes;
    00039 public:
    00040     Private();
    00041
    00042 private:
    00043     qreal datasetGap;
    00044     bool useFixedDatasetGap;
    00045     qreal valueBlockGap;
    00046     bool useFixedValueBlockGap;
    00047     qreal barWidth;
    00048     bool useFixedBarWidth;
    00049     bool drawSolidExcessArrows;
    00050     qreal groupGapFactor;
    00051     qreal barGapFactor;
    00052 };
    00053
    00054
    00055 BarAttributes::Private::Private()
    00056     :datasetGap( 6 ),
    00057     useFixedDatasetGap( false ),
    00058     valueBlockGap( 24 ),
    00059     useFixedValueBlockGap( false ),
    00060     barWidth( -1 ),
    00061     useFixedBarWidth( false ),
    00062     drawSolidExcessArrows( false ),
    00063     groupGapFactor( 1.0 ),
    00064     barGapFactor( 0.5 )
    00065 {
    00066 }
    00067
    00068
    00069 BarAttributes::BarAttributes()
    00070     : _d( new Private() )
    00071 {
    00072 }
    00073
    00074 BarAttributes::BarAttributes( const BarAttributes& r )
    00075     : _d( new Private( *r.d ) )
    00076 {
    00077 }
    00078
    00079 BarAttributes& BarAttributes::operator= ( const BarAttributes& r )
    00080 {
    00081     if( this == &r )
    00082         return *this;
    00083
    00084     *d = *r.d;
    00085
    00086     return *this;
    00087 }
    00088
    00089 BarAttributes::~BarAttributes()
    00090 {
    00091     delete _d; _d = 0;
    00092 }
    00093
    00094
    00095 bool BarAttributes::operator==( const BarAttributes& r ) const
    00096 {
    00097     if( fixedDataValueGap() == r.fixedDataValueGap() &&
    00098         useFixedDataValueGap() == r.useFixedDataValueGap() &&
    00099         fixedValueBlockGap() == r.fixedValueBlockGap() &&
    00100         useFixedValueBlockGap() == r.useFixedValueBlockGap() &&
    00101         fixedBarWidth() == r.fixedBarWidth() &&
    00102         useFixedBarWidth() == r.useFixedBarWidth() &&
    00103         groupGapFactor() == r.groupGapFactor() &&
    00104         barGapFactor() == r.barGapFactor() &&
    00105         drawSolidExcessArrows() == r.drawSolidExcessArrows() )
    00106         return true;
    00107     else
    00108         return false;
    00109 }
    00110
    00111
    00112 void BarAttributes::setFixedDataValueGap( qreal gap )
    00113 {
    00114     d->datasetGap = gap;
    00115 }
    00116
    00117 qreal BarAttributes::fixedDataValueGap() const
    00118 {
    00119     return d->datasetGap;
    00120 }
    00121
    00122 void BarAttributes::setUseFixedDataValueGap( bool gapIsFixed )
    00123 {
    00124     d->useFixedDatasetGap = gapIsFixed;
    00125 }
    00126
    00127 bool BarAttributes::useFixedDataValueGap() const
    00128 {
    00129     return d->useFixedDatasetGap;
    00130 }
    00131
    00132 void BarAttributes::setFixedValueBlockGap( qreal gap )
    00133 {
    00134     d->valueBlockGap = gap;
    00135 }
    00136
    00137 qreal BarAttributes::fixedValueBlockGap() const
    00138 {
    00139     return d->valueBlockGap;
    00140 }
    00141
    00142 void BarAttributes::setUseFixedValueBlockGap( bool gapIsFixed )
    00143 {
    00144     d->useFixedValueBlockGap = gapIsFixed;
    00145 }
    00146
    00147 bool BarAttributes::useFixedValueBlockGap() const
    00148 {
    00149     return d->useFixedValueBlockGap;
    00150 }
    00151
    00152 void BarAttributes::setFixedBarWidth( qreal width )
    00153 {
    00154     d->barWidth = width;
    00155 }
    00156
    00157 qreal BarAttributes::fixedBarWidth() const
    00158 {
    00159
    00160     return d->barWidth;
    00161 }
    00162
    00163 void BarAttributes::setUseFixedBarWidth( bool useFixedBarWidth )
    00164 {
    00165     d->useFixedBarWidth = useFixedBarWidth;
    00166 }
    00167
    00168 bool BarAttributes::useFixedBarWidth() const
    00169 {
    00170     return d->useFixedBarWidth;
    00171 }
    00172
    00173 void BarAttributes::setGroupGapFactor( qreal gapFactor )
    00174 {
    00175     d->groupGapFactor = gapFactor;
    00176 }
    00177
    00178 qreal BarAttributes::groupGapFactor() const
    00179 {
    00180     return d->groupGapFactor;
    00181 }
    00182
    00183 void BarAttributes::setBarGapFactor( qreal gapFactor )
    00184 {
    00185     d->barGapFactor = gapFactor;
    00186 }
    00187
    00188 qreal BarAttributes::barGapFactor() const
    00189 {
    00190     return d->barGapFactor;
    00191 }
    00192
    00193 void BarAttributes::setDrawSolidExcessArrows( bool solidArrows )
    00194 {
    00195     d->drawSolidExcessArrows = solidArrows;
    00196 }
    00197
    00198 bool BarAttributes::drawSolidExcessArrows() const
    00199 {
    00200     return d->drawSolidExcessArrows;
    00201 }
    00202