KDChartAbstractPieDiagram.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002  ** Copyright (C) 2007 Klarälvdalens Datakonsult AB.  All rights reserved.
00003  **
00004  ** This file is part of the KD Chart library.
00005  **
00006  ** This file may be distributed and/or modified under the terms of the
00007  ** GNU General Public License version 2 as published by the Free Software
00008  ** Foundation and appearing in the file LICENSE.GPL included in the
00009  ** packaging of this file.
00010  **
00011  ** Licensees holding valid commercial KD Chart licenses may use this file in
00012  ** accordance with the KD Chart Commercial License Agreement provided with
00013  ** the Software.
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  ** See http://www.kdab.net/kdchart for
00019  **   information about KDChart Commercial License Agreements.
00020  **
00021  ** Contact info@kdab.net if any conditions of this
00022  ** licensing are not clear to you.
00023  **
00024  **********************************************************************/
00025 
00026 #include <QMap>
00027 
00028 #include "KDChartAbstractPieDiagram.h"
00029 #include "KDChartAbstractPieDiagram_p.h"
00030 #include "KDChartAttributesModel.h"
00031 #include "KDChartPieAttributes.h"
00032 #include "KDChartThreeDPieAttributes.h"
00033 
00034 #include <KDABLibFakes>
00035 
00036 
00037 using namespace KDChart;
00038 
00039 AbstractPieDiagram::Private::Private() :
00040     granularity( 1.0 )
00041 {
00042 }
00043 
00044 AbstractPieDiagram::Private::~Private() {}
00045 
00046 AbstractPieDiagram::AbstractPieDiagram( QWidget* parent, PolarCoordinatePlane *plane ) :
00047     AbstractPolarDiagram( new Private(), parent, plane )
00048 {
00049     init();
00050 }
00051 
00052 AbstractPieDiagram::~AbstractPieDiagram()
00053 {
00054 }
00055 
00056 
00057 void AbstractPieDiagram::init()
00058 {
00059 }
00060 
00061 
00062 #define d d_func()
00063 
00064 void AbstractPieDiagram::setGranularity( qreal value )
00065 {
00066     d->granularity = value;
00067 }
00068 
00069 qreal AbstractPieDiagram::granularity() const
00070 {
00071     return (d->granularity < 0.05 || d->granularity > 36.0)
00072             ? 1.0
00073     : d->granularity;
00074 }
00075 
00076 
00077 void AbstractPieDiagram::setStartPosition( int degrees )
00078 {
00079     Q_UNUSED( degrees );
00080     qWarning() << "Deprecated AbstractPieDiagram::setStartPosition() called, setting ignored.";
00081 }
00082 
00083 int AbstractPieDiagram::startPosition() const
00084 {
00085     qWarning() << "Deprecated AbstractPieDiagram::startPosition() called.";
00086     return 0;
00087 }
00088 
00089 void AbstractPieDiagram::setPieAttributes( const PieAttributes & attrs )
00090 {
00091     d->attributesModel->setModelData( qVariantFromValue( attrs ), PieAttributesRole );
00092     emit layoutChanged( this );
00093 }
00094 
00095 void AbstractPieDiagram::setPieAttributes( int column, const PieAttributes & attrs )
00096 {
00097     d->attributesModel->setHeaderData(
00098         column, Qt::Vertical, qVariantFromValue( attrs ), PieAttributesRole );
00099     emit layoutChanged( this );
00100 }
00101 
00102 // Note: Our users NEED this method - even if
00103 //       we do not need it at drawing time!
00104 //       (khz, 2006-07-28)
00105 PieAttributes AbstractPieDiagram::pieAttributes() const
00106 {
00107     return qVariantValue<PieAttributes>(
00108         d->attributesModel->data( PieAttributesRole ) );
00109 }
00110 
00111 // Note: Our users NEED this method - even if
00112 //       we do not need it at drawing time!
00113 //       (khz, 2006-07-28)
00114 PieAttributes AbstractPieDiagram::pieAttributes( int column ) const
00115 {
00116     return qVariantValue<PieAttributes>(
00117         d->attributesModel->data(
00118             d->attributesModel->mapFromSource( columnToIndex( column ) ).column(),
00119             PieAttributesRole ) );
00120 }
00121 
00122 PieAttributes AbstractPieDiagram::pieAttributes( const QModelIndex & index ) const
00123 {
00124     return qVariantValue<PieAttributes>(
00125         d->attributesModel->data(
00126             d->attributesModel->mapFromSource( index ),
00127             PieAttributesRole ) );
00128 }
00129 
00130 
00131 void AbstractPieDiagram::setThreeDPieAttributes( const ThreeDPieAttributes & tda )
00132 {
00133     d->attributesModel->setModelData( qVariantFromValue( tda ), ThreeDPieAttributesRole );
00134     emit layoutChanged( this );
00135 }
00136 
00137 void AbstractPieDiagram::setThreeDPieAttributes( int column, const ThreeDPieAttributes & tda )
00138 {
00139     d->attributesModel->setHeaderData(
00140         column, Qt::Vertical, qVariantFromValue( tda ), ThreeDPieAttributesRole );
00141     emit layoutChanged( this );
00142 }
00143 
00144 void AbstractPieDiagram::setThreeDPieAttributes( const QModelIndex & index, const ThreeDPieAttributes & tda )
00145 {
00146     model()->setData( index, qVariantFromValue( tda ), ThreeDPieAttributesRole );
00147     emit layoutChanged( this );
00148 }
00149 
00150 // Note: Our users NEED this method - even if
00151 //       we do not need it at drawing time!
00152 //       (khz, 2006-07-28)
00153 ThreeDPieAttributes AbstractPieDiagram::threeDPieAttributes() const
00154 {
00155     return qVariantValue<ThreeDPieAttributes>(
00156         d->attributesModel->data( ThreeDPieAttributesRole ) );
00157 }
00158 
00159 // Note: Our users NEED this method - even if
00160 //       we do not need it at drawing time!
00161 //       (khz, 2006-07-28)
00162 ThreeDPieAttributes AbstractPieDiagram::threeDPieAttributes( int column ) const
00163 {
00164     return qVariantValue<ThreeDPieAttributes>(
00165         d->attributesModel->data(
00166             d->attributesModel->mapFromSource( columnToIndex( column ) ).column(),
00167             ThreeDPieAttributesRole ) );
00168 }
00169 
00170 ThreeDPieAttributes AbstractPieDiagram::threeDPieAttributes( const QModelIndex & index ) const
00171 {
00172     return qVariantValue<ThreeDPieAttributes>(
00173         d->attributesModel->data(
00174             d->attributesModel->mapFromSource( index ),
00175             ThreeDPieAttributesRole ) );
00176 }
00177 

Generated on Mon Sep 17 16:16:49 2007 for KD Chart 2 by  doxygen 1.5.1