EvolvingObjects
|
00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 //----------------------------------------------------------------------------- 00004 // eoGnuplot1DSnapshot.h 00005 // (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000 00006 /* 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 Contact: todos@geneura.ugr.es, http://geneura.ugr.es 00022 Marc.Schoenauer@inria.fr 00023 mkeijzer@dhi.dk 00024 */ 00025 //----------------------------------------------------------------------------- 00026 00027 00028 #ifndef EO_eoGnuplot1DSnapshot_H 00029 #define EO_eoGnuplot1DSnapshot_H 00030 00031 #include <fstream> 00032 #include <sstream> 00033 #include <string> 00034 00035 #include <eoObject.h> 00036 #include "eoRealVectorBounds.h" 00037 #include <utils/pipecom.h> 00038 #include <utils/eoFileSnapshot.h> 00039 #include <utils/eoGnuplot.h> 00040 00053 class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot 00054 { 00055 public: 00056 // Ctor 00057 eoGnuplot1DSnapshot(std::string _dirname, unsigned _frequency = 1, 00058 std::string _filename = "gen", std::string _delim = " ", 00059 unsigned _counter = 0, bool _rmFiles = true) : 00060 eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles), 00061 eoGnuplot(_filename,"set data style points"), 00062 pointSize(5) 00063 {} 00064 00065 // Ctor 00066 eoGnuplot1DSnapshot(std::string _dirname, eoRealVectorBounds & _bounds, 00067 unsigned _frequency = 1, std::string _filename = "gen", 00068 std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true ) : 00069 eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles), 00070 eoGnuplot(_filename,"set data style points"), 00071 pointSize(5) 00072 { 00073 handleBounds(_bounds); 00074 } 00075 // Ctor 00076 eoGnuplot1DSnapshot(eoFileSnapshot & _fSnapshot) : 00077 eoFileSnapshot(_fSnapshot), 00078 eoGnuplot(_fSnapshot.baseFileName(),"set data style points"), 00079 pointSize(5) 00080 {} 00081 00082 // Ctor with range 00083 eoGnuplot1DSnapshot(eoFileSnapshot & _fSnapshot, eoRealVectorBounds & _bounds) : 00084 eoFileSnapshot(_fSnapshot), 00085 eoGnuplot(_fSnapshot.baseFileName(),"set data style points"), 00086 pointSize(5) 00087 { 00088 handleBounds(_bounds); 00089 } 00090 00091 // Dtor 00092 virtual ~eoGnuplot1DSnapshot(){} 00093 00094 virtual eoMonitor& operator()(); 00095 00097 virtual std::string className() const { return "eoGnuplot1DSnapshot"; } 00098 00099 virtual void handleBounds(eoRealVectorBounds & _bounds) 00100 { 00101 std::ostringstream os; 00102 os << "set autoscale\nset yrange [" ; 00103 if (_bounds.isMinBounded(0)) 00104 os << _bounds.minimum(0); 00105 os << ":" ; 00106 if (_bounds.isMaxBounded(0)) 00107 os << _bounds.maximum(0); 00108 os << "]\n"; 00109 gnuplotCommand(os.str()); 00110 } 00111 00112 void setPointSize(unsigned _pointSize) 00113 { pointSize = _pointSize; } 00114 00115 protected: 00116 00117 unsigned pointSize; 00118 }; 00119 00120 00121 #endif