00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef KDCHARTBARDIAGRAM_H
00031 #define KDCHARTBARDIAGRAM_H
00032
00033 #include "KDChartAbstractCartesianDiagram.h"
00034 #include "KDChartBarAttributes.h"
00035 #include "KDChartThreeDBarAttributes.h"
00036
00037 class QPainter;
00038
00039 namespace KDChart {
00040
00041 class KDCHART_EXPORT BarDiagram : public AbstractCartesianDiagram
00042 {
00043 Q_OBJECT
00044
00045 Q_DISABLE_COPY( BarDiagram )
00046 KDCHART_DECLARE_DERIVED_DIAGRAM( BarDiagram, CartesianCoordinatePlane )
00047
00048 public:
00049 explicit BarDiagram(
00050 QWidget* parent = 0, CartesianCoordinatePlane* plane = 0 );
00051 virtual ~BarDiagram();
00052
00053 virtual BarDiagram * clone() const;
00054
00055 enum BarType { Normal,
00056 Stacked,
00057 Percent,
00058 Rows };
00059
00060 void setType( BarType type );
00061 BarType type() const;
00062
00063 void setBarAttributes( const BarAttributes & a );
00064 void setBarAttributes( int column, const BarAttributes & a );
00065 void setBarAttributes( const QModelIndex & index,
00066 const BarAttributes & a );
00067 BarAttributes barAttributes() const;
00068 BarAttributes barAttributes( int column ) const;
00069 BarAttributes barAttributes( const QModelIndex & index ) const;
00070
00071 void setThreeDBarAttributes( const ThreeDBarAttributes & a );
00072 void setThreeDBarAttributes( int column, const ThreeDBarAttributes & a );
00073 void setThreeDBarAttributes( const QModelIndex & index,
00074 const ThreeDBarAttributes & a );
00075 ThreeDBarAttributes threeDBarAttributes() const;
00076 ThreeDBarAttributes threeDBarAttributes( int column ) const;
00077 ThreeDBarAttributes threeDBarAttributes( const QModelIndex & index ) const;
00078
00079
00081 const int numberOfAbscissaSegments () const;
00083 const int numberOfOrdinateSegments () const;
00084
00085 protected:
00086 void paint ( PaintContext* paintContext );
00087
00088 public:
00089 void resize ( const QSizeF& area );
00090
00091 #if 0
00092
00093 void setThreeDimensionalBars( bool threeDBars );
00094 bool threeDimensionalBars() const;
00095
00096 void setThreeDimensionalBarsShadowColors( bool shadow );
00097 bool threeDimensionalBarsShadowColors() const;
00098
00099 void setThreeDimensionalBarAngle( uint angle );
00100 uint threeDimensionalBarAngle() const;
00101
00102 void setThreeDimensionalBarDepth( double depth );
00103 double threeDimensionalBarDepth() const;
00104
00105 #endif
00106
00107
00108 protected:
00109 virtual double threeDItemDepth( const QModelIndex & index ) const;
00110 virtual double threeDItemDepth( int column ) const;
00112 const QPair<QPointF, QPointF> calculateDataBoundaries() const;
00113
00114 void resizeEvent ( QResizeEvent* );
00115 private:
00116 void paintBars( PaintContext* ctx, const QModelIndex& index, const QRectF& bar, double& maxDepth );
00117 void calculateValueAndGapWidths( int rowCount, int colCount,
00118 double groupWidth,
00119 double& barWidth,
00120 double& spaceBetweenBars,
00121 double& spaceBetweenGroups );
00122 };
00123
00124 }
00125
00126 #endif // KDCHARTBARDIAGRAM_H