SawUtils.cpp

00001 /***************************************************************************
00002 *   Copyright (C) 2005 by Nestor Aguirre                                  *
00003 *   nfaguirrec@unal.edu.co                                                *
00004 *                                                                         *
00005 *   This program is free software; you can redistribute it and/or modify  *
00006 *   it under the terms of the GNU General Public License as published by  *
00007 *   the Free Software Foundation; either version 2 of the License, or     *
00008 *   (at your option) any later version.                                   *
00009 *                                                                         *
00010 *   This program is distributed in the hope that it will be useful,       *
00011 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013 *   GNU General Public License for more details.                          *
00014 *                                                                         *
00015 *   You should have received a copy of the GNU General Public License     *
00016 *   along with this program; if not, write to the                         *
00017 *   Free Software Foundation, Inc.,                                       *
00018 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019 ***************************************************************************/
00020 #include <SawUtils.h>
00021 
00022 /***********************************
00023 * Project
00024 */
00025 #include <SawVector.h>
00026 #include <SawVectorList.h>
00027 
00028 //**********************************
00029 
00030 SawUtils::SawUtils()
00031 {}
00032 
00033 SawUtils::~SawUtils()
00034 {}
00035 
00036 void SawUtils::writeWithFormatMapStyle( ostream& os, SawVector keys, SawVectorList values, int numberColumns, SawObject::NumberFormat formatKeys )
00037 {
00038         bool scientific = false ;
00039         
00040         os.precision( values[0].getPrecisionOutputStream() ) ;
00041                 
00042         os.setf( ios::fixed , ios::floatfield ) ;
00043         
00044         int intro = 0 ; //Numero de veces que entro al ciclo siguiente
00045         
00046         for( int k=0; k < floor((double)keys.getSize()/(double)numberColumns) ; k++ ){
00047         
00048                 for( int i=k*numberColumns+1; i < (k+1)*numberColumns+1; i++ )
00049                         os << setw( values[0].getWidthOutputStream() ) << i ;
00050                         
00051                 os << endl ;
00052         
00053                 for( int i=k*numberColumns; i < (k+1)*numberColumns; i++ )
00054                         os << setw( values[0].getWidthOutputStream() ) << keys.get(i) ;    
00055                         
00056                 os << endl ;
00057                 os << endl ;
00058                 
00059                 for( int i=0; i < values[0].getSize(); i++ ){
00060                         for( int j=k*numberColumns; j < (k+1)*numberColumns; j++ ){
00061                                 if( !scientific )
00062                                         os << setw( values[0].getWidthOutputStream() ) << values[j].get(i) ;
00063                                 else
00064                                         os << setw( values[0].getWidthOutputStream() + 3 ) << values[j].get(i) ;
00065                         }
00066                         os << endl ;
00067                 }
00068                 
00069                 os << endl ;
00070                 os << endl ;
00071                 
00072                 intro++ ;
00073         }
00074         
00075         for( int i=intro*numberColumns+1; i < intro*numberColumns+keys.getSize()%numberColumns+1 ; i++ )
00076                 os << setw( values[0].getWidthOutputStream() ) << i ;
00077                 
00078         os << endl ;
00079 
00080         for( int i=intro*numberColumns; i < intro*numberColumns+keys.getSize()%numberColumns; i++ )
00081                 os << setw( values[0].getWidthOutputStream() ) << keys.get(i) ;    
00082                 
00083         os << endl ;
00084         os << endl ;
00085         
00086         for( int i=0; i < values[0].getSize(); i++ ){
00087                 for( int j=intro*numberColumns; j < intro*numberColumns+keys.getSize()%numberColumns; j++ ){
00088                         if( !scientific )
00089                                 os << setw( values[0].getWidthOutputStream() ) << values[j].get(i) ;
00090                         else
00091                                 os << setw( values[0].getWidthOutputStream() + 3 ) << values[j].get(i) ;
00092                 }
00093                 os << endl ;
00094         }
00095 }

Generado el Sun Jul 22 18:05:41 2007 para SAW por  doxygen 1.5.1