kchart

KDChartTableBase.h
Go to the documentation of this file.
1/*
2 KDChart - a multi-platform charting engine
3*/
4
5/****************************************************************************
6 ** Copyright (C) 2001-2003 Klarälvdalens Datakonsult AB. All rights reserved.
7 **
8 ** This file is part of the KDChart library.
9 **
10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file.
14 **
15 ** Licensees holding valid commercial KDChart licenses may use this file in
16 ** accordance with the KDChart Commercial License Agreement provided with
17 ** the Software.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ** See http://www.klaralvdalens-datakonsult.se/?page=products for
23 ** information about KDChart Commercial License Agreements.
24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you.
27 **
28 **********************************************************************/
29#ifndef __KDCHARTTABLEINTERFACE_H__
30#define __KDCHARTTABLEINTERFACE_H__
31
32
33class TQTable;
34
35#include <tqvariant.h>
36#include <tqobject.h>
37#include <tqdatetime.h>
38
39#include <kdchart_export.h>
40
41#if defined( SUN7 ) || defined (_SGIAPI)
42 #include <float.h>
43 #include <limits.h>
44#else
45 #include <cfloat>
46 #include <climits>
47#endif
48
49
59#define KDCHART_POS_INFINITE DBL_MAX
60
70#define KDCHART_NEG_INFINITE -DBL_MAX
71
72
85
87class KDCHART_EXPORT KDChartTableDataBase :public TQObject
88{
89 TQ_OBJECT
90
91public:
98 TQObject( 0 ),
99 _sorted(false),
100 _useUsedRows(false),
101 _useUsedCols(false) {}
102
107 KDChartTableDataBase( const KDChartTableDataBase& other ) :TQObject(0)
108 {
109 _sorted = other._sorted;
110 _useUsedRows = other._useUsedRows;
111 _useUsedCols = other._useUsedCols;
112 _usedRows = other._usedRows;
113 _usedCols = other._usedCols;
114 }
115
121
122public slots:
133 virtual uint rows() const = 0;
144 virtual uint cols() const = 0;
145
160 virtual void setCell( uint _row, uint _col,
161 const TQVariant& _value1,
162 const TQVariant& _value2=TQVariant() ) = 0;
175 virtual void setProp( uint _row, uint _col,
176 int _propSet=0 ) = 0;
177
194 virtual bool cellCoord( uint _row, uint _col,
195 TQVariant& _value,
196 int coordinate=1 ) const = 0;
197
219 virtual TQVariant cellVal( uint _row, uint _col, int coordinate=1 ) const {
220 TQVariant value;
221 if( cellCoord( _row, _col, value, coordinate ) )
222 return value;
223 else
224 return TQVariant();
225 }
226
239 virtual bool cellProp( uint _row, uint _col,
240 int& _prop ) const = 0;
241
256 virtual void expand( uint _rows, uint _cols ) = 0;
257
258
259
260 // E N D O F pure-virtual function declarations
261
262
263
270 virtual bool cellContent( uint _row, uint _col,
271 TQVariant& _value1,
272 TQVariant& _value2,
273 int& _prop ) const
274 {
275 return cellCoords(_row,_col, _value1,_value2) &&
276 cellProp(_row,_col, _prop);
277 }
278
284 virtual bool cellCoords( uint _row, uint _col,
285 TQVariant& _value1,
286 TQVariant& _value2 ) const
287 {
288 return cellCoord(_row,_col, _value1, 1) &&
289 cellCoord(_row,_col, _value2, 2);
290 }
291
292
303 virtual void setUsedRows( uint _rows );
311 virtual uint usedRows() const;
312
323 virtual void setUsedCols( uint _cols );
331 virtual uint usedCols() const;
332
333
348 virtual uint colsScrolledBy() const
349 {
350 return 0;
351 }
352
353
359 virtual void setSorted(bool sorted);
365 virtual bool sorted() const;
366
378 virtual bool isPosInfinite( double value ) const
379 {
380 return value == KDCHART_POS_INFINITE;
381 }
382
394 virtual bool isNegInfinite( double value ) const
395 {
396 return value == KDCHART_NEG_INFINITE;
397 }
398
411 virtual bool isNormalDouble( double value ) const
412 {
413 return !isPosInfinite( value ) && !isNegInfinite( value );
414 }
415
430 bool isNormalDouble( TQVariant value, double& dVal ) const
431 {
432 if( TQVariant::Double != value.type() )
433 return false;
434 dVal = value.toDouble();
435 return isNormalDouble( dVal );
436 }
437
438 virtual void importFromQTable( TQTable* table );
439
440 virtual double maxValue( int coordinate=1 ) const;
441 virtual double minValue( int coordinate=1, bool bOnlyGTZero=false ) const;
442
443 virtual TQDateTime maxDtValue( int coordinate=1 ) const;
444 virtual TQDateTime minDtValue( int coordinate=1 ) const;
445
446 virtual double maxColSum( int coordinate=1 ) const;
447 virtual double minColSum( int coordinate=1 ) const;
448 virtual double maxColSum( uint row, uint row2, int coordinate=1 ) const;
449 virtual double minColSum( uint row, uint row2, int coordinate=1 ) const;
450 virtual double colSum( uint col, int coordinate=1 ) const;
451 virtual double colAbsSum( uint col, int coordinate=1 ) const;
452 virtual double maxRowSum( int coordinate=1 ) const;
453 virtual double minRowSum( int coordinate=1 ) const;
454 virtual double rowSum( uint row, int coordinate=1 ) const;
455 virtual double rowAbsSum( uint row, int coordinate=1 ) const;
456 virtual double maxInColumn( uint col, int coordinate=1 ) const;
457 virtual double minInColumn( uint col, int coordinate=1 ) const;
458 virtual double maxInRow( uint row, int coordinate=1 ) const;
459 virtual double minInRow( uint row, int coordinate=1 ) const;
460 virtual double maxInRows( uint row, uint row2, int coordinate=1 ) const;
461 virtual double minInRows( uint row, uint row2, int coordinate=1, bool bOnlyGTZero=false ) const;
462 virtual TQDateTime maxDtInRows( uint row, uint row2, int coordinate=1 ) const;
463 virtual TQDateTime minDtInRows( uint row, uint row2, int coordinate=1 ) const;
464 virtual uint lastPositiveCellInColumn( uint col, int coordinate=1 ) const;
465 virtual bool cellsHaveSeveralCoordinates(TQVariant::Type* type2Ref) const;
466 virtual bool cellsHaveSeveralCoordinates(uint row1=0, uint row2=UINT_MAX,
467 TQVariant::Type* type2Ref=NULL) const;
468 virtual TQVariant::Type cellsValueType( uint row1, uint row2=UINT_MAX,
469 int coordinate=1 ) const;
470 virtual TQVariant::Type cellsValueType( int coordinate=1 ) const;
471private:
472 bool _sorted;
473protected:
474 bool _useUsedRows, _useUsedCols;
475private:
476 uint _usedRows, _usedCols;
477};
478
479#endif
#define KDCHART_NEG_INFINITE
Use special value KDCHART_NEG_INFINITE to indicate negative infinite values.
#define KDCHART_POS_INFINITE
Use special value KDCHART_POS_INFINITE to indicate positive infinite values.
virtual bool cellContent(uint _row, uint _col, TQVariant &_value1, TQVariant &_value2, int &_prop) const
KDChartTableDataBase(const KDChartTableDataBase &other)
Default copy constructor.
virtual bool cellCoord(uint _row, uint _col, TQVariant &_value, int coordinate=1) const =0
Returns one of the coordinate data value(s) stored in a cell.
virtual uint colsScrolledBy() const
Returns the number of cols the table has been scrolled by.
virtual TQVariant cellVal(uint _row, uint _col, int coordinate=1) const
virtual bool isNormalDouble(double value) const
Returns true if the given value represents a normal double value.
bool isNormalDouble(TQVariant value, double &dVal) const
Returns true if the given TQVariant value represents a normal double value.
virtual bool isNegInfinite(double value) const
Returns true if the given value represents a negative infinite value.
virtual void expand(uint _rows, uint _cols)=0
Increases the number of rows (and/or columns, resp.) stored in this table.
virtual uint cols() const =0
Returns the number of cols in the table.
virtual ~KDChartTableDataBase()
Default destructor.
virtual bool cellProp(uint _row, uint _col, int &_prop) const =0
Returns the property set ID stored in a cell.
KDChartTableDataBase()
Default constructor.
virtual void setProp(uint _row, uint _col, int _propSet=0)=0
Specifies the property set ID for a cell.
virtual uint rows() const =0
Returns the number of rows in the table.
virtual bool cellCoords(uint _row, uint _col, TQVariant &_value1, TQVariant &_value2) const
virtual bool isPosInfinite(double value) const
Returns true if the given value represents a positive infinite value.
virtual void setCell(uint _row, uint _col, const TQVariant &_value1, const TQVariant &_value2=TQVariant())=0
Stores data in a cell.