00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2010 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 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 "KDChartMarkerAttributes.h" 00024 #include <QColor> 00025 #include <QMap> 00026 #include <QPen> 00027 #include <QSizeF> 00028 #include <QDebug> 00029 #include <qglobal.h> 00030 00031 #include <KDABLibFakes> 00032 00033 using namespace KDChart; 00034 00035 class MarkerAttributes::Private 00036 { 00037 friend class ::KDChart::MarkerAttributes; 00038 public: 00039 Private(); 00040 private: 00041 bool visible; 00042 QMap<uint,MarkerStyle> markerStylesMap; 00043 MarkerStyle markerStyle; 00044 QSizeF markerSize; 00045 QColor markerColor; 00046 QPen markerPen; 00047 }; 00048 00049 MarkerAttributes::Private::Private() 00050 : visible( false ), 00051 markerStyle( MarkerSquare ), 00052 markerSize( 10, 10 ), 00053 markerPen( Qt::black ) 00054 { 00055 } 00056 00057 00058 MarkerAttributes::MarkerAttributes() 00059 : _d( new Private ) 00060 { 00061 00062 } 00063 00064 MarkerAttributes::MarkerAttributes( const MarkerAttributes& r ) 00065 : _d( new Private( *r._d ) ) 00066 { 00067 00068 } 00069 00070 MarkerAttributes & MarkerAttributes::operator=( const MarkerAttributes& r ) 00071 { 00072 MarkerAttributes copy( r ); 00073 copy.swap( *this ); 00074 return *this; 00075 } 00076 00077 MarkerAttributes::~MarkerAttributes() 00078 { 00079 delete _d; _d = 0; 00080 } 00081 00082 #define d d_func() 00083 00084 bool MarkerAttributes::operator==( const MarkerAttributes& r ) const 00085 { 00086 /* 00087 qDebug() << "MarkerAttributes::operator== finds" 00088 << "b" << (isVisible() == r.isVisible()) 00089 << "c" << (markerStylesMap() == r.markerStylesMap()) 00090 << "d" << (markerStyle() == r.markerStyle()) << markerStyle() <<r.markerStyle() 00091 << "e" << (markerSize() == r.markerSize()) 00092 << "f" << (markerColor() == r.markerColor()) 00093 << "g" << (pen() == r.pen()) 00094 << "h" << (markerColor() == r.markerColor()) << markerColor() << r.markerColor(); 00095 */ 00096 return ( isVisible() == r.isVisible() && 00097 markerStylesMap() == r.markerStylesMap() && 00098 markerStyle() == r.markerStyle() && 00099 markerSize() == r.markerSize() && 00100 markerColor() == r.markerColor() && 00101 pen() == r.pen() ); 00102 } 00103 00104 00105 00106 void MarkerAttributes::setVisible( bool visible ) 00107 { 00108 d->visible = visible; 00109 } 00110 00111 bool MarkerAttributes::isVisible() const 00112 { 00113 return d->visible; 00114 } 00115 00116 void MarkerAttributes::setMarkerStylesMap( const MarkerStylesMap & map ) 00117 { 00118 d->markerStylesMap = map; 00119 } 00120 00121 MarkerAttributes::MarkerStylesMap MarkerAttributes::markerStylesMap() const 00122 { 00123 return d->markerStylesMap; 00124 } 00125 00126 void MarkerAttributes::setMarkerStyle( MarkerStyle style ) 00127 { 00128 d->markerStyle = style; 00129 } 00130 00131 MarkerAttributes::MarkerStyle MarkerAttributes::markerStyle() const 00132 { 00133 return d->markerStyle; 00134 } 00135 00136 void MarkerAttributes::setMarkerSize( const QSizeF& size ) 00137 { 00138 d->markerSize = size; 00139 } 00140 00141 QSizeF MarkerAttributes::markerSize() const 00142 { 00143 return d->markerSize; 00144 } 00145 00146 void MarkerAttributes::setMarkerColor( const QColor& color ) 00147 { 00148 d->markerColor = color; 00149 } 00150 00151 QColor MarkerAttributes::markerColor() const 00152 { 00153 return d->markerColor; 00154 } 00155 00156 void MarkerAttributes::setPen( const QPen& pen ) 00157 { 00158 d->markerPen = pen; 00159 } 00160 00161 QPen MarkerAttributes::pen() const 00162 { 00163 return d->markerPen; 00164 } 00165 00166 #undef d 00167 00168 #ifndef QT_NO_DEBUG_STREAM 00169 QDebug operator<<( QDebug dbg, const MarkerAttributes & ma ) { 00170 return dbg << "KDChart::MarkerAttributes(" 00171 << "visible=" << ma.isVisible() 00172 << "markerStylesMap=" << ma.markerStylesMap() 00173 << "markerStyle=" << ma.markerStyle() 00174 << "markerColor=" << ma.markerColor() 00175 << "pen=" << ma.pen() 00176 << ")"; 00177 } 00178 #endif 00179