Changeset 107
- Timestamp:
- Jun 28, 2006, 11:12:38 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Gnuplot.cc
r101 r107 79 79 int Gnuplot::command(const std::string& cmdstr) 80 80 { 81 std::cout << cmdstr << std::endl; 81 82 int r = fputs(cmdstr.c_str(),pipe_); 82 if (*(cmdstr.rbegin())!='\n') 83 fputc('\n',pipe_); 84 fflush(pipe_); 85 return r; 83 if (!r && *(cmdstr.rbegin())!='\n') 84 r=fputc('\n',pipe_); 85 return (r ? r : fflush(pipe_)); 86 86 } 87 87 -
trunk/lib/Gnuplot.h
r101 r107 33 33 #include <vector> 34 34 35 36 #include <iostream> 35 37 36 38 namespace theplu { … … 70 72 /// Send arbitrary commands to Gnuplot. 71 73 /// 74 /// @return 0 if fputs, fputc, and fflush are succesful 75 /// 72 76 int command(const std::string&); 73 77 … … 93 97 /// Gnuplot usage. 94 98 /// 99 /// @return whatever command() returns 100 /// 95 101 template <class T1, class T2> 96 voidplot(const std::vector<T1>& y, const std::vector<T2>& x)97 { plot(y,x,"plot"); }102 int plot(const std::vector<T1>& y, const std::vector<T2>& x) 103 { return plot(y,x,"plot"); } 98 104 99 105 template <class T1> 100 voidplot(const std::vector<T1>& y,106 int plot(const std::vector<T1>& y, 101 107 const std::vector<T1>& x=std::vector<T1>()) 102 { plot(y,x,"plot"); }108 { return plot(y,x,"plot"); } 103 109 104 110 /// … … 107 113 /// Gnuplot usage. 108 114 /// 115 /// @return whatever command() returns 116 /// 109 117 template <class T1, class T2> 110 voidreplot(const std::vector<T1>& y, const std::vector<T2>& x)111 { plot(y,x,"replot"); }118 int replot(const std::vector<T1>& y, const std::vector<T2>& x) 119 { return plot(y,x,"replot"); } 112 120 113 121 template <class T1> 114 voidreplot(const std::vector<T1>& y,122 int replot(const std::vector<T1>& y, 115 123 const std::vector<T1>& x=std::vector<T1>()) 116 { plot(y,x,"replot"); }124 { return plot(y,x,"replot"); } 117 125 118 126 private: … … 128 136 /// 129 137 template <class T1, class T2> 130 voidplot(const std::vector<T1>& y, const std::vector<T2>& x,138 int plot(const std::vector<T1>& y, const std::vector<T2>& x, 131 139 const std::string& plotcmd) 132 140 { … … 146 154 cmdstring << "e\n"; 147 155 148 command(cmdstring.str());156 return command(cmdstring.str()); 149 157 } 150 158 -
trunk/lib/Parser.cc
r103 r107 41 41 if (where==str.end()) 42 42 type_.push_back(empty); 43 else if (*where=='/' && *(where+1)=='/')43 else if (*where=='/' && ((where++)!=str.end()) && *where=='/') 44 44 type_.push_back(comment); 45 45 else -
trunk/test/gnuplot_pipe.cc
r84 r107 24 24 #include "Gnuplot.h" 25 25 26 #include <iostream> 26 27 #include <vector> 27 28 … … 39 40 40 41 svnstat::Gnuplot gnuplot1; 41 gnuplot1.command("set output 'test1.png'; set term png ; set title 'sine'"); 42 gnuplot1.command("plot sin(x) title 'sine of x' with lines"); 42 //if (gnuplot1.command("set output 'test1.png'; set term png ; set title 'sine'")) 43 //ok = false; 44 //if (gnuplot1.command("plot sin(x) title 'sine of x' with lines")) 45 //ok = false; 43 46 44 47 svnstat::Gnuplot gnuplot2; 45 gnuplot2.command("set output 'test2.png'; set term png");46 gnuplot2.plot(x);48 //if (gnuplot2.command("set output 'test2.png'; set term png")) 49 //gnuplot2.plot(x); 47 50 48 51 svnstat::Gnuplot gnuplot3; 49 gnuplot3.command("set output 'test3.png'; set term png"); 52 if (gnuplot3.command("set output 'test3.png'; set term png")) 53 ok=false; 50 54 gnuplot3.linetitle("parabola"); 51 gnuplot3.plot(x,y); 52 53 gnuplot3.command("set output 'test4.png'; set title 'composite'"); 55 if (gnuplot3.plot(x,y)) 56 ok=false; 57 if (gnuplot3.command("set output 'test4.png'; set title 'composite'")) 58 ok=false; 54 59 gnuplot3.linestyle("linespoints"); 55 60 gnuplot3.linetitle(""); 56 gnuplot3.replot(x); 61 if (gnuplot3.replot(x)) 62 ok=false; 57 63 58 64 /*
Note: See TracChangeset
for help on using the changeset viewer.