KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
KDChartDataValueAttributes.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
24 
25 #include <QVariant>
26 #include <QDebug>
28 #include "KDChartPosition.h"
29 #include <KDChartTextAttributes.h>
30 #include <KDChartFrameAttributes.h>
33 
34 #include <KDABLibFakes>
35 
36 // FIXME till
37 #define KDCHART_DATA_VALUE_AUTO_DIGITS 4
38 
39 
40 #define d d_func()
41 
42 using namespace KDChart;
43 
44 class DataValueAttributes::Private
45 {
46  friend class DataValueAttributes;
47 public:
48  Private();
49 private:
54  QString prefix;
55  QString suffix;
56  QString dataLabel;
57  RelativePosition negativeRelPos;
58  RelativePosition positiveRelPos;
59  qint16 decimalDigits;
60  qint16 powerOfTenDivisor;
61  bool visible : 1;
62  bool showInfinite : 1;
63  bool showRepetitiveDataLabels : 1;
65  bool usePercentage : 1;
67 };
68 
69 DataValueAttributes::Private::Private() :
70  decimalDigits( KDCHART_DATA_VALUE_AUTO_DIGITS ),
71  powerOfTenDivisor( 0 ),
72  visible( false ),
73  showInfinite( true )
74 {
76  textAttributes.setFontSize( me );
77  me.setValue( 8.0 );
78  me.setCalculationMode( KDChartEnums::MeasureCalculationModeAbsolute );
79  textAttributes.setMinimalFontSize( me );
80  textAttributes.setRotation( -45 );
81 
82  // we set the Position to unknown: so the diagrams can take their own decisions
83  positiveRelPos.setReferencePosition( Position::Unknown );
84  negativeRelPos.setReferencePosition( Position::Unknown );
85 
86  positiveRelPos.setAlignment( Qt::AlignTop | Qt::AlignRight );
87  negativeRelPos.setAlignment( Qt::AlignBottom | Qt::AlignRight );
88 
89  showRepetitiveDataLabels = false;
90  showOverlappingDataLabels = false;
91 
92  usePercentage = false;
93  mirrorNegativeValueTextRotation = false;
94 }
95 
96 
97 DataValueAttributes::DataValueAttributes()
98  : _d( new Private() )
99 {
100 }
101 
103  : _d( new Private( *r.d ) )
104 {
105 }
106 
108 {
109  if ( this == &r )
110  return *this;
111 
112  *d = *r.d;
113 
114  return *this;
115 }
116 
118 {
119  delete _d; _d = 0;
120 }
121 
122 
124 {
125  return isVisible() == r.isVisible() &&
126  textAttributes() == r.textAttributes() &&
127  frameAttributes() == r.frameAttributes() &&
130  decimalDigits() == r.decimalDigits() &&
131  prefix() == r.prefix() &&
132  suffix() == r.suffix() &&
133  dataLabel() == r.dataLabel() &&
134  powerOfTenDivisor() == r.powerOfTenDivisor() &&
135  showInfinite() == r.showInfinite() &&
140  usePercentage() == r.usePercentage() &&
142 }
143 
144 /*static*/
146 {
147  static const DataValueAttributes theDefaultDataValueAttributes;
148  return theDefaultDataValueAttributes;
149 }
150 
151 /*static*/
153 {
154  static const QVariant theDefaultDataValueAttributesVariant = qVariantFromValue(defaultAttributes());
155  return theDefaultDataValueAttributesVariant;
156 }
157 
158 
160 {
161  d->visible = visible;
162 }
163 
165 {
166  return d->visible;
167 }
168 
170 {
171  d->textAttributes = a;
172 }
173 
175 {
176  return d->textAttributes;
177 }
178 
180 {
181  d->frameAttributes = a;
182 }
183 
185 {
186  return d->frameAttributes;
187 }
188 
190 {
191  d->backgroundAttributes = a;
192 }
193 
195 {
196  return d->backgroundAttributes;
197 }
198 
200 {
201  d->markerAttributes = a;
202 }
203 
205 {
206  return d->markerAttributes;
207 }
208 
210 {
211  d->mirrorNegativeValueTextRotation = enable;
212 }
213 
215 {
216  return d->mirrorNegativeValueTextRotation;
217 }
218 
220 {
221  d->usePercentage = enable;
222 }
223 
225 {
226  return d->usePercentage;
227 }
228 
230 {
231  d->decimalDigits = digits;
232 }
233 
235 {
236  return d->decimalDigits;
237 }
238 
239 void DataValueAttributes::setPrefix( const QString prefixString )
240 {
241  d->prefix = prefixString;
242 }
243 
245 {
246  return d->prefix;
247 }
248 
249 void DataValueAttributes::setSuffix( const QString suffixString )
250 {
251  d->suffix = suffixString;
252 }
253 
255 {
256  return d->suffix;
257 }
258 
259 void DataValueAttributes::setDataLabel( const QString label )
260 {
261  d->dataLabel = label;
262 }
263 
265 {
266  return d->dataLabel;
267 }
268 
270 {
271  return d->showRepetitiveDataLabels;
272 }
273 
274 void DataValueAttributes::setShowRepetitiveDataLabels( bool showRepetitiveDataLabels )
275 {
276  d->showRepetitiveDataLabels = showRepetitiveDataLabels;
277 }
278 
280 {
281  return d->showOverlappingDataLabels;
282 }
283 
284 void DataValueAttributes::setShowOverlappingDataLabels( bool showOverlappingDataLabels )
285 {
286  d->showOverlappingDataLabels = showOverlappingDataLabels;
287 }
288 
289 void DataValueAttributes::setPowerOfTenDivisor( int powerOfTenDivisor )
290 {
291  d->powerOfTenDivisor = powerOfTenDivisor;
292 }
293 
294 int DataValueAttributes::powerOfTenDivisor() const
295 {
296  return d->powerOfTenDivisor;
297 }
298 
299 void DataValueAttributes::setShowInfinite( bool infinite )
300 {
301  d->showInfinite = infinite;
302 }
303 
304 bool DataValueAttributes::showInfinite() const
305 {
306  return d->showInfinite;
307 }
308 
310 {
311  d->negativeRelPos = relPosition;
312 }
313 
315 {
316  return d->negativeRelPos;
317 }
318 
320 {
321  d->positiveRelPos = relPosition;
322 }
323 
325 {
326  return d->positiveRelPos;
327 }
328 
329 #if !defined(QT_NO_DEBUG_STREAM)
330 QDebug operator<<(QDebug dbg, const KDChart::DataValueAttributes& val )
331 {
332  dbg << "RelativePosition DataValueAttributes("
333  << "visible="<<val.isVisible()
334  << "textattributes="<<val.textAttributes()
335  << "frameattributes="<<val.frameAttributes()
336  << "backgroundattributes="<<val.backgroundAttributes()
337  << "decimaldigits="<<val.decimalDigits()
338  << "poweroftendivisor="<<val.powerOfTenDivisor()
339  << "showinfinite="<<val.showInfinite()
340  << "negativerelativeposition="<<val.negativePosition()
341  << "positiverelativeposition="<<val.positivePosition()
342  << "showRepetitiveDataLabels="<<val.showRepetitiveDataLabels()
343  << "showOverlappingDataLabels="<<val.showOverlappingDataLabels()
344  <<")";
345  return dbg;
346 }
347 #endif /* QT_NO_DEBUG_STREAM */

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/