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

graphinfo.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the OPIE Project
00003                =.
00004              .=l.            Copyright (c)  2002 Dan Williams <drw@handhelds.org>
00005            .>+-=
00006  _;:,     .>    :=|.         This file is free software; you can
00007 .> <`_,   >  .   <=          redistribute it and/or modify it under
00008 :`=1 )Y*s>-.--   :           the terms of the GNU General Public
00009 .="- .-=="i,     .._         License as published by the Free Software
00010  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00011      ._= =}       :          or (at your option) any later version.
00012     .%`+i>       _;_.
00013     .i_,=:_.      -<s.       This file is distributed in the hope that
00014      +  .  -:.       =       it will be useful, but WITHOUT ANY WARRANTY;
00015     : ..    .:,     . . .    without even the implied warranty of
00016     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00017   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU General
00018 ..}^=.=       =       ;      Public License for more details.
00019 ++=   -.     .`     .:
00020  :     =  ...= . :.=-        You should have received a copy of the GNU
00021  -.   .:....=;==+<;          General Public License along with this file;
00022   -_. . .   )=.  =           see the file COPYING. If not, write to the
00023     --        :-=`           Free Software Foundation, Inc.,
00024                              59 Temple Place - Suite 330,
00025                              Boston, MA 02111-1307, USA.
00026 
00027 */
00028 
00029 #include "graphinfo.h"
00030 
00031 GraphInfo::GraphInfo( GraphType type, DataPointList *data, const QString &title,
00032                                           const QString &xtitle, const QString &ytitle )
00033 {
00034         t = type;
00035         d = data;
00036         gt = title;
00037         xt = xtitle;
00038         yt = ytitle;
00039 }
00040 
00041 GraphInfo::~GraphInfo()
00042 {
00043         if ( d )
00044         {
00045                 for ( DataPointInfo *data = d->first(); data; data = d->next() )
00046                 {
00047                         delete data;
00048                 }
00049         }
00050 }
00051 
00052 GraphInfo::GraphType GraphInfo::graphType()
00053 {
00054         return t;
00055 }
00056 
00057 void GraphInfo::setGraphType( GraphType type )
00058 {
00059         t = type;
00060 }
00061 
00062 DataPointList *GraphInfo::dataPoints()
00063 {
00064         return d;
00065 }
00066 
00067 void GraphInfo::setDataPoints( DataPointList *data )
00068 {
00069         d = data;
00070 }
00071 
00072 DataPointInfo *GraphInfo::firstDataPoint()
00073 {
00074         return( d->first() );
00075 }
00076 
00077 DataPointInfo *GraphInfo::nextDataPoint()
00078 {
00079         return( d->next() );
00080 }
00081 
00082 int GraphInfo::numberDataPoints()
00083 {
00084         return( d->count() );
00085 }
00086 
00087 float GraphInfo::maxValue()
00088 {
00089         float max = 0.0;
00090         for ( DataPointInfo *data = d->first(); data; data = d->next() )
00091         {
00092                 if ( data->value() > max )
00093                 {
00094                         max = data->value();
00095                 }
00096         }
00097         return max;
00098 }
00099 
00100 float GraphInfo::minValue()
00101 {
00102         float min = 0.0;
00103         for ( DataPointInfo *data = d->first(); data; data = d->next() )
00104         {
00105                 if ( data->value() < min )
00106                 {
00107                         min = data->value();
00108                 }
00109         }
00110         return min;
00111 }
00112 
00113 float GraphInfo::totalValue()
00114 {
00115         float sum = 0.0;
00116         for ( DataPointInfo *data = d->first(); data; data = d->next() )
00117         {
00118                 sum += data->value();
00119         }
00120         return sum;
00121 }
00122 
00123 void GraphInfo::setGraphTitle( const QString &title )
00124 {
00125         gt = title;
00126 }
00127 
00128 void GraphInfo::setXAxisTitle( const QString &xtitle )
00129 {
00130         xt = xtitle;
00131 }
00132 
00133 void GraphInfo::setYAxisTitle( const QString &ytitle )
00134 {
00135         yt = ytitle;
00136 }

Generated on Sat Nov 5 16:16:47 2005 for OPIE by  doxygen 1.4.2