#ifndef _PLOTTING_H #define _PLOTTING_H #include "arrays.h" #include "charString.h" #include #include using namespace std; // convenient constants const int su3=1; const int su2=2; const int u1=3; const int none=0; const int solid_fill=1; const int no_symbol=0; const int circle=1; const int square=2; const int diamond=3; const int triangle_up=4; const int triangle_left=5; const int triangle_down=6; const int triangle_right=7; const int plus_sign=8; const int cross_sign=9; const int star_sign=10; const int char_sign=11; const int white=0; const int black=1; const int red=2; const int green=3; const int blue=4; const int yellow=5; const int brown=6; const int grey=7; const int violet=8; const int cyan=9; const int magenta=10; const int orange=11; const int indigo=12; const int maroon=13; const int turquoise=14; const int green4=15; const int no_line=0; const int solid_line=1; const int dotted_line=2; const int dashed_line=3; const int long_dashed_line=4; const int dot_dashed_line=5; const int dot_long_dashed_line=6; const int dot_dot_dashed_line=7; const int dash_dash_dotted_line=8; // ************************************************************ #define WEBPAGE // ************************************************************* // Class containing a string and a location (in frame coordinates) // to put on a plot. The horizontal and vertical frame coordinates // vary between 0 and 1. class plot_label { public: charString label; double label_xloc, label_yloc; // frame coordinates plot_label(){} ~plot_label(){} void assign(const charString& label_string, double xloc, double yloc); }; // An array of plot_label variables. Indices are checked. class plot_labels { protected: plot_label *m; int n; public: plot_labels(); plot_labels(int dim); plot_labels(const plot_labels &pvec); ~plot_labels(); void assign(int index, const charString& label_string, double xloc, double yloc); int dim() const; void reset(int dim); plot_label& operator()(int i) const; }; // ******************************************************************* // This class contains a given curve to plot consisting // of data points (x, y, y_err) and other self-explanatory // information. The location of the label is specified // as follows: // // HORIZONTAL SPECIFICATION // // xloc_of_label < 0 => left of smallest-x point // xloc_of_label > 1 => right of largest-x point // 0 < xloc_of_label < 1 => fractional distance between // smallest and largest x-values // // VERTICAL SPECIFICATION // // yloc_of_label > 0 => above the curve // yloc_of_label = 0 => on the curve // yloc_of_label < 0 => below the curve // class xydy_curve { public: int Npoints; dvector xvals,yvals,dyvals; int line_color,line_type,line_thickness; int symbol_type,symbol_color,symbol_fill; double symbol_size; charString label; double horizontal_label_loc; int vertical_label_loc; xydy_curve(){} ~xydy_curve(){} int setup_from_stream(ifstream& in, 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, double xloc_of_label, int yloc_of_label ); void setup(int number_of_points, double *xvalues, double *yvalues, double *dyvalues, 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, double xloc_of_label, int yloc_of_label); void wipeout(); }; // An array of xydy_curve objects. class xydy_curves { protected: xydy_curve *m; int n; public: xydy_curves(); xydy_curves(int dim); xydy_curves(const xydy_curves &pvec); ~xydy_curves(); int setup_from_stream(int index, ifstream& in, 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, double xloc_of_label, int yloc_of_label ); void setup(int index, int number_of_points, double *xvalues, double *yvalues, double *dyvalues, 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, double xloc_of_label, int yloc_of_label); int dim() const; void reset(int dim); xydy_curve& operator()(int i) const; }; // ******************************************************************* // This class contains a given curve to plot consisting // of data points (x, y) and other self-explanatory // information. class xy_curve { public: int Npoints; dvector xvals,yvals; int line_color,line_type,line_thickness; int symbol_type,symbol_color,symbol_fill; double symbol_size; charString label; double horizontal_label_loc; int vertical_label_loc; xy_curve(){} ~xy_curve(){} void setup(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, const charString& label_string, double xloc_of_label, int yloc_of_label); void wipeout(); }; // An array of xy_curve objects. class xy_curves { protected: xy_curve *m; int n; public: xy_curves(); xy_curves(int dim); xy_curves(const xy_curves &pvec); ~xy_curves(); void 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, const charString& label_string, double xloc_of_label, int yloc_of_label); int dim() const; void reset(int dim); xy_curve& operator()(int i) const; }; // ******************************************************************* // This routine produces an "xmgrace" plot file. // Output is sent to the file "filename" which can then be // viewed using "xmgrace". The parameters are hopefully // self-explanatory. void produce_plot(const charString& filename, const charString& title, const charString& subtitle, const charString& xlabel, const charString& ylabel, double xmin, double xmax, double ymin, double ymax, double x_major_tick_spacing, int x_minor_tick_num, double y_major_tick_spacing, int y_minor_tick_num, const xydy_curves& xydy_results, const xy_curves& xy_curves_to_plot, const plot_labels& label_strings); void produce_plot(const charString& filename, const charString& title, const charString& subtitle, const charString& xlabel, const charString& ylabel, double xmin, double xmax, double ymin, double ymax, double x_major_tick_spacing, int x_minor_tick_num, double y_major_tick_spacing, int y_minor_tick_num, const xydy_curves& xydy_results, const plot_labels& label_strings); void produce_plot(const charString& filename, const charString& title, const charString& subtitle, const charString& xlabel, const charString& ylabel, double xmin, double xmax, double ymin, double ymax, double x_major_tick_spacing, int x_minor_tick_num, double y_major_tick_spacing, int y_minor_tick_num, const xy_curves& xy_curves_to_plot, const plot_labels& label_strings); // ****************************************************************** void setup_goldstone(int Rplot_type, double xmin, double xmax, double xi, double Zxi); void pump_out_plot(const charString& outfile, int level1, double label1_xloc, int label1_yloc); void pump_out_plot(const charString& outfile, int level1, double label1_xloc, int label1_yloc, int level2, double label2_xloc, int label2_yloc, int missing_curve_flag); void pump_out_plot(const charString& outfile, int level1, double label1_xloc, int label1_yloc, int level2, double label2_xloc, int label2_yloc, int level3, double label3_xloc, int label3_yloc, int missing_curve_flag); void pump_out_plot(const charString& outfile, int level1, double label1_xloc, int label1_yloc, int level2, double label2_xloc, int label2_yloc, int level3, double label3_xloc, int label3_yloc, int level4, double label4_xloc, int label4_yloc, int missing_curve_flag); void html_header(const charString filename, const charString& up_filename); void html_footer(const charString& up_filename); void pump_out_string_plot(const charString& outfile, int level1, double label1_xloc, int label1_yloc, int string_level, double xi, double Zxi, double Zxi_err); // ********************************************************************************* // useful global variables extern int line_thickness,Rplot_type; extern double xmin,xmax,ymin,ymax; extern double x_major_tick_spacing,y_major_tick_spacing; extern int x_minor_tick_num,y_minor_tick_num; extern charString title,subtitle,xlabel,ylabel; extern plot_labels label_strings; extern int Nchannels; extern Svector channel_match,channel_label; extern ifstream in; extern ofstream html_out; // **************************************************************************** #endif