KChart

KChartGridAttributes.cpp
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#include "KChartGridAttributes.h"
10
11#include "KChartMath_p.h"
12
13#include <QPen>
14#include <QDebug>
15
16#define d d_func()
17
18using namespace KChart;
19
20class Q_DECL_HIDDEN GridAttributes::Private
21{
22 friend class GridAttributes;
23public:
24 Private();
25private:
26 bool visible;
28 bool linesOnAnnotations;
29 qreal stepWidth;
30 qreal subStepWidth;
31 bool adjustLower;
32 bool adjustUpper;
33 QPen pen;
34 bool subVisible;
35 QPen subPen;
36 bool outerVisible;
37 QPen zeroPen;
38};
39
40GridAttributes::Private::Private()
41 : visible( true ),
42 sequence( KChartEnums::GranularitySequence_10_20 ),
43 linesOnAnnotations( false ),
44 stepWidth( 0.0 ),
45 subStepWidth( 0.0 ),
46 adjustLower( true ),
47 adjustUpper( true ),
48 pen( QColor(0xa0, 0xa0, 0xa0 ) ),
49 subVisible( true ),
50 subPen( QColor(0xd0, 0xd0, 0xd0 ) ),
51 outerVisible( true ),
52 zeroPen( QColor( 0x00, 0x00, 0x80 ) )
53{
54 pen.setCapStyle( Qt::FlatCap );
55 subPen.setCapStyle( Qt::FlatCap );
56 zeroPen.setCapStyle( Qt::FlatCap );
57}
58
59
60GridAttributes::GridAttributes()
61 : _d( new Private() )
62{
63 // this block left empty intentionally
64}
65
66GridAttributes::GridAttributes( const GridAttributes& r )
67 : _d( new Private( *r.d ) )
68{
69}
70
71GridAttributes & GridAttributes::operator=( const GridAttributes& r )
72{
73 if ( this == &r )
74 return *this;
75
76 *d = *r.d;
77
78 return *this;
79}
80
81GridAttributes::~GridAttributes()
82{
83 delete _d; _d = nullptr;
84}
85
86
87bool GridAttributes::operator==( const GridAttributes& r ) const
88{
89 return isGridVisible() == r.isGridVisible() &&
91 linesOnAnnotations() == r.linesOnAnnotations() &&
92 adjustLowerBoundToGrid() == r.adjustLowerBoundToGrid() &&
93 adjustUpperBoundToGrid() == r.adjustUpperBoundToGrid() &&
94 gridPen() == r.gridPen() &&
95 isSubGridVisible() == r.isSubGridVisible() &&
96 subGridPen() == r.subGridPen() &&
97 isOuterLinesVisible() == r.isOuterLinesVisible() &&
98 zeroLinePen() == r.zeroLinePen();
99}
100
101
102void GridAttributes::setGridVisible( bool visible )
103{
104 d->visible = visible;
105}
106
107bool GridAttributes::isGridVisible() const
108{
109 return d->visible;
110}
111
113{
114 d->linesOnAnnotations = b;
115}
116
117bool GridAttributes::linesOnAnnotations() const
118{
119 return d->linesOnAnnotations;
120}
121
122void GridAttributes::setGridStepWidth( qreal stepWidth )
123{
124 d->stepWidth = stepWidth;
125}
126
128{
129 return d->stepWidth;
130}
131
132
133
134void GridAttributes::setGridSubStepWidth( qreal subStepWidth )
135{
136 d->subStepWidth = subStepWidth;
137}
138
140{
141 return d->subStepWidth;
142}
143
145{
146 d->sequence = sequence;
147}
148
153
154void GridAttributes::setAdjustBoundsToGrid( bool adjustLower, bool adjustUpper )
155{
156 d->adjustLower = adjustLower;
157 d->adjustUpper = adjustUpper;
158}
159bool GridAttributes::adjustLowerBoundToGrid() const
160{
161 return d->adjustLower;
162}
163bool GridAttributes::adjustUpperBoundToGrid() const
164{
165 return d->adjustUpper;
166}
167
168void GridAttributes::setGridPen( const QPen & pen )
169{
170 d->pen = pen;
171 d->pen.setCapStyle( Qt::FlatCap );
172}
173
174QPen GridAttributes::gridPen() const
175{
176 return d->pen;
177}
178
179void GridAttributes::setSubGridVisible( bool visible )
180{
181 d->subVisible = visible;
182}
183
184bool GridAttributes::isSubGridVisible() const
185{
186 return d->subVisible;
187}
188
189void GridAttributes::setSubGridPen( const QPen & pen )
190{
191 d->subPen = pen;
192 d->subPen.setCapStyle( Qt::FlatCap );
193}
194
195QPen GridAttributes::subGridPen() const
196{
197 return d->subPen;
198}
199
200void GridAttributes::setOuterLinesVisible( bool visible )
201{
202 d->outerVisible = visible;
203}
204
205bool GridAttributes::isOuterLinesVisible() const
206{
207 return d->outerVisible;
208}
209
210void GridAttributes::setZeroLinePen( const QPen & pen )
211{
212 d->zeroPen = pen;
213 d->zeroPen.setCapStyle( Qt::FlatCap );
214}
215
216QPen GridAttributes::zeroLinePen() const
217{
218 return d->zeroPen;
219}
220
221#if !defined(QT_NO_DEBUG_STREAM)
223{
224 dbg << "KChart::GridAttributes("
225 << "visible="<<a.isGridVisible()
226 << "subVisible="<<a.isSubGridVisible()
227 // KChartEnums::GranularitySequence sequence;
228 << "stepWidth=" << a.gridStepWidth()
229 << "subStepWidth=" << a.gridSubStepWidth()
230 << "pen="<<a.gridPen()
231 << "subPen="<<a.subGridPen()
232 << "zeroPen="<<a.zeroLinePen()
233 << ")";
234 return dbg;
235}
236#endif /* QT_NO_DEBUG_STREAM */
237
Project global class providing some enums needed both by KChartParams and by KChartCustomBox.
Definition KChartEnums.h:27
GranularitySequence
GranularitySequence specifies the values, that may be applied, to determine a step width within a giv...
Definition KChartEnums.h:78
A set of attributes controlling the appearance of grids.
qreal gridStepWidth() const
Returns the step width to be used for calculating the grid lines.
void setGridGranularitySequence(KChartEnums::GranularitySequence sequence)
Specifies the granularity sequence to be used for calculating the grid lines.
void setGridSubStepWidth(qreal subStepWidth=0.0)
Specifies the sub-step width to be used for calculating the grid sub-lines.
qreal gridSubStepWidth() const
Returns the sub-step width to be used for calculating the sub-grid lines.
KChartEnums::GranularitySequence gridGranularitySequence() const
Returns the granularity sequence to be used for calculating the grid lines.
void setGridStepWidth(qreal stepWidth=0.0)
Specifies the step width to be used for calculating the grid lines.
void setAdjustBoundsToGrid(bool adjustLower, bool adjustUpper)
By default visible bounds of the data area are adjusted to match a main grid line.
void setLinesOnAnnotations(bool)
When this is enabled, grid lines are drawn only where axis annotations are.
QDebug operator<<(QDebug dbg, const DcrawInfoContainer &c)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.