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