KChart

KChartGridAttributes.h
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 #ifndef KCHARTGRIDATTRIBUTES_H
10 #define KCHARTGRIDATTRIBUTES_H
11 
12 #include <QMetaType>
13 #include "KChartGlobal.h"
14 #include "KChartEnums.h"
15 
16 QT_BEGIN_NAMESPACE
17 class QPen;
18 QT_END_NAMESPACE
19 
20 namespace KChart {
21 
22 /**
23  * @brief A set of attributes controlling the appearance of grids
24  */
25 class KCHART_EXPORT GridAttributes
26 {
27 public:
30  GridAttributes &operator= ( const GridAttributes& );
31 
32  ~GridAttributes();
33 
34  void setGridVisible( bool visible );
35  bool isGridVisible() const;
36 
37  /**
38  * When this is enabled, grid lines are drawn only where axis annotations are.
39  * Otherwise annotations are disregarded as far as the grid is concerned.
40  *
41  * The default is false.
42  */
43  void setLinesOnAnnotations( bool );
44  bool linesOnAnnotations() const;
45 
46 
47  /**
48  * Specifies the step width to be used for calculating
49  * the grid lines.
50  *
51  * \note Step with can be set for Linear axis calculation mode only,
52  * there is no way to specify a step width for Logarithmic axes.
53  *
54  * By default the GridAttributes class does not use a fixed step width,
55  * but it uses KChartEnums::GranularitySequence_10_20.
56  *
57  * \param stepWidth the step width to be used.
58  * If this parameter is omitted (or set to Zero, resp.)
59  * the automatic step width calculation will be done,
60  * using the granularity sequence specified.
61  * This is the default.
62  *
63  * \sa gridStepWidth, setGranularitySequence
64  */
65  void setGridStepWidth( qreal stepWidth = 0.0 );
66 
67  /**
68  * Returns the step width to be used for calculating
69  * the grid lines.
70  *
71  * \sa setGridStepWidth
72  */
73  qreal gridStepWidth() const;
74 
75 
76  /**
77  * Specifies the sub-step width to be used for calculating
78  * the grid sub-lines.
79  *
80  *
81  * \param subStepWidth the sub-step width to be used.
82  * If this parameter is omitted (or set to Zero, resp.)
83  * the automatic calculation will be done, using the
84  * granularity sequence specified.
85  * This is the default.
86  *
87  * \sa gridSubStepWidth
88  */
89  void setGridSubStepWidth( qreal subStepWidth = 0.0 );
90 
91  /**
92  * Returns the sub-step width to be used for calculating
93  * the sub-grid lines.
94  *
95  * \sa setGridStepWidth
96  */
97  qreal gridSubStepWidth() const;
98 
99  /**
100  * Specifies the granularity sequence to be used for calculating
101  * the grid lines.
102  *
103  * By default the GridAttributes class uses KChartEnums::GranularitySequence_10_20.
104  *
105  * \note Granularity can be set for Linear axis calculation mode only,
106  * there is no way to specify a step width for Logarithmic axes.
107  *
108  * \note The sequence specified by this method is ignored, if
109  * a fixed step width was specified via setStepWidth.
110  *
111  * \param sequence one of the sequences declared in
112  * KChartEnums::GranularitySequence.
113  *
114  * \sa gridGranularitySequence, setStepWidth
115  */
116  void setGridGranularitySequence( KChartEnums::GranularitySequence sequence );
117 
118  /**
119  * Returns the granularity sequence to be used for calculating
120  * the grid lines.
121  *
122  * \sa setGridGranularitySequence
123  */
124  KChartEnums::GranularitySequence gridGranularitySequence() const;
125 
126  /**
127  * By default visible bounds of the data area are adjusted to match
128  * a main grid line.
129  * If you set the respective adjust flag to false the bound will
130  * not start at a grid line's value but it will be the exact value
131  * of the data range set.
132  *
133  * \sa CartesianCoordinatePlane::setHorizontalRange
134  * \sa CartesianCoordinatePlane::setVerticalRange
135  */
136  void setAdjustBoundsToGrid( bool adjustLower, bool adjustUpper );
137  bool adjustLowerBoundToGrid() const;
138  bool adjustUpperBoundToGrid() const;
139 
140  void setGridPen( const QPen & pen );
141  QPen gridPen() const;
142 
143  void setSubGridVisible( bool visible );
144  bool isSubGridVisible() const;
145 
146  void setSubGridPen( const QPen & pen );
147  QPen subGridPen() const;
148 
149  void setOuterLinesVisible( bool visible );
150  bool isOuterLinesVisible() const;
151 
152  void setZeroLinePen( const QPen & pen );
153  QPen zeroLinePen() const;
154 
155  bool operator==( const GridAttributes& ) const;
156  inline bool operator!=( const GridAttributes& other ) const { return !operator==(other); }
157 
158 private:
159  KCHART_DECLARE_PRIVATE_BASE_VALUE( GridAttributes )
160 }; // End of class GridAttributes
161 
162 }
163 
164 #if !defined(QT_NO_DEBUG_STREAM)
165 KCHART_EXPORT QDebug operator<<(QDebug, const KChart::GridAttributes& );
166 #endif /* QT_NO_DEBUG_STREAM */
167 
168 KCHART_DECLARE_SWAP_SPECIALISATION( KChart::GridAttributes )
169 
170 QT_BEGIN_NAMESPACE
171 Q_DECLARE_TYPEINFO( KChart::GridAttributes, Q_MOVABLE_TYPE );
172 QT_END_NAMESPACE
173 
174 Q_DECLARE_METATYPE( KChart::GridAttributes )
175 
176 #endif // KCHARTGRIDATTRIBUTES_H
Contains KChart macros.
GranularitySequence
GranularitySequence specifies the values, that may be applied, to determine a step width within a giv...
Definition: KChartEnums.h:78
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
Definition of global enums.
A set of attributes controlling the appearance of grids.
Global namespace.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 22:37:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.