KD Chart 2
[rev.2.5]
|
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 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 qreal valueTotals() const; 00057 virtual qreal numberOfValuesPerDataset() const; 00058 virtual qreal numberOfDatasets() const; 00060 virtual qreal numberOfGridRings() const; 00061 00062 qreal 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 void drawOneSlice( QPainter* painter, uint dataset, uint slice, qreal granularity ); 00085 void drawPieSurface( QPainter* painter, uint dataset, uint slice, qreal granularity ); 00086 QPointF pointOnEllipse( const QRectF& rect, int dataset, int slice, bool outer, qreal angle, 00087 qreal totalGapFactor, qreal totalExplodeFactor ); 00088 }; // End of class RingDiagram 00089 00090 } 00091 00092 #endif // KDCHARTRINGDIAGRAM_H