KChart

KChartBarAttributes.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 "KChartBarAttributes.h"
21 
22 #include "KChartMath_p.h"
23 
24 #include <qglobal.h>
25 
26 #define d d_func()
27 
28 
29 using namespace KChart;
30 
31 class Q_DECL_HIDDEN BarAttributes::Private
32 {
33  friend class BarAttributes;
34 public:
35  Private();
36 
37 private:
38  qreal datasetGap;
39  bool useFixedDatasetGap;
40  qreal valueBlockGap;
41  bool useFixedValueBlockGap;
42  qreal barWidth;
43  bool useFixedBarWidth;
44  bool drawSolidExcessArrows;
45  qreal groupGapFactor;
46  qreal barGapFactor;
47 };
48 
49 
50 BarAttributes::Private::Private()
51  :datasetGap( 6 ),
52  useFixedDatasetGap( false ),
53  valueBlockGap( 24 ),
54  useFixedValueBlockGap( false ),
55  barWidth( -1 ),
56  useFixedBarWidth( false ),
57  drawSolidExcessArrows( false ),
58  groupGapFactor( 2.0 ),
59  barGapFactor( 0.4 )
60 {
61 }
62 
63 
64 BarAttributes::BarAttributes()
65  : _d( new Private() )
66 {
67 }
68 
69 BarAttributes::BarAttributes( const BarAttributes& r )
70  : _d( new Private( *r.d ) )
71 {
72 }
73 
74 BarAttributes& BarAttributes::operator= ( const BarAttributes& r )
75 {
76  if ( this == &r )
77  return *this;
78 
79  *d = *r.d;
80 
81  return *this;
82 }
83 
84 BarAttributes::~BarAttributes()
85 {
86  delete _d; _d = nullptr;
87 }
88 
89 
90 bool BarAttributes::operator==( const BarAttributes& r ) const
91 {
92  if ( fixedDataValueGap() == r.fixedDataValueGap() &&
93  useFixedDataValueGap() == r.useFixedDataValueGap() &&
94  fixedValueBlockGap() == r.fixedValueBlockGap() &&
95  useFixedValueBlockGap() == r.useFixedValueBlockGap() &&
96  fixedBarWidth() == r.fixedBarWidth() &&
97  useFixedBarWidth() == r.useFixedBarWidth() &&
98  groupGapFactor() == r.groupGapFactor() &&
99  barGapFactor() == r.barGapFactor() &&
100  drawSolidExcessArrows() == r.drawSolidExcessArrows() )
101  return true;
102  else
103  return false;
104 }
105 
106 
107 void BarAttributes::setFixedDataValueGap( qreal gap )
108 {
109  d->datasetGap = gap;
110 }
111 
112 qreal BarAttributes::fixedDataValueGap() const
113 {
114  return d->datasetGap;
115 }
116 
117 void BarAttributes::setUseFixedDataValueGap( bool gapIsFixed )
118 {
119  d->useFixedDatasetGap = gapIsFixed;
120 }
121 
122 bool BarAttributes::useFixedDataValueGap() const
123 {
124  return d->useFixedDatasetGap;
125 }
126 
127 void BarAttributes::setFixedValueBlockGap( qreal gap )
128 {
129  d->valueBlockGap = gap;
130 }
131 
132 qreal BarAttributes::fixedValueBlockGap() const
133 {
134  return d->valueBlockGap;
135 }
136 
137 void BarAttributes::setUseFixedValueBlockGap( bool gapIsFixed )
138 {
139  d->useFixedValueBlockGap = gapIsFixed;
140 }
141 
142 bool BarAttributes::useFixedValueBlockGap() const
143 {
144  return d->useFixedValueBlockGap;
145 }
146 
147 void BarAttributes::setFixedBarWidth( qreal width )
148 {
149  d->barWidth = width;
150 }
151 
152 qreal BarAttributes::fixedBarWidth() const
153 {
154 
155  return d->barWidth;
156 }
157 
158 void BarAttributes::setUseFixedBarWidth( bool useFixedBarWidth )
159 {
160  d->useFixedBarWidth = useFixedBarWidth;
161 }
162 
163 bool BarAttributes::useFixedBarWidth() const
164 {
165  return d->useFixedBarWidth;
166 }
167 
168 void BarAttributes::setGroupGapFactor( qreal gapFactor )
169 {
170  d->groupGapFactor = gapFactor;
171 }
172 
173 qreal BarAttributes::groupGapFactor() const
174 {
175  return d->groupGapFactor;
176 }
177 
178 void BarAttributes::setBarGapFactor( qreal gapFactor )
179 {
180  d->barGapFactor = gapFactor;
181 }
182 
183 qreal BarAttributes::barGapFactor() const
184 {
185  return d->barGapFactor;
186 }
187 
188 void BarAttributes::setDrawSolidExcessArrows( bool solidArrows )
189 {
190  d->drawSolidExcessArrows = solidArrows;
191 }
192 
193 bool BarAttributes::drawSolidExcessArrows() const
194 {
195  return d->drawSolidExcessArrows;
196 }
197 
Set of attributes for changing the appearance of bar charts.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jan 20 2021 22:39:30 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.