Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

Plot.cpp

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////////////////////////
00002 /*! \file Plot.cpp
00003 *  \brief Implementation of the Plot class.
00004 *  \author $Author: cakinli $
00005 *  \version $Revision: 1.1.1.1 $
00006 *  \date    $Date: 2005/04/26 17:41:00 $
00007 *//////////////////////////////////////////////////////////////////////////////////////////////////
00008 /* 
00009 *
00010 */
00011 //////////////////////////////////////////////////////////////////////////////////////////////////
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         std::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.1.1.1  2005/04/26 17:41:00  cakinli
00092 *       Adding OpenSESSAME to DSACSS distrib to capture fixed version.
00093 *       
00094 *       Revision 1.4  2003/10/18 21:37:28  rsharo
00095 *       Removed "../utils" from all qmake project paths. Prepended "utils
00096 *       /" to all #include directives for utils. Removed ".h" extensions from STL header
00097 *       s and referenced STL components from "std::" namespace.  Overall, changed to be
00098 *       more portable.
00099 *       
00100 *       Revision 1.3  2003/05/13 18:58:27  nilspace
00101 *       Cleaned up comments.
00102 *       
00103 *       Revision 1.2  2003/04/27 22:04:34  nilspace
00104 *       Created the namespace O_SESSAME.
00105 *       
00106 *       Revision 1.1  2003/04/08 22:31:25  nilspace
00107 *       Initial Submission.
00108 *       
00109 *       
00110 *
00111 ******************************************************************************/

Generated on Wed Sep 5 12:54:24 2007 for DSACSS Operational Code by  doxygen 1.3.9.1