00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00037
00038 #ifndef _GNUPLOT_HH
00039 #define _GNUPLOT_HH
00040
00041 #include <OpenMesh/Core/System/config.hh>
00042
00043
00044
00045
00046
00047 #if defined(OM_CC_MIPS)
00048 # include <stdio.h>
00049 #else
00050 # include <cstdio>
00051 #endif
00052 #include <string>
00053 #include <vector>
00054 #include <stdexcept>
00055
00056
00057
00058 #ifdef WIN32
00059 # define GP_MAX_TMP_FILES 27 //27 temporary files it's Microsoft restriction
00060 #else
00061 # define GP_MAX_TMP_FILES 64
00062 # define GP_TMP_NAME_SIZE 512
00063 # define GP_TITLE_SIZE 80
00064 #endif
00065 #define GP_CMD_SIZE 1024
00066
00067
00068
00069 using namespace std;
00070
00071
00072
00074 class GnuplotException : public runtime_error
00075 {
00076 public:
00077 GnuplotException(const string &msg) : runtime_error(msg){}
00078 };
00079
00080
00081
00092 class Gnuplot
00093 {
00094 private:
00095
00096 FILE *gnucmd;
00097 string pstyle;
00098 vector<string> to_delete;
00099 int nplots;
00100 bool get_program_path(const string);
00101 bool valid;
00102
00103
00104 static string gnuplot_executable_;
00105
00106 void init();
00107
00108 public:
00109
00111
00112
00113 Gnuplot();
00114
00116 Gnuplot(const string & _style);
00117
00119 Gnuplot(const string & _title,
00120 const string & _style,
00121 const string & _xlabel,
00122 const string & _ylabel,
00123 vector<double> _x, vector<double> _y);
00124
00126 Gnuplot(const string &_title,
00127 const string &_style,
00128 const string &_xlabel,
00129 const string &_ylabel,
00130 vector<double> _x);
00132
00133 ~Gnuplot();
00134
00136 void cmd(const char *_cmd, ...);
00137
00139
00140 void set_style(const string & _style);
00141 void set_ylabel(const string & _ylabel);
00142 void set_xlabel(const string & _xlabel);
00143
00144
00146
00147
00149 void plot_x(vector<double> _x, const string &_title);
00150
00152 void plot_xy(vector<double> _x, vector<double> _y, const string &_title);
00153
00156 void plot_slope(
00157 double _a,
00158 double _b,
00159 const string & _title
00160 );
00161
00163 void plot_equation(
00164 const string & _equation,
00165 const string & _title
00166 );
00167
00169 void reset_plot(void);
00170
00172
00174 bool is_valid(void) const { return valid; }
00175
00177 bool is_active(void) const { return this->nplots > 0; }
00178 };
00179
00180
00181
00182 #endif // _GNUPLOT_HH
00183
00184