KD Chart 2 [rev.2.4]
|
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 KDCHARTBARDIAGRAM_H 00024 #define KDCHARTBARDIAGRAM_H 00025 00026 #include "KDChartAbstractCartesianDiagram.h" 00027 #include "KDChartBarAttributes.h" 00028 //#include "KDChartThreeDBarAttributes.h" 00029 00030 class QPainter; 00031 00032 namespace KDChart { 00033 00034 class ThreeDBarAttributes; 00035 00041 class KDCHART_EXPORT BarDiagram : public AbstractCartesianDiagram 00042 { 00043 Q_OBJECT 00044 00045 Q_DISABLE_COPY( BarDiagram ) 00046 00047 KDCHART_DECLARE_DERIVED_DIAGRAM( BarDiagram, CartesianCoordinatePlane ) 00048 00049 public: 00050 class BarDiagramType; 00051 friend class BarDiagramType; 00052 00053 explicit BarDiagram( 00054 QWidget* parent = 0, CartesianCoordinatePlane* plane = 0 ); 00055 virtual ~BarDiagram(); 00056 00057 virtual BarDiagram * clone() const; 00061 bool compare( const BarDiagram* other )const; 00062 00063 enum BarType { Normal, 00064 Stacked, 00065 Percent, 00066 Rows 00067 }; 00068 00069 void setType( const BarType type ); 00070 BarType type() const; 00071 00072 void setOrientation( Qt::Orientation orientation ); 00073 Qt::Orientation orientation() const; 00074 00075 void setBarAttributes( const BarAttributes & a ); 00076 void setBarAttributes( int column, const BarAttributes & a ); 00077 void setBarAttributes( const QModelIndex & index, const BarAttributes & a ); 00078 00079 BarAttributes barAttributes() const; 00080 BarAttributes barAttributes( int column ) const; 00081 BarAttributes barAttributes( const QModelIndex & index ) const; 00082 00083 void setThreeDBarAttributes( const ThreeDBarAttributes & a ); 00084 void setThreeDBarAttributes( int column, const ThreeDBarAttributes & a ); 00085 void setThreeDBarAttributes( const QModelIndex & index, 00086 const ThreeDBarAttributes & a ); 00087 ThreeDBarAttributes threeDBarAttributes() const; 00088 ThreeDBarAttributes threeDBarAttributes( int column ) const; 00089 ThreeDBarAttributes threeDBarAttributes( const QModelIndex & index ) const; 00090 00091 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE) 00092 // implement AbstractCartesianDiagram 00094 const int numberOfAbscissaSegments () const; 00096 const int numberOfOrdinateSegments () const; 00097 #else 00098 // implement AbstractCartesianDiagram 00100 int numberOfAbscissaSegments () const; 00102 int numberOfOrdinateSegments () const; 00103 #endif 00104 00105 protected: 00106 void paint ( PaintContext* paintContext ); 00107 00108 public: 00109 void resize ( const QSizeF& area ); 00110 00111 #if 0 00112 // FIXME merge with 3DAttributes? 00113 void setThreeDimensionalBars( bool threeDBars ); 00114 bool threeDimensionalBars() const; 00115 00116 void setThreeDimensionalBarsShadowColors( bool shadow ); 00117 bool threeDimensionalBarsShadowColors() const; 00118 00119 void setThreeDimensionalBarAngle( uint angle ); 00120 uint threeDimensionalBarAngle() const; 00121 00122 void setThreeDimensionalBarDepth( double depth ); 00123 double threeDimensionalBarDepth() const; 00124 00125 #endif 00126 00127 00128 protected: 00129 virtual double threeDItemDepth( const QModelIndex & index ) const; 00130 virtual double threeDItemDepth( int column ) const; 00132 const QPair<QPointF, QPointF> calculateDataBoundaries() const; 00133 void paintEvent ( QPaintEvent* ); 00134 void resizeEvent ( QResizeEvent* ); 00135 private: 00136 00137 /* 00138 void paintBars( PaintContext* ctx, const QModelIndex& index, const QRectF& bar, double& maxDepth ); 00139 */ 00140 void calculateValueAndGapWidths( int rowCount, int colCount, 00141 double groupWidth, 00142 double& barWidth, 00143 double& spaceBetweenBars, 00144 double& spaceBetweenGroups ); 00145 }; // End of class BarDiagram 00146 00147 } 00148 00149 #endif // KDCHARTBARDIAGRAM_H