KD Chart 2  [rev.2.5.1]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
KDChartPlotter.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2001-2013 Klaralvdalens Datakonsult AB. All rights reserved.
3 **
4 ** This file is part of the KD Chart library.
5 **
6 ** Licensees holding valid commercial KD Chart licenses may use this file in
7 ** accordance with the KD Chart Commercial License Agreement provided with
8 ** the Software.
9 **
10 **
11 ** This file may be distributed and/or modified under the terms of the
12 ** GNU General Public License version 2 and version 3 as published by the
13 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included.
14 **
15 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17 **
18 ** Contact info@kdab.com if any conditions of this licensing are not
19 ** clear to you.
20 **
21 **********************************************************************/
22 
23 #ifndef KDCHARTPLOTTER_H
24 #define KDCHARTPLOTTER_H
25 
27 
28 #include "KDChartLineAttributes.h"
30 
31 namespace KDChart {
32 
33  class ThreeDLineAttributes;
34 
38 class KDCHART_EXPORT Plotter : public AbstractCartesianDiagram
39 {
40  Q_OBJECT
41 
42  Q_DISABLE_COPY( Plotter )
43  Q_ENUMS( CompressionMode )
44 
46  Q_PROPERTY( CompressionMode useDataCompression READ useDataCompression WRITE setUseDataCompression )
47  Q_PROPERTY( qreal mergeRadiusPercentage READ mergeRadiusPercentage WRITE setMergeRadiusPercentage )
48 
49 public:
50  // SLOPE enables a compression based on minmal slope changes
51  // DISTANCE is still buggy and can fail, same for BOTH, NONE is the default mode
52  enum CompressionMode{ SLOPE, DISTANCE, BOTH, NONE };
53  class PlotterType;
54  friend class PlotterType;
55 
56  explicit Plotter( QWidget* parent = 0, CartesianCoordinatePlane* plane = 0 );
57  virtual ~Plotter();
58 
59  virtual Plotter* clone() const;
60 
64  bool compare( const Plotter* other ) const;
65 
66  enum PlotType {
67  Normal = 0,
68  Percent
69  };
70 
71 
72  void setType( const PlotType type );
73  PlotType type() const;
74 
75  void setLineAttributes( const LineAttributes & a );
76  void setLineAttributes( int column, const LineAttributes & a );
77  void setLineAttributes( const QModelIndex & index, const LineAttributes & a );
78  void resetLineAttributes( int column );
79  void resetLineAttributes( const QModelIndex & index );
80  LineAttributes lineAttributes() const;
81  LineAttributes lineAttributes( int column ) const;
82  LineAttributes lineAttributes( const QModelIndex & index ) const;
83 
84  void setThreeDLineAttributes( const ThreeDLineAttributes & a );
85  void setThreeDLineAttributes( int column, const ThreeDLineAttributes & a );
86  void setThreeDLineAttributes( const QModelIndex & index,
87  const ThreeDLineAttributes & a );
88 
89  //FIXME(khz): big TODO(khz): add a lot of reset...Attributes() methods to all
90  // appropriate places, for 2.1 (that is: after we have release 2.0.2) :-)
91 
93  ThreeDLineAttributes threeDLineAttributes( int column ) const;
94  ThreeDLineAttributes threeDLineAttributes( const QModelIndex & index ) const;
95 
96  void setValueTrackerAttributes( const QModelIndex & index,
97  const ValueTrackerAttributes & a );
98  ValueTrackerAttributes valueTrackerAttributes( const QModelIndex & index ) const;
99 
100  void setModel( QAbstractItemModel *model );
101 
102  CompressionMode useDataCompression() const;
103  void setUseDataCompression( CompressionMode value );
104 
105  qreal maxSlopeChange() const;
106  void setMaxSlopeChange( qreal value );
107 
108  qreal mergeRadiusPercentage() const;
109  void setMergeRadiusPercentage( qreal value );
110 
111 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
112  // implement AbstractCartesianDiagram
113  /* reimpl */
114  const int numberOfAbscissaSegments () const;
115  /* reimpl */
116  const int numberOfOrdinateSegments () const;
117 #else
118  // implement AbstractCartesianDiagram
119  /* reimpl */
120  int numberOfAbscissaSegments () const;
121  /* reimpl */
122  int numberOfOrdinateSegments () const;
123 #endif
124 
125 protected:
126  void paint ( PaintContext* paintContext );
127 
128 public:
129  void resize ( const QSizeF& area );
130 
131 protected:
132  virtual qreal threeDItemDepth( const QModelIndex & index ) const;
133  virtual qreal threeDItemDepth( int column ) const;
135  virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const;
136  void paintEvent ( QPaintEvent* );
137  void resizeEvent ( QResizeEvent* );
138 protected Q_SLOTS:
139  void setDataBoundariesDirty();
140  void calcMergeRadius();
141 }; // End of class KDChart::Plotter
142 
143 }
144 
145 #endif // KDCHARTLINEDIAGRAM_H

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-chart/