KDChartRingDiagram.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 ** Copyright (C) 2001-2010 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 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 KDCHARTRINGDIAGRAM_H
00024 #define KDCHARTRINGDIAGRAM_H
00025 
00026 #include "KDChartAbstractPieDiagram.h"
00027 
00028 namespace KDChart {
00029 
00033 class KDCHART_EXPORT RingDiagram : public AbstractPieDiagram
00034 {
00035     Q_OBJECT
00036 
00037     Q_DISABLE_COPY( RingDiagram )
00038     KDCHART_DECLARE_DERIVED_DIAGRAM( RingDiagram, PolarCoordinatePlane )
00039 
00040 public:
00041     explicit RingDiagram(
00042         QWidget* parent = 0, PolarCoordinatePlane* plane = 0 );
00043     virtual ~RingDiagram();
00044 
00045 protected:
00046     // Implement AbstractDiagram
00048     virtual void paint ( PaintContext* paintContext );
00049 public:
00051     virtual void resize ( const QSizeF& area );
00052 
00053     // Implement AbstractPolarDiagram
00055     virtual double valueTotals () const;
00057     virtual double numberOfValuesPerDataset() const;
00058     virtual double numberOfDatasets() const;
00060     virtual double numberOfGridRings() const;
00061 
00062     double valueTotals( int dataset ) const;
00063 
00064     virtual RingDiagram * clone() const;
00065 
00069     bool compare( const RingDiagram* other ) const;
00070 
00071     void setRelativeThickness( bool relativeThickness );
00072     bool relativeThickness() const;
00073 
00074     virtual void setExpandWhenExploded( bool expand );
00075     virtual bool expandWhenExploded() const;
00076 
00077 protected:
00079     virtual const QPair<QPointF, QPointF> calculateDataBoundaries() const;
00080     void paintEvent( QPaintEvent* );
00081     void resizeEvent( QResizeEvent* );
00082 
00083 private:
00084     //QRectF piePosition( uint dataset, uint pie ) const;
00085     void drawOnePie( QPainter* painter,
00086         uint dataset, uint pie,
00087         qreal granularity );
00088     void drawPieSurface( QPainter* painter,
00089         uint dataset, uint pie,
00090         qreal granularity );
00091     QPointF pointOnCircle( const QRectF& rect, int dataset, int pie, bool outer, qreal angle, qreal totalGapFactor, qreal totalExplodeFactor );
00092     //qreal radiusOf( const QRectF& rect, int dataset, int pie, bool outer );
00093 }; // End of class RingDiagram
00094 
00095 }
00096 
00097 #endif // KDCHARTRINGDIAGRAM_H