1 /*
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #include "KChartLineAttributes.h"
21 
22 #include "KChartMath_p.h"
23 
24 #include <QDebug>
25 
26 #define d d_func()
27 
28 using namespace KChart;
29 
30 class Q_DECL_HIDDEN LineAttributes::Private
31 {
32     friend class LineAttributes;
33 public:
34     Private();
35 
36 private:
37     //Areas
38     MissingValuesPolicy missingValuesPolicy;
39     bool displayArea;
40     bool visible;
41     uint transparency;
42     int areaBoundingDataset;
43 };
44 
45 
Private()46 LineAttributes::Private::Private()
47     : missingValuesPolicy( MissingValuesAreBridged )
48     , displayArea( false )
49     , visible( true )
50     , transparency( 255 )
51     , areaBoundingDataset( -1 )
52 {
53 }
54 
55 
LineAttributes()56 LineAttributes::LineAttributes()
57     : _d( new Private() )
58 {
59 }
60 
LineAttributes(const LineAttributes & r)61 LineAttributes::LineAttributes( const LineAttributes& r )
62     : _d( new Private( *r.d ) )
63 {
64 }
65 
operator =(const LineAttributes & r)66 LineAttributes& LineAttributes::operator= ( const LineAttributes& r )
67 {
68     if ( this == &r )
69         return *this;
70 
71     *d = *r.d;
72 
73     return *this;
74 }
75 
~LineAttributes()76 LineAttributes::~LineAttributes()
77 {
78     delete _d; _d = nullptr;
79 }
80 
operator ==(const LineAttributes & r) const81 bool LineAttributes::operator==( const LineAttributes& r ) const
82 {
83     return
84         missingValuesPolicy() == r.missingValuesPolicy() &&
85         displayArea() == r.displayArea() &&
86         isVisible() == r.isVisible() &&
87         transparency() == r.transparency() &&
88         areaBoundingDataset() == r.areaBoundingDataset();
89 }
90 
setMissingValuesPolicy(MissingValuesPolicy policy)91 void LineAttributes::setMissingValuesPolicy( MissingValuesPolicy policy )
92 {
93     d->missingValuesPolicy = policy;
94 }
95 
missingValuesPolicy() const96 LineAttributes::MissingValuesPolicy LineAttributes::missingValuesPolicy() const
97 {
98     return d->missingValuesPolicy;
99 }
100 
setDisplayArea(bool display)101 void LineAttributes::setDisplayArea( bool display )
102 {
103     d->displayArea = display;
104 }
105 
displayArea() const106 bool LineAttributes::displayArea() const
107 {
108    return d->displayArea;
109 }
110 
setTransparency(uint alpha)111 void LineAttributes::setTransparency( uint alpha )
112 {
113      if ( alpha > 255 )
114         alpha = 255;
115     d->transparency = alpha;
116 }
117 
transparency() const118 uint LineAttributes::transparency() const
119 {
120      return d->transparency;
121 }
122 
setAreaBoundingDataset(int dataset)123 void LineAttributes::setAreaBoundingDataset( int dataset )
124 {
125    d->areaBoundingDataset = dataset;
126 }
127 
areaBoundingDataset() const128 int LineAttributes::areaBoundingDataset() const
129 {
130     return d->areaBoundingDataset;
131 }
132 
setVisible(bool visible)133 void LineAttributes::setVisible( bool visible )
134 {
135     d->visible = visible;
136 }
137 
isVisible() const138 bool LineAttributes::isVisible() const
139 {
140     return d->visible;
141 }
142 
143 #if !defined(QT_NO_DEBUG_STREAM)
operator <<(QDebug dbg,const KChart::LineAttributes & a)144 QDebug operator<<(QDebug dbg, const KChart::LineAttributes& a)
145 {
146     dbg << "KChart::LineAttributes("
147             //     MissingValuesPolicy missingValuesPolicy;
148             << "bool="<<a.displayArea()
149             << "visible="<<a.isVisible()
150             << "transparency="<<a.transparency()
151             << "areaBoundingDataset="<<a.areaBoundingDataset()
152             << ")";
153     return dbg;
154 
155 }
156 #endif /* QT_NO_DEBUG_STREAM */
157