00001 // This plotting program courtesy of M. Rauscher, modifications by K. S. Brown 00002 // Any derived class of GnuPlotter must overload Update, even 00003 // if (as in the example of a one-time plot) you don't use it. 00004 00005 #ifndef GNUPLOTTER_H 00006 #define GNUPLOTTER_H 00007 00008 #include <sstream> 00009 #include <stdio.h> 00010 #include "SubjectObserver.h" 00011 #include <stdlib.h> 00012 00013 class GnuPlotter : public Observer 00014 { 00015 protected: 00016 char title[256]; 00017 char buffnamevalue[256]; 00018 char *buffername; 00019 int buffattempt; 00020 FILE* gnuplot_pipe; 00021 FILE* buffer; 00022 public: 00023 virtual bool SetTitle(const char * text) 00024 { 00025 #ifdef _DEBUG 00026 if (strlen(text)>=255) return(false); 00027 #endif 00028 strcpy(title, text); 00029 return(true); 00030 } 00031 #ifndef SWIG 00032 GnuPlotter(void); 00033 GnuPlotter(FILE * gplotpipe); 00034 virtual ~GnuPlotter(void); 00035 00036 // virtual bool InitializeGnuplot(void)=0; 00037 virtual bool FlushGnuPlotter(void) 00038 { 00039 #ifdef _DEBUG 00040 if (gnuplot_pipe==NULL) return(false); 00041 #endif 00042 fflush(gnuplot_pipe); 00043 return(true); 00044 }; 00045 virtual bool SendPlotCommand(const char* commandstring); 00046 virtual void Update(Subject *theChangedSubject) = 0; 00047 #endif // SWIG 00048 }; 00049 #endif