KD Chart 2
[rev.2.5]
|
00001 /**************************************************************************** 00002 ** Copyright (C) 2001-2012 Klaralvdalens Datakonsult AB. All rights reserved. 00003 ** 00004 ** This file is part of the KD Chart library. 00005 ** 00006 ** Licensees holding valid commercial KD Chart licenses may use this file in 00007 ** accordance with the KD Chart Commercial License Agreement provided with 00008 ** the Software. 00009 ** 00010 ** 00011 ** This file may be distributed and/or modified under the terms of the 00012 ** GNU General Public License version 2 and version 3 as published by the 00013 ** Free Software Foundation and appearing in the file LICENSE.GPL.txt included. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** Contact info@kdab.com if any conditions of this licensing are not 00019 ** clear to you. 00020 ** 00021 **********************************************************************/ 00022 00023 #ifndef KDCHARTPLOTTER_H 00024 #define KDCHARTPLOTTER_H 00025 00026 #include "KDChartAbstractCartesianDiagram.h" 00027 00028 #include "KDChartLineAttributes.h" 00029 #include "KDChartValueTrackerAttributes.h" 00030 00031 namespace KDChart { 00032 00033 class ThreeDLineAttributes; 00034 00038 class KDCHART_EXPORT Plotter : public AbstractCartesianDiagram 00039 { 00040 Q_OBJECT 00041 00042 Q_DISABLE_COPY( Plotter ) 00043 Q_ENUMS( CompressionMode ) 00044 00045 KDCHART_DECLARE_DERIVED_DIAGRAM( Plotter, CartesianCoordinatePlane ) 00046 Q_PROPERTY( CompressionMode useDataCompression READ useDataCompression WRITE setUseDataCompression ) 00047 Q_PROPERTY( qreal mergeRadiusPercentage READ mergeRadiusPercentage WRITE setMergeRadiusPercentage ) 00048 00049 public: 00050 // SLOPE enables a compression based on minmal slope changes 00051 // DISTANCE is still buggy and can fail, same for BOTH, NONE is the default mode 00052 enum CompressionMode{ SLOPE, DISTANCE, BOTH, NONE }; 00053 class PlotterType; 00054 friend class PlotterType; 00055 00056 explicit Plotter( QWidget* parent = 0, CartesianCoordinatePlane* plane = 0 ); 00057 virtual ~Plotter(); 00058 00059 virtual Plotter* clone() const; 00060 00064 bool compare( const Plotter* other ) const; 00065 00066 enum PlotType { 00067 Normal = 0, 00068 Percent 00069 }; 00070 00071 00072 void setType( const PlotType type ); 00073 PlotType type() const; 00074 00075 void setLineAttributes( const LineAttributes & a ); 00076 void setLineAttributes( int column, const LineAttributes & a ); 00077 void setLineAttributes( const QModelIndex & index, const LineAttributes & a ); 00078 void resetLineAttributes( int column ); 00079 void resetLineAttributes( const QModelIndex & index ); 00080 LineAttributes lineAttributes() const; 00081 LineAttributes lineAttributes( int column ) const; 00082 LineAttributes lineAttributes( const QModelIndex & index ) const; 00083 00084 void setThreeDLineAttributes( const ThreeDLineAttributes & a ); 00085 void setThreeDLineAttributes( int column, const ThreeDLineAttributes & a ); 00086 void setThreeDLineAttributes( const QModelIndex & index, 00087 const ThreeDLineAttributes & a ); 00088 00089 //FIXME(khz): big TODO(khz): add a lot of reset...Attributes() methods to all 00090 // appropriate places, for 2.1 (that is: after we have release 2.0.2) :-) 00091 00092 ThreeDLineAttributes threeDLineAttributes() const; 00093 ThreeDLineAttributes threeDLineAttributes( int column ) const; 00094 ThreeDLineAttributes threeDLineAttributes( const QModelIndex & index ) const; 00095 00096 void setValueTrackerAttributes( const QModelIndex & index, 00097 const ValueTrackerAttributes & a ); 00098 ValueTrackerAttributes valueTrackerAttributes( const QModelIndex & index ) const; 00099 00100 void setModel( QAbstractItemModel *model ); 00101 00102 CompressionMode useDataCompression() const; 00103 void setUseDataCompression( CompressionMode value ); 00104 00105 qreal maxSlopeChange() const; 00106 void setMaxSlopeChange( qreal value ); 00107 00108 qreal mergeRadiusPercentage() const; 00109 void setMergeRadiusPercentage( qreal value ); 00110 00111 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE) 00112 // implement AbstractCartesianDiagram 00113 /* reimpl */ 00114 const int numberOfAbscissaSegments () const; 00115 /* reimpl */ 00116 const int numberOfOrdinateSegments () const; 00117 #else 00118 // implement AbstractCartesianDiagram 00119 /* reimpl */ 00120 int numberOfAbscissaSegments () const; 00121 /* reimpl */ 00122 int numberOfOrdinateSegments () const; 00123 #endif 00124 00125 protected: 00126 void paint ( PaintContext* paintContext ); 00127 00128 public: 00129 void resize ( const QSizeF& area ); 00130 00131 protected: 00132 virtual qreal threeDItemDepth( const QModelIndex & index ) const; 00133 virtual qreal threeDItemDepth( int column ) const; 00135 virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const; 00136 void paintEvent ( QPaintEvent* ); 00137 void resizeEvent ( QResizeEvent* ); 00138 protected Q_SLOTS: 00139 void setDataBoundariesDirty(); 00140 void calcMergeRadius(); 00141 }; // End of class KDChart::Plotter 00142 00143 } 00144 00145 #endif // KDCHARTLINEDIAGRAM_H