finish the handling of gnuplot completely at build-time.

No gnuplot-ifs in headers anymore.
This commit is contained in:
kuepper 2005-10-05 21:34:19 +00:00
commit afc0659e35
12 changed files with 219 additions and 192 deletions

View file

@ -44,30 +44,34 @@ eoGnuplot::eoGnuplot(std::string _title, std::string _extra)
eoGnuplot::~eoGnuplot()
{
#ifdef HAVE_GNUPLOT
if( gpCom ) {
PipeComSend( gpCom, "quit\n" );
PipeComClose( gpCom );
gpCom =NULL;
}
#endif
}
void eoGnuplot::gnuplotCommand(const char *_command)
{
#ifdef HAVE_GNUPLOT
if(gpCom) {
PipeComSend( gpCom, _command );
PipeComSend( gpCom, "\n" );
}
#endif
}
void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
{
#ifdef HAVE_GNUPLOT
std::ostringstream os;
os << "250x150-0+" << numWindow*170;
numWindow++;
os << "250x150-0+" << 170 * numWindow++;
char *args[6];
args[0] = strdup( GNUPLOT_PROGRAM );
args[1] = strdup( "-geometry" );
@ -83,6 +87,7 @@ void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
PipeComSend( gpCom, _extra.c_str() );
PipeComSend( gpCom, "\n" );
}
#endif
}

View file

@ -29,29 +29,30 @@
#include <sstream>
#include "eoGnuplot1DMonitor.h"
#include "eoParam.h"
#include "utils/eoGnuplot1DMonitor.h"
#include "utils/eoParam.h"
eoMonitor& eoGnuplot1DMonitor::operator() (void)
{
// update file using the eoFileMonitor
eoFileMonitor::operator()();
// sends plot order to gnuplot
// assumes successive plots will have same nb of columns!!!
if (firstTime)
// update file using the eoFileMonitor
eoFileMonitor::operator()();
#ifdef HAVE_GNUPLOT
// sends plot order to gnuplot
// assumes successive plots will have same nb of columns!!!
if (firstTime)
{
FirstPlot();
firstTime = false;
FirstPlot();
firstTime = false;
}
else
else
{
if( gpCom ) {
PipeComSend( gpCom, "replot\n" );
}
if( gpCom ) {
PipeComSend( gpCom, "replot\n" );
}
}
return *this;
#endif
return *this;
}
@ -62,6 +63,7 @@ void eoGnuplot1DMonitor::FirstPlot()
{
throw std::runtime_error("Must have some stats to plot!\n");
}
#ifdef HAVE_GNUPLOT
std::ostringstream os;
os << "plot";
for (unsigned i=1; i<vec.size(); i++) {
@ -72,6 +74,7 @@ void eoGnuplot1DMonitor::FirstPlot()
}
os << '\n';
PipeComSend( gpCom, os.str().c_str());
#endif
}

View file

@ -1,5 +1,3 @@
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// eoGnuplot1DMonitor.h
// (c) Marc Schoenauer, Maarten Keijzer and GeNeura Team, 2000
@ -49,6 +47,7 @@ everytime
class eoGnuplot1DMonitor : public eoFileMonitor, public eoGnuplot
{
public:
using eoMonitor::vec;
/** Constructor */
@ -70,4 +69,13 @@ public:
};
#endif
#endif // EO_eoGnuplot1DMonitor_H
// Local Variables:
// c-file-style: "Stroustrup"
// comment-column: 35
// fill-column: 80
// mode: C++
// End:

View file

@ -6,20 +6,22 @@
inline eoMonitor& eoGnuplot1DSnapshot::operator() (void)
eoMonitor& eoGnuplot1DSnapshot::operator()()
{
// update file using the eoFileMonitor method
eoFileSnapshot::operator()();
// update file using the eoFileMonitor method
eoFileSnapshot::operator()();
// sends plot order to gnuplot
//std::string buff; // need local memory
std::ostringstream os;
os << "set title 'Gen. " << getCounter() << "'; plot '"
// mk: had to use getFilename().c_str(), because it seems the string(stream) lib is screwed in gcc3.2
<< getFileName().c_str() << "' notitle with points ps " << pointSize;
os << std::endl;
PipeComSend( gpCom, os.str().c_str());
return (*this);
#ifdef HAVE_GNUPLOT
// sends plot order to gnuplot
std::ostringstream os;
os << "set title 'Gen. " << getCounter() << "'; plot '"
// mk: had to use getFilename().c_str(),
// because it seems the string(stream) lib is screwed in gcc3.2
<< getFileName().c_str() << "' notitle with points ps " << pointSize
<< std::endl;
PipeComSend(gpCom, os.str().c_str());
#endif
return *this;
}

View file

@ -53,7 +53,8 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
public:
// Ctor
eoGnuplot1DSnapshot(std::string _dirname, unsigned _frequency = 1,
std::string _filename = "gen", std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true) :
std::string _filename = "gen", std::string _delim = " ",
unsigned _counter = 0, bool _rmFiles = true) :
eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles),
eoGnuplot(_filename,"set data style points"),
pointSize(5)
@ -88,7 +89,7 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
// Dtor
virtual ~eoGnuplot1DSnapshot(){}
virtual eoMonitor& operator() (void) ;
virtual eoMonitor& operator()();
/// Class name.
virtual std::string className() const { return "eoGnuplot1DSnapshot"; }
@ -96,20 +97,20 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
virtual void handleBounds(eoRealVectorBounds & _bounds)
{
std::ostringstream os;
// std::ostrstream os;
os << "set autoscale\nset yrange [" ;
if (_bounds.isMinBounded(0))
os << _bounds.minimum(0);
os << ":" ;
if (_bounds.isMaxBounded(0))
os << _bounds.maximum(0);
os << "]\n";
gnuplotCommand(os.str());
os << "set autoscale\nset yrange [" ;
if (_bounds.isMinBounded(0))
os << _bounds.minimum(0);
os << ":" ;
if (_bounds.isMaxBounded(0))
os << _bounds.maximum(0);
os << "]\n";
gnuplotCommand(os.str());
}
unsigned pointSize;
private:
protected:
unsigned pointSize;
};