KD Chart API Documentation  3.1
KDChartGridAttributes.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Chart library.
4 **
5 ** SPDX-FileCopyrightText: 2001 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #include "KDChartGridAttributes.h"
12 
13 #include <QDebug>
14 #include <QPen>
15 
16 #include <KDABLibFakes>
17 
18 #define d d_func()
19 
20 using namespace KDChart;
21 
22 class GridAttributes::Private
23 {
24  friend class GridAttributes;
25 
26 public:
27  Private();
28 
29 private:
30  bool visible = true;
32  bool linesOnAnnotations = false;
33  qreal stepWidth = 0.0;
34  qreal subStepWidth = 0.0;
35  bool adjustLower = true;
36  bool adjustUpper = true;
37  QPen pen;
38  bool subVisible = true;
39  QPen subPen;
40  bool outerVisible = true;
41  QPen zeroPen;
42 };
43 
44 GridAttributes::Private::Private()
45  : pen(QColor(0xa0, 0xa0, 0xa0))
46  , subPen(QColor(0xd0, 0xd0, 0xd0))
47  , zeroPen(QColor(0x00, 0x00, 0x80))
48 {
49  pen.setCapStyle(Qt::FlatCap);
50  subPen.setCapStyle(Qt::FlatCap);
51  zeroPen.setCapStyle(Qt::FlatCap);
52 }
53 
54 GridAttributes::GridAttributes()
55  : _d(new Private())
56 {
57  // this block left empty intentionally
58 }
59 
61  : _d(new Private(*r.d))
62 {
63 }
64 
66 {
67  if (this == &r)
68  return *this;
69 
70  *d = *r.d;
71 
72  return *this;
73 }
74 
76 {
77  delete _d;
78  _d = nullptr;
79 }
80 
82 {
84 }
85 
87 {
88  d->visible = visible;
89 }
90 
92 {
93  return d->visible;
94 }
95 
97 {
98  d->linesOnAnnotations = b;
99 }
100 
102 {
103  return d->linesOnAnnotations;
104 }
105 
124 void GridAttributes::setGridStepWidth(qreal stepWidth)
125 {
126  d->stepWidth = stepWidth;
127 }
128 
136 {
137  return d->stepWidth;
138 }
139 
154 void GridAttributes::setGridSubStepWidth(qreal subStepWidth)
155 {
156  d->subStepWidth = subStepWidth;
157 }
158 
166 {
167  return d->subStepWidth;
168 }
169 
188 {
189  d->sequence = sequence;
190 }
191 
199 {
200  return d->sequence;
201 }
202 
203 void GridAttributes::setAdjustBoundsToGrid(bool adjustLower, bool adjustUpper)
204 {
205  d->adjustLower = adjustLower;
206  d->adjustUpper = adjustUpper;
207 }
209 {
210  return d->adjustLower;
211 }
213 {
214  return d->adjustUpper;
215 }
216 
217 void GridAttributes::setGridPen(const QPen &pen)
218 {
219  d->pen = pen;
220  d->pen.setCapStyle(Qt::FlatCap);
221 }
222 
224 {
225  return d->pen;
226 }
227 
229 {
230  d->subVisible = visible;
231 }
232 
234 {
235  return d->subVisible;
236 }
237 
238 void GridAttributes::setSubGridPen(const QPen &pen)
239 {
240  d->subPen = pen;
241  d->subPen.setCapStyle(Qt::FlatCap);
242 }
243 
245 {
246  return d->subPen;
247 }
248 
250 {
251  d->outerVisible = visible;
252 }
253 
255 {
256  return d->outerVisible;
257 }
258 
259 void GridAttributes::setZeroLinePen(const QPen &pen)
260 {
261  d->zeroPen = pen;
262  d->zeroPen.setCapStyle(Qt::FlatCap);
263 }
264 
266 {
267  return d->zeroPen;
268 }
269 
270 #if !defined(QT_NO_DEBUG_STREAM)
271 QDebug operator<<(QDebug dbg, const KDChart::GridAttributes &a)
272 {
273  dbg << "KDChart::GridAttributes("
274  << "visible=" << a.isGridVisible()
275  << "subVisible=" << a.isSubGridVisible()
276  // KDChartEnums::GranularitySequence sequence;
277  << "stepWidth=" << a.gridStepWidth()
278  << "subStepWidth=" << a.gridSubStepWidth()
279  << "pen=" << a.gridPen()
280  << "subPen=" << a.subGridPen()
281  << "zeroPen=" << a.zeroLinePen()
282  << ")";
283  return dbg;
284 }
285 #endif /* QT_NO_DEBUG_STREAM */
#define d
@ GranularitySequence_10_20
Definition: KDChartEnums.h:85
A set of attributes controlling the appearance of grids.
void setGridVisible(bool visible)
KDChartEnums::GranularitySequence gridGranularitySequence() const
GridAttributes & operator=(const GridAttributes &)
void setGridSubStepWidth(qreal subStepWidth=0.0)
void setGridPen(const QPen &pen)
void setZeroLinePen(const QPen &pen)
bool operator==(const GridAttributes &) const
void setGridGranularitySequence(KDChartEnums::GranularitySequence sequence)
void setGridStepWidth(qreal stepWidth=0.0)
void setAdjustBoundsToGrid(bool adjustLower, bool adjustUpper)
void setOuterLinesVisible(bool visible)
void setSubGridPen(const QPen &pen)
void setSubGridVisible(bool visible)
QDebug operator<<(QDebug stream, const DataDimension &r)

© 2001 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-chart/
Generated by doxygen 1.9.1