KChart

KChartLineDiagram.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 KCHARTLINEDIAGRAM_H
10#define KCHARTLINEDIAGRAM_H
11
12#include "KChartAbstractCartesianDiagram.h"
13#include "KChartLineAttributes.h"
14#include "KChartValueTrackerAttributes.h"
15
16QT_BEGIN_NAMESPACE
17class QPainter;
18class QPolygonF;
19QT_END_NAMESPACE
20
21namespace KChart {
22
23 class ThreeDLineAttributes;
24
25/**
26 * @brief LineDiagram defines a common line diagram.
27 *
28 * It provides different subtypes which are set using \a setType.
29 */
30class KCHART_EXPORT LineDiagram : public AbstractCartesianDiagram
31{
32 Q_OBJECT
33
34 Q_DISABLE_COPY( LineDiagram )
35// KCHART_DECLARE_PRIVATE_DERIVED_PARENT( LineDiagram, CartesianCoordinatePlane * )
36
37 KCHART_DECLARE_DERIVED_DIAGRAM( LineDiagram, CartesianCoordinatePlane )
38
39
40public:
41 class LineDiagramType;
42 friend class LineDiagramType;
43
44 explicit LineDiagram( QWidget* parent = nullptr, CartesianCoordinatePlane* plane = nullptr );
45 ~LineDiagram() override;
46
47
48 /**
49 * Creates an exact copy of this diagram.
50 */
51 virtual LineDiagram * clone() const;
52
53 /**
54 * Returns true if both diagrams have the same settings.
55 */
56 bool compare( const LineDiagram* other ) const;
57
58 enum LineType {
59 Normal = 0,
60 Stacked = 1,
61 Percent = 2
62 };
63
64
65
66 /**
67 * Sets the line diagram's type to \a type
68 * \sa LineDiagram::LineType
69 */
70 void setType( const LineType type );
71
72 /**
73 * @return the type of the line diagram
74 */
75 LineType type() const;
76
77 /** If centerDataPoints() is true, all data points are moved by an
78 * offset of 0.5 to the right. This is useful in conjunction with
79 * bar diagrams, since data points are then centered just like bars.
80 *
81 * \sa centerDataPoints()
82 */
83 void setCenterDataPoints( bool center );
84 /** @return option set by setCenterDataPoints() */
85 bool centerDataPoints() const;
86
87 /** With this property set to true, data sets in a normal line diagram
88 * are drawn in reversed order. More clearly, the first (top-most) data set
89 * in the source model will then appear in front. This is mostly due to
90 * historical reasons.
91 */
92 void setReverseDatasetOrder( bool reverse );
93 /** \see setReverseDatasetOrder */
94 bool reverseDatasetOrder() const;
95
96
97 /**
98 * Sets the global line attributes to \a la
99 */
100 void setLineAttributes( const LineAttributes & a );
101
102 /**
103 * Sets the line attributes of data set \a column to \a la
104 */
105 void setLineAttributes( int column, const LineAttributes & a );
106
107 /**
108 * Sets the line attributes for the model index \a index to \a la
109 */
110 void setLineAttributes( const QModelIndex & index, const LineAttributes & a );
111
112 /**
113 * Resets the line attributes of data set \a column
114 */
115 void resetLineAttributes( int column );
116
117 /**
118 * Remove any explicit line attributes settings that might have been specified before.
119 */
120 void resetLineAttributes( const QModelIndex & index );
121
122 /**
123 * @return the global line attribute set
124 */
125 LineAttributes lineAttributes() const;
126
127 /**
128 * @return the line attribute set of data set \a column
129 */
130 LineAttributes lineAttributes( int column ) const;
131
132 /**
133 * @return the line attribute set of the model index \a index
134 */
135 LineAttributes lineAttributes( const QModelIndex & index ) const;
136
137
138 /**
139 * Sets the global 3D line attributes to \a la
140 */
141 void setThreeDLineAttributes( const ThreeDLineAttributes & a );
142
143 /**
144 * Sets the 3D line attributes of data set \a column to \a ta
145 */
146 void setThreeDLineAttributes( int column, const ThreeDLineAttributes &ta );
147
148 /**
149 * Sets the 3D line attributes of model index \a index to \a la
150 */
151 void setThreeDLineAttributes( const QModelIndex & index,
152 const ThreeDLineAttributes &la );
153
154
155 /**
156 * @return the global 3D line attributes
157 */
158 ThreeDLineAttributes threeDLineAttributes() const;
159
160 /**
161 * @return the 3D line attributes of data set \a column
162 */
163 ThreeDLineAttributes threeDLineAttributes( int column ) const;
164
165 /**
166 * @return the 3D line attributes of the model index \a index
167 */
168 ThreeDLineAttributes threeDLineAttributes( const QModelIndex & index ) const;
169
170
171 /**
172 * Sets the value tracker attributes of the model index \a index to \a va
173 */
174 void setValueTrackerAttributes( const QModelIndex & index,
175 const ValueTrackerAttributes & a );
176
177 /**
178 * Returns the value tracker attributes of the model index \a index
179 */
180 ValueTrackerAttributes valueTrackerAttributes( const QModelIndex & index ) const;
181
182#if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
183 // implement AbstractCartesianDiagram
184 /* reimpl */
185 const int numberOfAbscissaSegments () const;
186 /* reimpl */
187 const int numberOfOrdinateSegments () const;
188#else
189 // implement AbstractCartesianDiagram
190 /* reimpl */
191 int numberOfAbscissaSegments () const override;
192 /* reimpl */
193 int numberOfOrdinateSegments () const override;
194#endif
195
196protected:
197 void paint ( PaintContext* paintContext ) override;
198
199public:
200 void resize ( const QSizeF& area ) override;
201
202protected:
203
204 qreal threeDItemDepth( const QModelIndex & index ) const override;
205 qreal threeDItemDepth( int column ) const override;
206 /** \reimpl */
207 const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
208 void paintEvent ( QPaintEvent* ) override;
209 void resizeEvent ( QResizeEvent* ) override;
210}; // End of class KChartLineDiagram
211
212}
213
214#endif // KCHARTLINEDIAGRAM_H
Base class for diagrams based on a cartesian coordianate system.
Set of attributes for changing the appearance of line charts.
LineDiagram defines a common line diagram.
Stores information about painting diagrams.
Cell-specific attributes regarding value tracking.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:18:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.