KChart

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

KDE's Doxygen guidelines are available online.