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