//////////////////////////////////////////// // // C++ interface to gnuplot for MSVC 6.0 // // Modifications by Peter Blockley // peterblockley.tripod.com // /////////////////////////////////////////// //////////////////////////////////////////// // // A C++ interface to gnuplot. // // This is a direct translation from the C interface // written by N. Devillard (which is available from // http://ndevilla.free.fr/gnuplot/). // // As in the C interface this uses pipes and so wont // run on a system that does'nt have POSIX pipe // support // // Rajarshi Guha // // // 07/03/03 // // 26/01/04 - Gnuplot::cmd() was rewritten to accept a // char* rather than a std::string, thus avoiding the // va_start warning at compile time // ///////////////////////////////////////// #include //#include //#include #include #include //#include //#include //#include //#include //#include #include #include #include #include #include //#include #ifndef _GNUPLOT_PIPES_H_ #define _GNUPLOT_PIPES_H_ #define GP_MAX_TMP_FILES 64 #define GP_TMP_NAME_SIZE 512 #define GP_CMD_SIZE 1024 #define GP_TITLE_SIZE 80 using namespace std; class GnuplotException : public runtime_error { public: GnuplotException(const string &msg) : runtime_error(msg){} }; class Gnuplot { private: FILE *gnucmd; string pstyle; vector to_delete; int nplots; bool get_program_path(const string); bool valid; public: Gnuplot(); // set a style during construction Gnuplot(const string &); // The equivilant of gnuplot_plot_once, the two forms // allow you to plot either (x,y) pairs or just a single // vector at one go Gnuplot(const string &, // title const string &, // style const string &, // xlabel const string &, // ylabel vector, vector); Gnuplot(const string &, //title const string &, //style const string &, //xlabel const string &, //ylabel vector); ~Gnuplot(); // send a command to gnuplot void cmd(const char*, ...); // set line style void set_style(const string &); // set y and x axis labels void set_ylabel(const string &); void set_xlabel(const string &); // plot a single vector void plot_x(vector, const string & // title ); // plot x,y pairs void plot_xy(vector, vector, const string & // title ); // plot an equation of the form: y = ax + b // You supply a and b void plot_slope( double, // a double, // b const string & // title ); // plot an equation supplied as a string void plot_equation( const string &, // equation const string & // title ); // if multiple plots are present it will clear the plot area void reset_plot(void); bool is_valid(void); }; #endif