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

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