KDChartDataRegion.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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 typedef QValueList<QPointArray> PointArrayList;
00043
00044 KDChartDataRegion()
00045 {
00046 init();
00047 }
00048
00049 KDChartDataRegion( QRegion region, uint r, uint c, uint ch )
00050 {
00051 init();
00052 pRegion = new QRegion( region );
00053 row = r;
00054 col = c;
00055 chart = ch;
00056 }
00057
00058 KDChartDataRegion( uint r, uint c, uint ch, QPointArray array )
00059 {
00060 init();
00061 pArray = new QPointArray( array );
00062 row = r;
00063 col = c;
00064 chart = ch;
00065 }
00066
00067 KDChartDataRegion( uint r, uint c, uint ch, QRect rect )
00068 {
00069 init();
00070 pRect = new QRect( rect );
00071 row = r;
00072 col = c;
00073 chart = ch;
00074 }
00075 KDChartDataRegion( uint r, uint c, uint ch, PointArrayList * list, bool takeOwnership )
00076 {
00077 init();
00078 if( takeOwnership )
00079 pPointArrayList = list;
00080 else
00081 pPointArrayList = new PointArrayList( * list );
00082 row = r;
00083 col = c;
00084 chart = ch;
00085 }
00086
00087 ~KDChartDataRegion()
00088 {
00089
00090 if( pPointArrayList )
00091 delete pPointArrayList;
00092 if( pRegion )
00093 delete pRegion;
00094 if( pArray )
00095 delete pArray;
00096 if( pRect )
00097 delete pRect;
00098 if( pTextRegion )
00099 delete pTextRegion;
00100 }
00101
00102 QRegion region() const
00103 {
00104 if( pPointArrayList && ! pPointArrayList->empty() ){
00105 QRegion region;
00106 PointArrayList::iterator it;
00107 for ( it = pPointArrayList->begin(); it != pPointArrayList->end(); ++it ){
00108 region += QRegion( *it );
00109 }
00110 return region;
00111 }
00112 if( pRegion )
00113 return *pRegion;
00114 if( pArray )
00115 return QRegion( *pArray );
00116 if( pRect )
00117 return QRegion( *pRect );
00118 return QRegion();
00119 }
00120
00121 QRect rect() const
00122 {
00123 if( pPointArrayList && ! pPointArrayList->empty() ){
00124 QRect rect;
00125 PointArrayList::iterator it;
00126 for ( it = pPointArrayList->begin(); it != pPointArrayList->end(); ++it ){
00127 rect = rect.unite( (*it).boundingRect() );
00128 }
00129 return rect;
00130 }
00131 if( pRegion )
00132 return pRegion->boundingRect();
00133 if( pArray )
00134 return pArray->boundingRect();
00135 if( pRect )
00136 return *pRect;
00137 return QRect();
00138 }
00139
00140 bool contains(const QPoint & p) const
00141 {
00142 if( pPointArrayList && ! pPointArrayList->empty() ){
00143 PointArrayList::iterator it;
00144 for ( it = pPointArrayList->begin(); it != pPointArrayList->end(); ++it ){
00145 QRegion region( *it );
00146 if( region.contains( p ) )
00147 return true;
00148 }
00149 return false;
00150 }
00151 if( pRegion )
00152 return pRegion->contains( p );
00153 if( pArray )
00154 return QRegion( *pArray ).contains( p );
00155 if( pRect )
00156 return pRect->contains( p );
00157 return false;
00158 }
00159
00160 void init()
00161 {
00162 pRegion = 0;
00163 pArray = 0;
00164 pRect = 0;
00165 pTextRegion = 0;
00166 pPointArrayList = 0;
00167 row = 0;
00168 col = 0;
00169 chart = 0;
00170 negative = false;
00171 points.resize( 9 );
00172 startAngle = 1440;
00173 angleLen = 1;
00174 }
00175
00176 QRegion* pRegion;
00177 QPointArray* pArray;
00178 QRect* pRect;
00179 QRegion* pTextRegion;
00180
00181
00182
00183 PointArrayList* pPointArrayList;
00184
00185
00186
00187
00188
00189
00190
00191 QPointArray points;
00192
00193 int startAngle;
00194 int angleLen;
00195
00196 uint row;
00197 uint col;
00198
00199 uint chart;
00200 QString text;
00201 bool negative;
00202 };
00203
00204
00224 typedef QPtrList < KDChartDataRegion > KDChartDataRegionList;
00225
00226 #endif