KDChartBarDiagram.h

Go to the documentation of this file.
00001 /* -*- Mode: C++ -*-
00002    KDChart - a multi-platform charting engine
00003    */
00004 
00005 /****************************************************************************
00006  ** Copyright (C) 2005-2007 Klaralvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KD Chart library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KD Chart licenses may use this file in
00016  ** accordance with the KD Chart Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.kdab.net/kdchart for
00023  **   information about KD Chart Commercial License Agreements.
00024  **
00025  ** Contact info@kdab.net if any conditions of this
00026  ** licensing are not clear to you.
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 ThreeDBarAttributes;
00042 
00048 class KDCHART_EXPORT BarDiagram : public AbstractCartesianDiagram
00049 {
00050     Q_OBJECT
00051 
00052     Q_DISABLE_COPY( BarDiagram )
00053 
00054     KDCHART_DECLARE_DERIVED_DIAGRAM( BarDiagram, CartesianCoordinatePlane )
00055 
00056 public:
00057     class BarDiagramType;
00058     friend class BarDiagramType;
00059 
00060     explicit BarDiagram(
00061         QWidget* parent = 0, CartesianCoordinatePlane* plane = 0 );
00062     virtual ~BarDiagram();
00063 
00064     virtual BarDiagram * clone() const;
00068     bool compare( const BarDiagram* other )const;
00069 
00070     enum BarType { Normal,
00071                    Stacked,
00072                    Percent,
00073                    Rows 
00074                  };
00075 
00076     void setType( const BarType type );
00077     BarType type() const;
00078     
00079     void setOrientation( Qt::Orientation orientation );
00080     Qt::Orientation orientation() const;
00081 
00082     void setBarAttributes( const BarAttributes & a );
00083     void setBarAttributes( int column, const BarAttributes & a );
00084     void setBarAttributes( const QModelIndex & index, const BarAttributes & a );
00085 
00086     BarAttributes barAttributes() const;
00087     BarAttributes barAttributes( int column ) const;
00088     BarAttributes barAttributes( const QModelIndex & index ) const;
00089 
00090     void setThreeDBarAttributes( const ThreeDBarAttributes & a );
00091     void setThreeDBarAttributes( int column, const ThreeDBarAttributes & a );
00092     void setThreeDBarAttributes( const QModelIndex & index,
00093                                   const ThreeDBarAttributes & a );
00094     ThreeDBarAttributes threeDBarAttributes() const;
00095     ThreeDBarAttributes threeDBarAttributes( int column ) const;
00096     ThreeDBarAttributes threeDBarAttributes( const QModelIndex & index ) const;
00097 
00098 #if QT_VERSION < 0x040400 || defined(Q_COMPILER_MANGLES_RETURN_TYPE)
00099     // implement AbstractCartesianDiagram
00101     const int numberOfAbscissaSegments () const;
00103     const int numberOfOrdinateSegments () const;
00104 #else
00105     // implement AbstractCartesianDiagram
00107     int numberOfAbscissaSegments () const;
00109     int numberOfOrdinateSegments () const;
00110 #endif
00111 
00112 protected:
00113     void paint ( PaintContext* paintContext );
00114 
00115 public:
00116     void resize ( const QSizeF& area );
00117 
00118 #if 0
00119     // FIXME merge with 3DAttributes?
00120     void setThreeDimensionalBars( bool threeDBars );
00121     bool threeDimensionalBars() const;
00122 
00123     void setThreeDimensionalBarsShadowColors( bool shadow );
00124     bool threeDimensionalBarsShadowColors() const;
00125 
00126     void setThreeDimensionalBarAngle( uint angle );
00127     uint threeDimensionalBarAngle() const;
00128 
00129     void setThreeDimensionalBarDepth( double depth );
00130     double threeDimensionalBarDepth() const;
00131 
00132 #endif
00133 
00134 
00135 protected:
00136     virtual double threeDItemDepth( const QModelIndex & index ) const;
00137     virtual double threeDItemDepth( int column ) const;
00139     const QPair<QPointF, QPointF> calculateDataBoundaries() const;
00140     void paintEvent ( QPaintEvent* );
00141     void resizeEvent ( QResizeEvent* );
00142 private:
00143 
00144     /*
00145     void paintBars( PaintContext* ctx, const QModelIndex& index, const QRectF& bar, double& maxDepth );
00146     */
00147     void calculateValueAndGapWidths( int rowCount, int colCount,
00148                                      double groupWidth,
00149                                      double& barWidth,
00150                                      double& spaceBetweenBars,
00151                                      double& spaceBetweenGroups );
00152 }; // End of class BarDiagram
00153 
00154 }
00155 
00156 #endif // KDCHARTBARDIAGRAM_H

Generated on Thu Mar 4 23:19:10 2010 for KD Chart 2 by  doxygen 1.5.4