KChart

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

KDE's Doxygen guidelines are available online.