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

matvec::Plotter Class Reference

#include <plotter.h>

List of all members.


Detailed Description

an object to plot curves

Definition at line 34 of file plotter.h.

Public Types

enum  plot_cmd { plt, replt }

Public Methods

 Plotter (const std::string &pp="gnuplot")
 Plotter (const Plotter &p)
 ~Plotter (void)
int plot (const std::string &cmd, Plotter::plot_cmd pc=Plotter::plt)
int plot3D (const std::string &cmd)
int plot (const doubleMatrix &dat, Plotter::plot_cmd pc=Plotter::plt, const std::string &options="title'y'with lines")
int plot3D (const doubleMatrix &dat, const std::string &options="title'z'with lines")
int replot (void)
int save (const std::string &fname, const std::string &device="postscript")
int set (const std::string &para)
int display (void) const
int open (void)
void close (void)

Protected Attributes

FILE * plot_pipe
std::string plot_program
std::string data_fname


Member Enumeration Documentation

enum matvec::Plotter::plot_cmd
 

Enumeration values:
plt 
replt 

Definition at line 41 of file plotter.h.

00041 {plt, replt};


Constructor & Destructor Documentation

matvec::Plotter::Plotter const std::string &    pp = "gnuplot"
 

Definition at line 29 of file plotter.cpp.

References data_fname, matvec::Session::mktemp(), plot_pipe, plot_program, and matvec::SESSION.

00030 {
00031     plot_program = pp;
00032     plot_pipe = 0;
00033     data_fname = SESSION.mktemp();
00034 }

matvec::Plotter::Plotter const Plotter &    p
 

Definition at line 36 of file plotter.cpp.

References data_fname, plot_pipe, and plot_program.

00037 {
00038    plot_program = p.plot_program;
00039    plot_pipe    = p.plot_pipe;
00040    data_fname   = p.data_fname;
00041 }

matvec::Plotter::~Plotter void    [inline]
 

Definition at line 39 of file plotter.h.

References close().

00039 {close();}


Member Function Documentation

void matvec::Plotter::close void   
 

Definition at line 134 of file plotter.cpp.

References plot_pipe.

Referenced by ~Plotter().

00135 {
00136    if (plot_pipe) {
00137       pclose(plot_pipe);
00138       plot_pipe = 0;
00139    }
00140 }

int matvec::Plotter::display void    const [inline]
 

Definition at line 52 of file plotter.h.

00052 {std::cout<<"\tan object of Plotter\n";return 1;}

int matvec::Plotter::open void   
 

Definition at line 128 of file plotter.cpp.

References plot_pipe, and plot_program.

Referenced by plot(), plot3D(), and set().

00129 {
00130    if (! plot_pipe) plot_pipe = popen(plot_program.c_str(),"w");
00131    return 1;
00132 }

int matvec::Plotter::plot const doubleMatrix   dat,
Plotter::plot_cmd    pc = Plotter::plt,
const std::string &    options = "title'y'with lines"
 

Definition at line 65 of file plotter.cpp.

References data_fname, matvec::Session::mktemp(), matvec::Matrix< double >::num_cols(), open(), plot_pipe, matvec::Matrix< double >::save(), matvec::SESSION, and matvec::warning().

00066 {
00067    if (pc == Plotter::replt) { data_fname = SESSION.mktemp();}
00068    dat.save(data_fname,std::ios::out);
00069    this->open();
00070    if (dat.num_cols() >= 1) {
00071       if (pc == Plotter::plt) {
00072          fprintf(plot_pipe,"plot \"%s\" %s\n",data_fname.c_str(),options.c_str());
00073       }
00074       else if (pc == Plotter::replt) {
00075          fprintf(plot_pipe,"replot \"%s\" %s\n",data_fname.c_str(),options.c_str());
00076       }
00077    }
00078    else {
00079       warning("Plotter::plot(data): data is empty");
00080    }
00081    fflush(plot_pipe);
00082    return 1;
00083 }

int matvec::Plotter::plot const std::string &    cmd,
Plotter::plot_cmd    pc = Plotter::plt
 

Definition at line 43 of file plotter.cpp.

References open(), and plot_pipe.

00044 {
00045    this->open();
00046    if (pc == Plotter::plt) {
00047       fprintf(plot_pipe,"plot %s\n",cmd.c_str());
00048       fflush(plot_pipe);
00049    }
00050    else if (pc == Plotter::replt) {
00051       fprintf(plot_pipe,"replot %s\n",cmd.c_str());
00052       fflush(plot_pipe);
00053    }
00054    return 1;
00055 }

int matvec::Plotter::plot3D const doubleMatrix   dat,
const std::string &    options = "title'z'with lines"
 

Definition at line 85 of file plotter.cpp.

References data_fname, matvec::Matrix< double >::num_cols(), open(), plot_pipe, matvec::Matrix< double >::save(), and matvec::warning().

00086 {
00087    dat.save(data_fname.c_str(),std::ios::out);
00088    this->open();
00089    if (dat.num_cols() >= 3) {
00090       fprintf(plot_pipe,"splot \"%s\" %s\n",data_fname.c_str(),options.c_str());
00091    }
00092    else {
00093       warning("Plotter::plot(data): data needs at least three columns");
00094    }
00095    fflush(plot_pipe);
00096    return 1;
00097 }

int matvec::Plotter::plot3D const std::string &    cmd
 

Definition at line 57 of file plotter.cpp.

References open(), and plot_pipe.

00058 {
00059    this->open();
00060    fprintf(plot_pipe,"splot %s\n",cmd.c_str());
00061    fflush(plot_pipe);
00062    return 1;
00063 }

int matvec::Plotter::replot void   
 

Definition at line 99 of file plotter.cpp.

References plot_pipe, and matvec::warning().

00100 {
00101    if (plot_pipe) {
00102       fprintf(plot_pipe,"set terminal x11\n");
00103       fprintf(plot_pipe,"replot\n");  fflush(plot_pipe);
00104    }
00105    else {
00106       warning("Plotter::replot(): no  previous plotting has been found");
00107    }
00108    return 1;
00109 }

int matvec::Plotter::save const std::string &    fname,
const std::string &    device = "postscript"
 

Definition at line 119 of file plotter.cpp.

References plot_pipe.

00120 {
00121    fprintf(plot_pipe,"set terminal %s\n",device.c_str());
00122    fprintf(plot_pipe,"set output \"%s\" \n",fname.c_str());
00123    fprintf(plot_pipe,"replot\n");
00124    fflush(plot_pipe);
00125    return 1;
00126 }

int matvec::Plotter::set const std::string &    para
 

Definition at line 111 of file plotter.cpp.

References open(), and plot_pipe.

00112 {
00113    if (!plot_pipe) this->open();
00114    fprintf(plot_pipe,"set %s\n",settings.c_str());
00115    fflush(plot_pipe);
00116    return 1;
00117 }


Member Data Documentation

std::string matvec::Plotter::data_fname [protected]
 

Definition at line 58 of file plotter.h.

Referenced by plot(), plot3D(), and Plotter().

FILE* matvec::Plotter::plot_pipe [protected]
 

Definition at line 57 of file plotter.h.

Referenced by close(), open(), plot(), plot3D(), Plotter(), replot(), save(), and set().

std::string matvec::Plotter::plot_program [protected]
 

Definition at line 58 of file plotter.h.

Referenced by open(), and Plotter().


The documentation for this class was generated from the following files:
Generated on Thu Jun 16 17:14:43 2005 for Matvec by doxygen1.2.16