KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
KDChartGridAttributes.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 
23 #include "KDChartGridAttributes.h"
24 
25 #include <QPen>
26 #include <QDebug>
27 
28 #include <KDABLibFakes>
29 
30 #define d d_func()
31 
32 using namespace KDChart;
33 
34 class GridAttributes::Private
35 {
36  friend class GridAttributes;
37 public:
38  Private();
39 private:
40  bool visible;
42  qreal stepWidth;
43  qreal subStepWidth;
44  bool adjustLower;
45  bool adjustUpper;
46  QPen pen;
47  bool subVisible;
48  QPen subPen;
49  bool outerVisible;
50  QPen zeroPen;
51 };
52 
53 GridAttributes::Private::Private()
54  : visible( true ),
55  sequence( KDChartEnums::GranularitySequence_10_20 ),
56  stepWidth( 0.0 ),
57  subStepWidth( 0.0 ),
58  adjustLower( true ),
59  adjustUpper( true ),
60  pen( QColor(0xa0, 0xa0, 0xa0 ) ),
61  subVisible( true ),
62  subPen( QColor(0xd0, 0xd0, 0xd0 ) ),
63  outerVisible( true ),
64  zeroPen( QColor( 0x00, 0x00, 0x80 ) )
65 {
66  pen.setCapStyle( Qt::FlatCap );
67  subPen.setCapStyle( Qt::FlatCap );
68  zeroPen.setCapStyle( Qt::FlatCap );
69 }
70 
71 
72 GridAttributes::GridAttributes()
73  : _d( new Private() )
74 {
75  // this bloc left empty intentionally
76 }
77 
79  : _d( new Private( *r.d ) )
80 {
81 }
82 
84 {
85  if ( this == &r )
86  return *this;
87 
88  *d = *r.d;
89 
90  return *this;
91 }
92 
94 {
95  delete _d; _d = 0;
96 }
97 
98 
100 {
101  return isGridVisible() == r.isGridVisible() &&
105  gridPen() == r.gridPen() &&
107  subGridPen() == r.subGridPen() &&
109  zeroLinePen() == r.zeroLinePen();
110 }
111 
112 
113 void GridAttributes::setGridVisible( bool visible )
114 {
115  d->visible = visible;
116 }
117 
119 {
120  return d->visible;
121 }
122 
141 void GridAttributes::setGridStepWidth( qreal stepWidth )
142 {
143  d->stepWidth = stepWidth;
144 }
145 
153 {
154  return d->stepWidth;
155 }
156 
157 
172 void GridAttributes::setGridSubStepWidth( qreal subStepWidth )
173 {
174  d->subStepWidth = subStepWidth;
175 }
176 
184 {
185  return d->subStepWidth;
186 }
187 
206 {
207  d->sequence = sequence;
208 }
209 
217 {
218  return d->sequence;
219 }
220 
221 void GridAttributes::setAdjustBoundsToGrid( bool adjustLower, bool adjustUpper )
222 {
223  d->adjustLower = adjustLower;
224  d->adjustUpper = adjustUpper;
225 }
227 {
228  return d->adjustLower;
229 }
231 {
232  return d->adjustUpper;
233 }
234 
235 void GridAttributes::setGridPen( const QPen & pen )
236 {
237  d->pen = pen;
238  d->pen.setCapStyle( Qt::FlatCap );
239 }
240 
242 {
243  return d->pen;
244 }
245 
247 {
248  d->subVisible = visible;
249 }
250 
252 {
253  return d->subVisible;
254 }
255 
256 void GridAttributes::setSubGridPen( const QPen & pen )
257 {
258  d->subPen = pen;
259  d->subPen.setCapStyle( Qt::FlatCap );
260 }
261 
263 {
264  return d->subPen;
265 }
266 
268 {
269  d->outerVisible = visible;
270 }
271 
273 {
274  return d->outerVisible;
275 }
276 
277 void GridAttributes::setZeroLinePen( const QPen & pen )
278 {
279  d->zeroPen = pen;
280  d->zeroPen.setCapStyle( Qt::FlatCap );
281 }
282 
284 {
285  return d->zeroPen;
286 }
287 
288 #if !defined(QT_NO_DEBUG_STREAM)
289 QDebug operator<<(QDebug dbg, const KDChart::GridAttributes& a)
290 {
291  dbg << "KDChart::GridAttributes("
292  << "visible="<<a.isGridVisible()
293  << "subVisible="<<a.isSubGridVisible()
294  // KDChartEnums::GranularitySequence sequence;
295  << "stepWidth=" << a.gridStepWidth()
296  << "subStepWidth=" << a.gridSubStepWidth()
297  << "pen="<<a.gridPen()
298  << "subPen="<<a.subGridPen()
299  << "zeroPen="<<a.zeroLinePen()
300  << ")";
301  return dbg;
302 }
303 #endif /* QT_NO_DEBUG_STREAM */
304 

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