#include #include "iohelp.h" #include "plotting2.h" //#define XERRORS #define COMPACT_LEGEND // ********************************************************************* // useful global variables const double symbol_size=0.6; int line_thickness=2,Rplot_type; double xmin,xmax,ymin,ymax; double x_major_tick_spacing,y_major_tick_spacing; int x_minor_tick_num,y_minor_tick_num; charString title,subtitle,xlabel,ylabel; plot_labels label_strings(1); double legend_xpos,legend_ypos; int Nchannels; Svector channel_match,channel_label; ifstream in; ofstream html_out; xy_curves goldstone; xy_curves comparison_curves(3); // ******************************************************************************** void plot_label::assign(const charString& label_string, double xloc, double yloc) { label=label_string; label_xloc=xloc; label_yloc=yloc; } // ********************************************************************* plot_labels::plot_labels() {n=0;} plot_labels::plot_labels(int dim) {n=dim; if (dim<1){ cerr << "negative or zero dimension in plot_labels"<0){ m=new plot_label[n]; if (!m){ cerr << " problem allocating memory"<0) delete [] ++m;} void plot_labels::assign(int index, const charString& label_string, double xloc, double yloc) { if ((index>=1)&&(index<=n)){ m[index].assign(label_string,xloc,yloc); } else{ cerr << " bad index; no assignment made in plot_labels"<0) delete [] ++m; n=dim; if (n>0){ m=new plot_label[n]; if (!m){ cerr << " problem allocating memory"<=1)&&(i<=n)) ? m[i] : (cerr << "plot_labels out of bounds"<next=NULL; head->R_value=R; head->Rinv_value=Rinv; head->Rerr_value=Rerr; head->Rinverr_value=Rinverr; head->mean_value=ans; head->stdev_value=err; tail=head; } else{ tail->next=new node; tail=tail->next; tail->R_value=R; tail->Rinv_value=Rinv; tail->Rerr_value=Rerr; tail->Rinverr_value=Rinverr; tail->mean_value=ans; tail->stdev_value=err; tail->next=NULL; } } void delete_nodes() { if (head==NULL) return; node *pnode=head; node *pnext=head->next; while (pnext != NULL){ delete pnode; pnode=pnext; pnext=pnext->next; } head=NULL; tail=NULL; } // **************************************************************** // Rplot_type: 1 => x-axis is R, 0 => x-axis is 1/R int plot_curve::setup_from_file( const charString& datafile, const charString& channel_string, int Rplot_type, int type_of_line, int color_of_line, int thickness_of_line, int type_of_symbol, int color_of_symbol, int fill_of_symbol, double size_of_symbol, const charString& label_string) { const int maxlinelength=132; static char ff[maxlinelength]; Svector tokens; int flag; double Rvalue,Rerrvalue,Rinvvalue,Rinverrvalue,ans,err; ifstream in(convert_to_charstar(datafile)); if (!in){ cerr << " could not open data file"; in.close(); return 1;} flag=Npoints=0; // first, search sequentially through file to find start // of relevant channel while (!flag){ in.getline(ff,maxlinelength); get_tokens(ff,tokens); if (tokens.dim()==11){ if (tokens(9).locate(channel_string)>=0) flag=1; } if (in.eof()){ cerr << " could not find requested channel"<mean_value; dyvals(flag)=pnode->stdev_value; if (Rplot_type){ xvals(flag)=pnode->R_value; dxvals(flag)=pnode->Rerr_value;} else{ xvals(flag)=pnode->Rinv_value; dxvals(flag)=pnode->Rinverr_value;} pnode=pnode->next; } delete_nodes(); in.close(); line_color=color_of_line; line_type=type_of_line; line_thickness=thickness_of_line; symbol_type=type_of_symbol; symbol_color=color_of_symbol; symbol_fill=fill_of_symbol; symbol_size=size_of_symbol; label=label_string; return 0; } void plot_curve::wipeout() { Npoints=0; xvals(); dxvals(); yvals(); dyvals(); label=""; } // ****************************************************************** plot_curves::plot_curves() {n=0;} plot_curves::plot_curves(int dim) {n=dim; if (dim<1){ cerr << "negative or zero dimension in plot_curves"<0){ m=new plot_curve[n]; if (!m){ cerr << " problem allocating memory"<0) delete [] ++m;} int plot_curves::setup_from_file( int index, const charString& datafile, const charString& channel_string, int Rplot_type, int type_of_line, int color_of_line, int thickness_of_line, int type_of_symbol, int color_of_symbol, int fill_of_symbol, double size_of_symbol, const charString& label_string) { if ((index>=1)&&(index<=n)){ return m[index].setup_from_file(datafile,channel_string,Rplot_type, type_of_line,color_of_line, thickness_of_line,type_of_symbol, color_of_symbol,fill_of_symbol, size_of_symbol,label_string); } else{ cerr << " bad index; no assignment made in plot_curves"<0) delete [] ++m; n=dim; if (n>0){ m=new plot_curve[n]; if (!m){ cerr << " problem allocating memory"<=1)&&(i<=n)) ? m[i] : (cerr << "plot_curves out of bounds"<0){ m=new xy_curve[n]; if (!m){ cerr << " problem allocating memory"<0) delete [] ++m;} void xy_curves::setup(int index, int number_of_points, double *xvalues, double *yvalues, int type_of_line, int color_of_line, int thickness_of_line, int type_of_symbol, int color_of_symbol, int fill_of_symbol, double size_of_symbol) { if ((index>=1)&&(index<=n)){ m[index].setup(number_of_points,xvalues,yvalues, type_of_line,color_of_line, thickness_of_line,type_of_symbol, color_of_symbol,fill_of_symbol, size_of_symbol); } else{ cerr << " bad index; no assignment made in xy_curves"<=1)&&(index<=n)){ m[index].setup(number_of_points,xvalues,yvalues, type_of_line,color_of_line, thickness_of_line,type_of_symbol, color_of_symbol,fill_of_symbol, size_of_symbol,label_string); } else{ cerr << " bad index; no assignment made in xy_curves"<0) delete [] ++m; n=dim; if (n>0){ m=new xy_curve[n]; if (!m){ cerr << " problem allocating memory"<=1)&&(i<=n)) ? m[i] : (cerr << "xy_curves out of bounds"<0){ str="@ s"+int_to_string(i)+" "; out << str << "on"<0) out << str << "legend \""<rr) rr=xmin; step=(xmax-rr)/Ngold_points; for (j=0;j=xmin)&&(r<=xmax)){ r=levels(i).yvals(j); if (r>ymax) ymax=r; if (r=0){ str=str.right_relax_substring('/');} str=str+".gif"; html_out << "



" <"<"< Plots"<"<"<"<"<"<"<"<"<"<

"<"<

"<"<"<"<"<"<"<=xmin)&&(r<=xmax)){ r=levels(i).yvals(j); if (r>ymax) ymax=r; if (r=0){ str=str.right_relax_substring('/');} str=str+".gif"; html_out << "



" <