KD Chart 2 [rev.2.4]

KDChartGridAttributes.cpp

Go to the documentation of this file.
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 "KDChartGridAttributes.h"
00024 
00025 #include <QPen>
00026 #include <QDebug>
00027 
00028 #include <KDABLibFakes>
00029 
00030 #define d d_func()
00031 
00032 using namespace KDChart;
00033 
00034 class GridAttributes::Private
00035 {
00036     friend class GridAttributes;
00037 public:
00038     Private();
00039 private:
00040     bool visible;
00041     KDChartEnums::GranularitySequence sequence;
00042     qreal stepWidth;
00043     qreal subStepWidth;
00044     bool adjustLower;
00045     bool adjustUpper;
00046     QPen pen;
00047     bool subVisible;
00048     QPen subPen;
00049     bool outerVisible;
00050     QPen zeroPen;
00051 };
00052 
00053 GridAttributes::Private::Private()
00054     : visible( true ),
00055       sequence( KDChartEnums::GranularitySequence_10_20 ),
00056       stepWidth( 0.0 ),
00057       subStepWidth( 0.0 ),
00058       adjustLower( true ),
00059       adjustUpper( true ),
00060       pen( QColor(0xa0, 0xa0, 0xa0 ) ),
00061       subVisible( true ),
00062       subPen( QColor(0xd0, 0xd0, 0xd0 ) ),
00063       outerVisible( true ),
00064       zeroPen( QColor( 0x00, 0x00, 0x80 ) )
00065 {
00066     pen.setCapStyle(     Qt::FlatCap );
00067     subPen.setCapStyle(  Qt::FlatCap );
00068     zeroPen.setCapStyle( Qt::FlatCap );
00069 }
00070 
00071 
00072 GridAttributes::GridAttributes()
00073     : _d( new Private() )
00074 {
00075     // this bloc left empty intentionally
00076 }
00077 
00078 GridAttributes::GridAttributes( const GridAttributes& r )
00079     : _d( new Private( *r.d ) )
00080 {
00081 }
00082 
00083 GridAttributes & GridAttributes::operator=( const GridAttributes& r )
00084 {
00085     if( this == &r )
00086         return *this;
00087 
00088     *d = *r.d;
00089 
00090     return *this;
00091 }
00092 
00093 GridAttributes::~GridAttributes()
00094 {
00095     delete _d; _d = 0;
00096 }
00097 
00098 
00099 bool GridAttributes::operator==( const GridAttributes& r ) const
00100 {
00101     return  isGridVisible() == r.isGridVisible() &&
00102             gridGranularitySequence() == r.gridGranularitySequence() &&
00103             adjustLowerBoundToGrid() == r.adjustLowerBoundToGrid() &&
00104             adjustUpperBoundToGrid() == r.adjustUpperBoundToGrid() &&
00105             gridPen() == r.gridPen() &&
00106             isSubGridVisible() == r.isSubGridVisible() &&
00107             subGridPen() == r.subGridPen() &&
00108             isOuterLinesVisible() == r.isOuterLinesVisible() &&
00109             zeroLinePen() == r.zeroLinePen();
00110 }
00111 
00112 
00113 void GridAttributes::setGridVisible( bool visible )
00114 {
00115     d->visible = visible;
00116 }
00117 
00118 bool GridAttributes::isGridVisible() const
00119 {
00120     return d->visible;
00121 }
00122 
00141 void GridAttributes::setGridStepWidth( qreal stepWidth )
00142 {
00143     d->stepWidth = stepWidth;
00144 }
00145 
00152 qreal GridAttributes::gridStepWidth() const
00153 {
00154     return d->stepWidth;
00155 }
00156 
00157 
00172 void GridAttributes::setGridSubStepWidth( qreal subStepWidth )
00173 {
00174     d->subStepWidth = subStepWidth;
00175 }
00176 
00183 qreal GridAttributes::gridSubStepWidth() const
00184 {
00185     return d->subStepWidth;
00186 }
00187 
00205 void GridAttributes::setGridGranularitySequence( KDChartEnums::GranularitySequence sequence )
00206 {
00207     d->sequence = sequence;
00208 }
00209 
00216 KDChartEnums::GranularitySequence GridAttributes::gridGranularitySequence() const
00217 {
00218     return d->sequence;
00219 }
00220 
00221 void GridAttributes::setAdjustBoundsToGrid( bool adjustLower, bool adjustUpper )
00222 {
00223     d->adjustLower = adjustLower;
00224     d->adjustUpper = adjustUpper;
00225 }
00226 bool GridAttributes::adjustLowerBoundToGrid() const
00227 {
00228     return d->adjustLower;
00229 }
00230 bool GridAttributes::adjustUpperBoundToGrid() const
00231 {
00232     return d->adjustUpper;
00233 }
00234 
00235 void GridAttributes::setGridPen( const QPen & pen )
00236 {
00237     d->pen = pen;
00238     d->pen.setCapStyle( Qt::FlatCap );
00239 }
00240 
00241 QPen GridAttributes::gridPen() const
00242 {
00243     return d->pen;
00244 }
00245 
00246 void GridAttributes::setSubGridVisible( bool visible )
00247 {
00248     d->subVisible = visible;
00249 }
00250 
00251 bool GridAttributes::isSubGridVisible() const
00252 {
00253     return d->subVisible;
00254 }
00255 
00256 void GridAttributes::setSubGridPen( const QPen & pen )
00257 {
00258     d->subPen = pen;
00259     d->subPen.setCapStyle( Qt::FlatCap );
00260 }
00261 
00262 QPen GridAttributes::subGridPen() const
00263 {
00264     return d->subPen;
00265 }
00266 
00267 void GridAttributes::setOuterLinesVisible( bool visible )
00268 {
00269     d->outerVisible = visible;
00270 }
00271 
00272 bool GridAttributes::isOuterLinesVisible() const
00273 {
00274     return d->outerVisible;
00275 }
00276 
00277 void GridAttributes::setZeroLinePen( const QPen & pen )
00278 {
00279     d->zeroPen = pen;
00280     d->zeroPen.setCapStyle( Qt::FlatCap );
00281 }
00282 
00283 QPen GridAttributes::zeroLinePen() const
00284 {
00285     return d->zeroPen;
00286 }
00287 
00288 #if !defined(QT_NO_DEBUG_STREAM)
00289 QDebug operator<<(QDebug dbg, const KDChart::GridAttributes& a)
00290 {
00291     dbg << "KDChart::GridAttributes("
00292             << "visible="<<a.isGridVisible()
00293             << "subVisible="<<a.isSubGridVisible()
00294             // KDChartEnums::GranularitySequence sequence;
00295             << "stepWidth=" << a.gridStepWidth()
00296             << "subStepWidth=" << a.gridSubStepWidth()
00297             << "pen="<<a.gridPen()
00298             << "subPen="<<a.subGridPen()
00299             << "zeroPen="<<a.zeroLinePen()
00300             << ")";
00301     return dbg;
00302 }
00303 #endif /* QT_NO_DEBUG_STREAM */
00304 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/