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