KDChartPieDiagram.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2011 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 KDCHARTPIEDIAGRAM_H
00024 #define KDCHARTPIEDIAGRAM_H
00025 
00026 #include "KDChartAbstractPieDiagram.h"
00027 
00028 namespace KDChart {
00029 
00030     class DataValueTextInfo;
00031     typedef class QVector<DataValueTextInfo> DataValueTextInfoList;
00032 
00036 class KDCHART_EXPORT PieDiagram : public AbstractPieDiagram
00037 {
00038     Q_OBJECT
00039 
00040     Q_DISABLE_COPY( PieDiagram )
00041     KDCHART_DECLARE_DERIVED_DIAGRAM( PieDiagram, PolarCoordinatePlane )
00042 
00043 public:
00044     explicit PieDiagram(
00045         QWidget* parent = 0, PolarCoordinatePlane* plane = 0 );
00046     virtual ~PieDiagram();
00047 
00048 protected:
00049     // Implement AbstractDiagram
00051     virtual void paint ( PaintContext* paintContext );
00052     void paintInternal(PaintContext* paintContext, QRectF& textBoundingRect);
00053 
00054 public:
00056     virtual void resize ( const QSizeF& area );
00057 
00058     // Implement AbstractPolarDiagram
00060     virtual double valueTotals () const;
00062     virtual double numberOfValuesPerDataset() const;
00064     virtual double numberOfGridRings() const;
00065 
00066     virtual PieDiagram * clone() const;
00067 
00068 protected:
00070     virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const;
00071     void paintEvent( QPaintEvent* );
00072     void resizeEvent( QResizeEvent* );
00073 
00074 private:
00075     QRectF piePosition( uint dataset, uint pie ) const;
00076     void drawOnePie( QPainter* painter,
00077         DataValueTextInfoList* list,
00078         uint dataset, uint pie,
00079         qreal granularity,
00080         qreal threeDPieHeight );
00081     void drawPieSurface( QPainter* painter,
00082         DataValueTextInfoList* list,
00083         uint dataset, uint pie,
00084         qreal granularity );
00085     void draw3DEffect( QPainter* painter,
00086         const QRectF& drawPosition,
00087         uint dataset, uint pie,
00088         qreal granularity,
00089         const ThreeDPieAttributes& threeDAttrs,
00090         bool /*explode*/ );
00091     void drawStraightEffectSegment( QPainter* painter,
00092         const QRectF& rect,
00093         qreal threeDHeight,
00094         qreal angle );
00095     void drawUpperBrinkEffect( QPainter* painter,
00096         const QRectF& rect,
00097         qreal angle );
00098     void drawArcEffectSegment( QPainter* painter,
00099         const QRectF& rect,
00100         qreal threeDHeight,
00101         qreal startAngle,
00102         qreal endAngle,
00103         qreal granularity );
00104     void drawArcUpperBrinkEffectSegment( QPainter* painter,
00105         const QRectF& rect,
00106         qreal startAngle,
00107         qreal endAngle,
00108         qreal granularity );
00109     uint findPieAt( qreal angle, int columnCount );
00110     uint findLeftPie( uint pie, int columnCount );
00111     uint findRightPie( uint pie, int columnCount );
00112     QPointF pointOnCircle( const QRectF& rect, qreal angle );
00113 }; // End of class KDChartPieDiagram
00114 
00115 }
00116 #endif // KDCHARTPIEDIAGRAM_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/