KChart

KChartPlotter.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 KCHARTPLOTTER_H
21 #define KCHARTPLOTTER_H
22 
23 #include "KChartAbstractCartesianDiagram.h"
24 
25 #include "KChartLineAttributes.h"
26 #include "KChartValueTrackerAttributes.h"
27 
28 namespace KChart {
29 
30  class ThreeDLineAttributes;
31 
32 /**
33  * @brief Plotter defines a diagram type plotting two-dimensional data.
34  */
35 class KCHART_EXPORT Plotter : public AbstractCartesianDiagram
36 {
37  Q_OBJECT
38 
39  Q_DISABLE_COPY( Plotter )
40 
41  KCHART_DECLARE_DERIVED_DIAGRAM( Plotter, CartesianCoordinatePlane )
42  Q_PROPERTY( CompressionMode useDataCompression READ useDataCompression WRITE setUseDataCompression )
43  Q_PROPERTY( qreal mergeRadiusPercentage READ mergeRadiusPercentage WRITE setMergeRadiusPercentage )
44 
45 public:
46  // SLOPE enables a compression based on minmal slope changes
47  // DISTANCE is still buggy and can fail, same for BOTH, NONE is the default mode
48  enum CompressionMode{ SLOPE, DISTANCE, BOTH, NONE };
49  Q_ENUM( CompressionMode )
50  class PlotterType;
51  friend class PlotterType;
52 
53  explicit Plotter( QWidget* parent = nullptr, CartesianCoordinatePlane* plane = nullptr );
54  virtual ~Plotter();
55 
56 
57  /**
58  * Creates an exact copy of this diagram.
59  */
60  virtual Plotter* clone() const;
61 
62  /**
63  * Returns true if both diagrams have the same settings.
64  */
65  bool compare( const Plotter* other ) const;
66 
67  enum PlotType {
68  Normal = 0,
69  Percent,
70  Stacked
71  };
72 
73 
74 
75  /**
76  * Sets the plotter's type to \a type
77  */
78  void setType( const PlotType type );
79 
80  /**
81  * @return the type of the plotter
82  */
83  PlotType type() const;
84 
85  /**
86  * Sets the global line attributes to \a la
87  */
88  void setLineAttributes( const LineAttributes & la );
89 
90  /**
91  * Sets the line attributes of data set \a column to \a la
92  */
93  void setLineAttributes( int column, const LineAttributes &la );
94 
95  /**
96  * Sets the line attributes for the model index \a index to \a la
97  */
98  void setLineAttributes( const QModelIndex & index, const LineAttributes &la );
99 
100  /**
101  * Resets the line attributes of data set \a column
102  */
103  void resetLineAttributes( int column );
104 
105  /**
106  * Remove any explicit line attributes settings that might have been specified before.
107  */
108  void resetLineAttributes( const QModelIndex & index );
109 
110  /**
111  * @return the global line attribute set
112  */
113  LineAttributes lineAttributes() const;
114 
115  /**
116  * @return the line attribute set of data set \a column
117  */
118  LineAttributes lineAttributes( int column ) const;
119 
120  /**
121  * @return the line attribute set of the model index \a index
122  */
123  LineAttributes lineAttributes( const QModelIndex & index ) const;
124 
125  /**
126  * Sets the global 3D line attributes to \a la
127  */
128  void setThreeDLineAttributes( const ThreeDLineAttributes & la );
129 
130  /**
131  * Sets the 3D line attributes of data set \a column to \a la
132  */
133  void setThreeDLineAttributes( int column, const ThreeDLineAttributes & la );
134 
135  /**
136  * Sets the 3D line attributes of model index \a index to \a la
137  */
138  void setThreeDLineAttributes( const QModelIndex & index,
139  const ThreeDLineAttributes & la );
140 
141  /**
142  * @return the global 3D line attributes
143  */
144  ThreeDLineAttributes threeDLineAttributes() const;
145 
146  /**
147  * @return the 3D line attributes of data set \a column
148  */
149  ThreeDLineAttributes threeDLineAttributes( int column ) const;
150 
151  /**
152  * @return the 3D line attributes of the model index \a index
153  */
154  ThreeDLineAttributes threeDLineAttributes( const QModelIndex & index ) const;
155 
156  /**
157  * Sets the value tracker attributes of the model index \a index to \a va
158  */
159  void setValueTrackerAttributes( const QModelIndex & index,
160  const ValueTrackerAttributes & va );
161 
162  /**
163  * Returns the value tracker attributes of the model index \a index
164  */
165  ValueTrackerAttributes valueTrackerAttributes( const QModelIndex & index ) const;
166 
167  CompressionMode useDataCompression() const;
168  void setUseDataCompression( CompressionMode value );
169 
170  qreal maxSlopeChange() const;
171  void setMaxSlopeChange( qreal value );
172 
173  qreal mergeRadiusPercentage() const;
174  void setMergeRadiusPercentage( qreal value );
175 
176 #if defined(Q_COMPILER_MANGLES_RETURN_TYPE)
177  // implement AbstractCartesianDiagram
178  /* reimpl */
179  const int numberOfAbscissaSegments () const;
180  /* reimpl */
181  const int numberOfOrdinateSegments () const;
182 #else
183  // implement AbstractCartesianDiagram
184  /* reimpl */
185  int numberOfAbscissaSegments () const override;
186  /* reimpl */
187  int numberOfOrdinateSegments () const override;
188 #endif
189 
190 protected Q_SLOTS:
191  void connectAttributesModel( AttributesModel* );
192 
193 protected:
194  void paint ( PaintContext* paintContext ) override;
195 
196 public:
197  void resize ( const QSizeF& area ) override;
198 
199 protected:
200  qreal threeDItemDepth( const QModelIndex & index ) const override;
201  qreal threeDItemDepth( int column ) const override;
202  /** \reimpl */
203  const QPair<QPointF, QPointF> calculateDataBoundaries() const override;
204  void paintEvent ( QPaintEvent* ) override;
205  void resizeEvent ( QResizeEvent* ) override;
206 protected Q_SLOTS:
207  void setDataBoundariesDirty();
208  void calcMergeRadius();
209 }; // End of class KChart::Plotter
210 
211 }
212 
213 #endif // KCHARTLINEDIAGRAM_H
Class only listed here to document inheritance of some KChart classes.
A set of 3D line attributes.
Plotter defines a diagram type plotting two-dimensional data.
Definition: KChartPlotter.h:35
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.
A proxy model used for decorating data with attributes.
Cell-specific attributes regarding value tracking.
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.