Plot.cpp

Go to the documentation of this file.
00001 
00002 
00008 /* 
00009 *
00010 */
00012 
00013 #include "Plot.h"
00014 namespace O_SESSAME {
00015 
00016 Plot::Plot()
00017 {
00018     m_pipeVar = popen("gnuplot","w");
00019         
00020     char tmpname[L_tmpnam];
00021     m_dataFilename = tmpnam(tmpname);
00022     
00023     return;
00024 }
00025 Plot::~Plot()
00026 {
00027     // delete data file
00028     pclose(m_pipeVar); // close pipe when you are finished with plotting
00029     return;
00030 }
00031 Plot::Plot(const Matrix &_data)
00032 {
00033     Plot();
00034     AddPlot(_data);
00035     return;
00036 }
00037 Plot::Plot(const Matrix &_data, int _cols[], const int &_numCols)
00038 {
00039     Plot();
00040     AddPlot(_data, _cols, _numCols);
00041 }
00042 
00043 void Plot::AddPlot(const Matrix &_data)
00044 {
00045     ofstream ofile;
00046     ofile.open(m_dataFilename);
00047     ofile << _data;
00048     ofile.close();
00049     
00050     fprintf(m_pipeVar, "plot '%s' with linespoints\n", m_dataFilename);
00051     fflush(m_pipeVar);
00052     for(int ii = MatrixIndexBase+2;ii < MatrixIndexBase + _data[MatrixColsIndex].getIndexBound();++ii)
00053     {
00054         fprintf(m_pipeVar, "replot '%s' using 1:%i with linespoints\n", m_dataFilename, ii);
00055         fflush(m_pipeVar);
00056     }
00057     fflush(m_pipeVar); // pipes are buffered, so flush buffer after you are finished
00058     return;
00059 }
00060 
00061 void Plot::AddPlot(const Matrix &_data, int _cols[], const int &_numCols)
00062 {
00063     for(int ii = 0;ii < _numCols;++ii)
00064     {
00065         fprintf(m_pipeVar, "replot '%s' using 1:%i with linespoints\n", m_dataFilename, ii);
00066         fflush(m_pipeVar);
00067     }    
00068     return;
00069 }
00070 
00071 void Plot::Title(const char *_titleString)
00072 {
00073     fprintf(m_pipeVar, "set title '%s' \n", _titleString);
00074     fflush(m_pipeVar);
00075     return;
00076 }
00077 
00078 void Plot::Set(const char *_parameterName, const char *_values)
00079 {
00080     return;
00081 }
00082 void Plot::Command(const char *_stringCommand)
00083 {
00084     return;
00085 }
00086 } // close namespace O_SESSAME
00087 
00088 // Do not change the comments below - they will be added automatically by CVS
00089 /*****************************************************************************
00090 *       $Log: Plot.cpp,v $
00091 *       Revision 1.3  2003/05/13 18:58:27  nilspace
00092 *       Cleaned up comments.
00093 *       
00094 *       Revision 1.2  2003/04/27 22:04:34  nilspace
00095 *       Created the namespace O_SESSAME.
00096 *       
00097 *       Revision 1.1  2003/04/08 22:31:25  nilspace
00098 *       Initial Submission.
00099 *       
00100 *       
00101 *
00102 ******************************************************************************/

Generated on Wed Aug 6 12:58:50 2003 for Open-Sessame Framework by doxygen1.3