kchart

KDChartDataRegion.h

00001 /* -*- Mode: C++ -*-
00002    KDChart - a multi-platform charting engine
00003    */
00004 
00005 /****************************************************************************
00006  ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KDChart library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KDChart licenses may use this file in
00016  ** accordance with the KDChart Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.klaralvdalens-datakonsult.se/?page=products for
00023  **   information about KDChart Commercial License Agreements.
00024  **
00025  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
00026  ** licensing are not clear to you.
00027  **
00028  **********************************************************************/
00029 #ifndef __KDCHARTDATAREGION__
00030 #define __KDCHARTDATAREGION__
00031 
00032 #include <qregion.h>
00033 #include <qpointarray.h>
00034 
00035 #include "KDChartGlobal.h"
00036 
00040 struct KDCHART_EXPORT KDChartDataRegion
00041 {
00042     KDChartDataRegion()
00043     {
00044         init();
00045     }
00046 
00047     KDChartDataRegion( QRegion region, uint r, uint c, uint ch )
00048     {
00049         init();
00050         pRegion = new QRegion( region );
00051         row     = r;
00052         col     = c;
00053         chart   = ch;
00054     }
00055 
00056     KDChartDataRegion( uint r, uint c, uint ch, QPointArray array )
00057     {
00058         init();
00059         pArray = new QPointArray( array );
00060         row     = r;
00061         col     = c;
00062         chart   = ch;
00063     }
00064 
00065     KDChartDataRegion( uint r, uint c, uint ch, QRect rect )
00066     {
00067         init();
00068         pRect = new QRect( rect );
00069         row   = r;
00070         col   = c;
00071         chart = ch;
00072     }
00073 
00074     ~KDChartDataRegion()
00075     {
00076         //qDebug ("~KDChartDataRegion");
00077         if( pRegion )
00078             delete pRegion;
00079         if( pArray )
00080             delete pArray;
00081         if( pRect )
00082             delete pRect;
00083         if( pTextRegion )
00084             delete pTextRegion;
00085     }
00086 
00087     QRegion region() const
00088     {
00089         if( pRegion )
00090             return *pRegion;
00091         if( pArray )
00092             return QRegion( *pArray );
00093         if( pRect )
00094             return QRegion( *pRect );
00095         return QRegion();
00096     }
00097 
00098     QRect rect() const
00099     {
00100         if( pRegion )
00101             return pRegion->boundingRect();
00102         if( pArray )
00103             return pArray->boundingRect();
00104         if( pRect )
00105             return *pRect;
00106         return QRect();
00107     }
00108 
00109     void init()
00110     {
00111         pRegion     = 0;
00112         pArray      = 0;
00113         pRect       = 0;
00114         pTextRegion = 0;
00115         row    = 0;
00116         col    = 0;
00117         chart  = 0;
00118         negative = false; // default value (useful if value is a string)
00119         points.resize( 9 );
00120         startAngle = 1440;
00121         angleLen   =    1;
00122     }
00123 
00124     QRegion*     pRegion;
00125     QPointArray* pArray;
00126     QRect*       pRect;
00127     QRegion*     pTextRegion;  // for the data values text
00128 
00129     // For rectangular data representation  (bar, line, area, point, ...)
00130     // we use the above declared 'pRect'.
00131     // For curved data representations (pie slice, ring segment, ...)
00132     // we store the following additional anchor information:
00133 
00134     // store 9 elements: one for each value of KDChartEnums::PositionFlag
00135     QPointArray points;
00136 
00137     int startAngle; // Note: 5760 makes a full circle, 2880 is left 'corner'.
00138     int angleLen;
00139 
00140     uint row;
00141     uint col;
00142     // members needed for calculation of data values texts
00143     uint chart;
00144     QString text;        // the data values text
00145     bool    negative;    // stores whether the data value is less than zero
00146 };
00147 
00148 
00168 typedef QPtrList < KDChartDataRegion > KDChartDataRegionList;
00169 
00170 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys