KChart

KChartLineAttributes.cpp
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 
46 LineAttributes::Private::Private()
47  : missingValuesPolicy( MissingValuesAreBridged )
48  , displayArea( false )
49  , visible( true )
50  , transparency( 255 )
51  , areaBoundingDataset( -1 )
52 {
53 }
54 
55 
56 LineAttributes::LineAttributes()
57  : _d( new Private() )
58 {
59 }
60 
61 LineAttributes::LineAttributes( const LineAttributes& r )
62  : _d( new Private( *r.d ) )
63 {
64 }
65 
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 
76 LineAttributes::~LineAttributes()
77 {
78  delete _d; _d = nullptr;
79 }
80 
81 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 
91 void LineAttributes::setMissingValuesPolicy( MissingValuesPolicy policy )
92 {
93  d->missingValuesPolicy = policy;
94 }
95 
96 LineAttributes::MissingValuesPolicy LineAttributes::missingValuesPolicy() const
97 {
98  return d->missingValuesPolicy;
99 }
100 
101 void LineAttributes::setDisplayArea( bool display )
102 {
103  d->displayArea = display;
104 }
105 
106 bool LineAttributes::displayArea() const
107 {
108  return d->displayArea;
109 }
110 
111 void LineAttributes::setTransparency( uint alpha )
112 {
113  if ( alpha > 255 )
114  alpha = 255;
115  d->transparency = alpha;
116 }
117 
118 uint LineAttributes::transparency() const
119 {
120  return d->transparency;
121 }
122 
124 {
125  d->areaBoundingDataset = dataset;
126 }
127 
128 int LineAttributes::areaBoundingDataset() const
129 {
130  return d->areaBoundingDataset;
131 }
132 
133 void LineAttributes::setVisible( bool visible )
134 {
135  d->visible = visible;
136 }
137 
138 bool LineAttributes::isVisible() const
139 {
140  return d->visible;
141 }
142 
143 #if !defined(QT_NO_DEBUG_STREAM)
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 */
void setAreaBoundingDataset(int dataset)
Sets the lower or upper (depending on the displayed value being positive or negative, resp.) bounding line (i.e., the dataset with the line data).
Set of attributes for changing the appearance of line charts.
void setVisible(bool visible)
Determines if lines are to be drawn or not.
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
MissingValuesPolicy
MissingValuesPolicy specifies how a missing value will be shown in a line diagram.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 29 2020 22:42:41 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.