KD Chart 2: KDChartAbstractPieDiagram.cpp Source File

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# KDChartAbstractPieDiagram.cpp

Go to the documentation of this file.

    00001 /****************************************************************************
    00002  ** Copyright (C) 2006 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     qWarning() << "Deprecated AbstractPieDiagram::setStartPosition() called, setting ignored.";
    00080 }
    00081
    00082 int AbstractPieDiagram::startPosition() const
    00083 {
    00084     qWarning() << "Deprecated AbstractPieDiagram::startPosition() called.";
    00085     return 0;
    00086 }
    00087
    00088 void AbstractPieDiagram::setPieAttributes( const PieAttributes & attrs )
    00089 {
    00090     d->attributesModel->setModelData( qVariantFromValue( attrs ), PieAttributesRole );
    00091     emit layoutChanged( this );
    00092 }
    00093
    00094 void AbstractPieDiagram::setPieAttributes( int column, const PieAttributes & attrs )
    00095 {
    00096     d->attributesModel->setHeaderData(
    00097         column, Qt::Vertical, qVariantFromValue( attrs ), PieAttributesRole );
    00098     emit layoutChanged( this );
    00099 }
    00100
    00101 // Note: Our users NEED this method - even if
    00102 //       we do not need it at drawing time!
    00103 //       (khz, 2006-07-28)
    00104 PieAttributes AbstractPieDiagram::pieAttributes() const
    00105 {
    00106     return qVariantValue<PieAttributes>(
    00107         d->attributesModel->data( PieAttributesRole ) );
    00108 }
    00109
    00110 // Note: Our users NEED this method - even if
    00111 //       we do not need it at drawing time!
    00112 //       (khz, 2006-07-28)
    00113 PieAttributes AbstractPieDiagram::pieAttributes( int column ) const
    00114 {
    00115     return qVariantValue<PieAttributes>(
    00116         d->attributesModel->data(
    00117             d->attributesModel->mapFromSource( columnToIndex( column ) ).column(),
    00118             PieAttributesRole ) );
    00119 }
    00120
    00121 PieAttributes AbstractPieDiagram::pieAttributes( const QModelIndex & index ) const
    00122 {
    00123     return qVariantValue<PieAttributes>(
    00124         d->attributesModel->data(
    00125             d->attributesModel->mapFromSource( index ),
    00126             PieAttributesRole ) );
    00127 }
    00128
    00129
    00130 void AbstractPieDiagram::setThreeDPieAttributes( const ThreeDPieAttributes & tda )
    00131 {
    00132     d->attributesModel->setModelData( qVariantFromValue( tda ), ThreeDPieAttributesRole );
    00133     emit layoutChanged( this );
    00134 }
    00135
    00136 void AbstractPieDiagram::setThreeDPieAttributes( int column, const ThreeDPieAttributes & tda )
    00137 {
    00138     d->attributesModel->setHeaderData(
    00139         column, Qt::Vertical, qVariantFromValue( tda ), ThreeDPieAttributesRole );
    00140     emit layoutChanged( this );
    00141 }
    00142
    00143 void AbstractPieDiagram::setThreeDPieAttributes( const QModelIndex & index, const ThreeDPieAttributes & tda )
    00144 {
    00145     model()->setData( index, qVariantFromValue( tda ), ThreeDPieAttributesRole );
    00146     emit layoutChanged( this );
    00147 }
    00148
    00149 // Note: Our users NEED this method - even if
    00150 //       we do not need it at drawing time!
    00151 //       (khz, 2006-07-28)
    00152 ThreeDPieAttributes AbstractPieDiagram::threeDPieAttributes() const
    00153 {
    00154     return qVariantValue<ThreeDPieAttributes>(
    00155         d->attributesModel->data( ThreeDPieAttributesRole ) );
    00156 }
    00157
    00158 // Note: Our users NEED this method - even if
    00159 //       we do not need it at drawing time!
    00160 //       (khz, 2006-07-28)
    00161 ThreeDPieAttributes AbstractPieDiagram::threeDPieAttributes( int column ) const
    00162 {
    00163     return qVariantValue<ThreeDPieAttributes>(
    00164         d->attributesModel->data(
    00165             d->attributesModel->mapFromSource( columnToIndex( column ) ).column(),
    00166             ThreeDPieAttributesRole ) );
    00167 }
    00168
    00169 ThreeDPieAttributes AbstractPieDiagram::threeDPieAttributes( const QModelIndex & index ) const
    00170 {
    00171     return qVariantValue<ThreeDPieAttributes>(
    00172         d->attributesModel->data(
    00173             d->attributesModel->mapFromSource( index ),
    00174             ThreeDPieAttributesRole ) );
    00175 }
    00176