File indexing completed on 2024-05-12 15:54:18

0001 /*
0002  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
0003  *
0004  * This file is part of the KD Chart library.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
0018  */
0019 
0020 #include "KChartLineAttributes.h"
0021 
0022 #include "KChartMath_p.h"
0023 
0024 #include <QDebug>
0025 
0026 #define d d_func()
0027 
0028 using namespace KChart;
0029 
0030 class Q_DECL_HIDDEN LineAttributes::Private
0031 {
0032     friend class LineAttributes;
0033 public:
0034     Private();
0035 
0036 private:
0037     //Areas
0038     MissingValuesPolicy missingValuesPolicy;
0039     bool displayArea;
0040     bool visible;
0041     uint transparency;
0042     int areaBoundingDataset;
0043 };
0044 
0045 
0046 LineAttributes::Private::Private()
0047     : missingValuesPolicy( MissingValuesAreBridged )
0048     , displayArea( false )
0049     , visible( true )
0050     , transparency( 255 )
0051     , areaBoundingDataset( -1 )
0052 {
0053 }
0054 
0055 
0056 LineAttributes::LineAttributes()
0057     : _d( new Private() )
0058 {
0059 }
0060 
0061 LineAttributes::LineAttributes( const LineAttributes& r )
0062     : _d( new Private( *r.d ) )
0063 {
0064 }
0065 
0066 LineAttributes& LineAttributes::operator= ( const LineAttributes& r )
0067 {
0068     if ( this == &r )
0069         return *this;
0070 
0071     *d = *r.d;
0072 
0073     return *this;
0074 }
0075 
0076 LineAttributes::~LineAttributes()
0077 {
0078     delete _d; _d = nullptr;
0079 }
0080 
0081 bool LineAttributes::operator==( const LineAttributes& r ) const
0082 {
0083     return
0084         missingValuesPolicy() == r.missingValuesPolicy() &&
0085         displayArea() == r.displayArea() &&
0086         isVisible() == r.isVisible() &&
0087         transparency() == r.transparency() &&
0088         areaBoundingDataset() == r.areaBoundingDataset();
0089 }
0090 
0091 void LineAttributes::setMissingValuesPolicy( MissingValuesPolicy policy )
0092 {
0093     d->missingValuesPolicy = policy;
0094 }
0095 
0096 LineAttributes::MissingValuesPolicy LineAttributes::missingValuesPolicy() const
0097 {
0098     return d->missingValuesPolicy;
0099 }
0100 
0101 void LineAttributes::setDisplayArea( bool display )
0102 {
0103     d->displayArea = display;
0104 }
0105 
0106 bool LineAttributes::displayArea() const
0107 {
0108    return d->displayArea;
0109 }
0110 
0111 void LineAttributes::setTransparency( uint alpha )
0112 {
0113      if ( alpha > 255 )
0114         alpha = 255;
0115     d->transparency = alpha;
0116 }
0117 
0118 uint LineAttributes::transparency() const
0119 {
0120      return d->transparency;
0121 }
0122 
0123 void LineAttributes::setAreaBoundingDataset( int dataset )
0124 {
0125    d->areaBoundingDataset = dataset;
0126 }
0127 
0128 int LineAttributes::areaBoundingDataset() const
0129 {
0130     return d->areaBoundingDataset;
0131 }
0132 
0133 void LineAttributes::setVisible( bool visible )
0134 {
0135     d->visible = visible;
0136 }
0137 
0138 bool LineAttributes::isVisible() const
0139 {
0140     return d->visible;
0141 }
0142 
0143 #if !defined(QT_NO_DEBUG_STREAM)
0144 QDebug operator<<(QDebug dbg, const KChart::LineAttributes& a)
0145 {
0146     dbg << "KChart::LineAttributes("
0147             //     MissingValuesPolicy missingValuesPolicy;
0148             << "bool="<<a.displayArea()
0149             << "visible="<<a.isVisible()
0150             << "transparency="<<a.transparency()
0151             << "areaBoundingDataset="<<a.areaBoundingDataset()
0152             << ")";
0153     return dbg;
0154 
0155 }
0156 #endif /* QT_NO_DEBUG_STREAM */