KDChartLeveyJenningsGridAttributes.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2007 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 "KDChartLeveyJenningsGridAttributes.h"
00027 
00028 #include <QBrush>
00029 #include <QMap>
00030 #include <QPen>
00031 
00032 #include <KDABLibFakes>
00033 
00034 #define d d_func()
00035 
00036 using namespace KDChart;
00037 
00038 class LeveyJenningsGridAttributes::Private
00039 {
00040     friend class LeveyJenningsGridAttributes;
00041 public:
00042     Private();
00043 private:
00044     QMap< GridType, bool > visible;
00045     QMap< GridType, QPen > pens;
00046     QMap< LeveyJenningsGridAttributes::Range, QBrush > rangeBrushes;
00047 };
00048 
00049 LeveyJenningsGridAttributes::Private::Private()
00050 {
00051     pens[ Calculated ].setCapStyle( Qt::FlatCap );
00052     pens[ Calculated ].setColor( Qt::blue );
00053     pens[ Expected ].setCapStyle( Qt::FlatCap );
00054     pens[ Expected ].setColor( Qt::black );
00055     
00056     visible[ Calculated ] = true;
00057     visible[ Expected ] = true;
00058     
00059     rangeBrushes[ LeveyJenningsGridAttributes::CriticalRange ] = QBrush( QColor( 255, 255, 192 ) );
00060     rangeBrushes[ LeveyJenningsGridAttributes::OutOfRange ]    = QBrush( QColor( 255, 128, 128 ) );
00061 }
00062 
00063 
00064 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes()
00065     : _d( new Private() )
00066 {
00067     // this bloc left empty intentionally
00068 }
00069 
00070 LeveyJenningsGridAttributes::LeveyJenningsGridAttributes( const LeveyJenningsGridAttributes& r )
00071     : _d( new Private( *r.d ) )
00072 {
00073 }
00074 
00075 LeveyJenningsGridAttributes & LeveyJenningsGridAttributes::operator=( const LeveyJenningsGridAttributes& r )
00076 {
00077     if( this == &r )
00078         return *this;
00079 
00080     *d = *r.d;
00081 
00082     return *this;
00083 }
00084 
00085 LeveyJenningsGridAttributes::~LeveyJenningsGridAttributes()
00086 {
00087     delete _d; _d = 0;
00088 }
00089 
00090 
00091 bool LeveyJenningsGridAttributes::operator==( const LeveyJenningsGridAttributes& r ) const
00092 {
00093     return  isGridVisible( Expected ) == r.isGridVisible( Expected ) &&
00094             isGridVisible( Calculated ) == r.isGridVisible( Calculated ) &&
00095             gridPen( Expected ) == r.gridPen( Expected ) &&
00096             gridPen( Calculated ) == r.gridPen( Calculated );
00097 }
00098 
00099 void LeveyJenningsGridAttributes::setRangeBrush( Range range, const QBrush& brush )
00100 {
00101     d->rangeBrushes[ range ] = brush;
00102 }
00103 
00104 QBrush LeveyJenningsGridAttributes::rangeBrush( Range range ) const
00105 {
00106     return d->rangeBrushes[ range ];
00107 }
00108 
00109 
00110 void LeveyJenningsGridAttributes::setGridVisible( GridType type, bool visible )
00111 {
00112     d->visible[ type ] = visible;
00113 }
00114 
00115 bool LeveyJenningsGridAttributes::isGridVisible( GridType type ) const
00116 {
00117     return d->visible[ type ];
00118 }
00119 
00120 void LeveyJenningsGridAttributes::setGridPen( GridType type, const QPen& pen )
00121 {
00122     d->pens[ type ] = pen;
00123     d->pens[ type ].setCapStyle( Qt::FlatCap );
00124 }
00125 
00126 QPen LeveyJenningsGridAttributes::gridPen( GridType type ) const
00127 {
00128     return d->pens[ type ];
00129 }

Generated on Thu Mar 4 23:19:11 2010 for KD Chart 2 by  doxygen 1.5.4