Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

sxy_series.cpp

Go to the documentation of this file.
00001 // =======================================================================
00002 
00003 char *series_cpp = "$Id: sxy_series.cpp,v 1.5 2003/01/06 22:06:48 clinio Exp $";
00004 
00005 // =======================================================================
00006 
00007 #include <float.h>
00008 #include <xy.h>
00009 
00010 #include "sxy_series.h"
00011 
00012 // =======================================================================
00013 
00014 // .......................................................................
00015 
00016 double SXYSeries::getAnInvalidNumber(void) {
00017    return FLT_MAX + 10.0;
00018 }
00019 
00020 // .......................................................................
00021 
00022 unsigned int SXYSeries::isValidNumber(double n) {
00023    return (n > -FLT_MAX) && (n < FLT_MAX);
00024 }
00025 
00026 // .......................................................................
00027 
00028 void SXYSeries::getSeveralLimits( SXYVector<SXYSeries*> *vector, 
00029 double& xmin, double& xmax, double& ymin, double& ymax ) {
00030    xmin = FLT_MAX; xmax = -FLT_MAX;
00031    ymin = FLT_MAX; ymax = -FLT_MAX;
00032 
00033    unsigned int num_series = vector->getLength();
00034    for (unsigned int s = 0; s < num_series; s++) {
00035        SXYSeries *srs = vector->getElement(s);
00036        assert(srs);
00037        double xi, xa, yi, ya;
00038        srs->getLimits(xi, xa, yi, ya);
00039        if (xi < xmin) xmin = xi;
00040        if (xa > xmax) xmax = xa;
00041        if (yi < ymin) ymin = yi;
00042        if (ya > ymax) ymax = ya;
00043     }
00044 }
00045 
00046 // .......................................................................
00047 
00048 void SXYSeries::writePoint(unsigned int n, double x, double y) {
00049    assert(0);
00050 }
00051 
00052 // .......................................................................
00053 
00054 void SXYSeries::domain (double begin, double end) {
00055   // Não faz nada.
00056 }
00057 
00058 // .......................................................................
00059 
00060 void SXYSeries::domain (double* begin, double* end) const {
00061   // Usa um domínio de menos infinito a mais infinito
00062   *begin = -FLT_MAX;
00063   *end = FLT_MAX;
00064 }
00065 
00066 // .......................................................................
00067 
00068 xybool SXYSeries::changPoint(unsigned int, double, double) { 
00069    // Não tem troca de pontos diretamente sobre os dados originais
00070    return xyfalse; 
00071 }
00072 
00073 // .......................................................................
00080 void SXYSeries::getLimits( double& xmin, double& xmax,
00081 double& ymin, double& ymax ) {
00082    xmin = FLT_MAX; xmax = -FLT_MAX;
00083    ymin = FLT_MAX; ymax = -FLT_MAX;
00084    for( unsigned int i = 0; i < getNumPoints(); i++ ) {
00085       double x, y;
00086       unsigned int has_point = this->getPoint( i, x, y );
00087       if ( has_point ) {
00088          if ( x < xmin ) xmin = x;
00089          if ( x > xmax ) xmax = x;
00090          if ( y < ymin ) ymin = y;
00091          if ( y > ymax ) ymax = y;
00092       }
00093    }
00094 
00095    if ( xmin > xmax ) {
00096       double tmp = xmin;
00097       xmin = xmax; xmax = tmp;
00098    }
00099 
00100    if ( ymin > ymax ) {
00101       double tmp = ymin;
00102       ymin = ymax; ymax = tmp;
00103    }
00104 }
00105 
00106 // .......................................................................
00107 
00108 unsigned int SXYSeries::numPoints (void) {
00109    // Repasse a outro método a ser redefinido.
00110    unsigned int np = getNumPoints();
00111    return np;
00112 }
00113 
00114 // .......................................................................
00115 
00116 xybool SXYSeries::point (int n, double& x, double& y) {
00117    // Repasse a outro método a ser redefinido.
00118    unsigned int np = getNumPoints();
00119    unsigned int i = n;
00120    if ( i < 0 || i >= np ) return xyfalse;
00121    unsigned int result = getPoint(n, x, y);
00122    return result ? xytrue : xyfalse;
00123 }
00124 
00125 // .......................................................................
00126 
00127 SXYSeries::SXYSeries() { 
00128   // Não faz nada.
00129 }
00130 
00131 // .......................................................................
00132 
00133 SXYSeries::~SXYSeries() {
00134   // Não faz nada.
00135 }
00136 

SXY
Tecgraf / PUC-Rio - Computer Graphics Technology Group