From 2359fa6d3cc1a84d16bbe1ee72e691187bf3b817 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Sat, 18 Mar 2017 16:13:36 +0100 Subject: [PATCH] more explicit filenames g4->setup1D.ps etc. --- pub/itest/{p2d.f2t => p2D.f2t} | 0 pub/lib/commands.cpp | 12 +++++------ pub/lib/plot.cpp | 7 +++---- pub/plot/dualplot.cpp | 4 ++-- pub/plot/dualplot.hpp | 2 +- pub/plot/ps_plotter.cpp | 16 +++++++------- pub/plot/ps_plotter.hpp | 2 +- pub/share/CMakeLists.txt | 9 +++++++- pub/share/{c4.ps => continuation.ps} | 0 pub/share/frida.ini.in | 7 +++---- pub/share/{g4.ps => setup1D.ps} | 2 +- pub/share/setup2D.ps | 31 ++++++++++++++++++++++++++++ pub/share/wups17a.ps | 9 ++++++++ 13 files changed, 73 insertions(+), 28 deletions(-) rename pub/itest/{p2d.f2t => p2D.f2t} (100%) rename pub/share/{c4.ps => continuation.ps} (100%) rename pub/share/{g4.ps => setup1D.ps} (95%) create mode 100644 pub/share/setup2D.ps diff --git a/pub/itest/p2d.f2t b/pub/itest/p2D.f2t similarity index 100% rename from pub/itest/p2d.f2t rename to pub/itest/p2D.f2t diff --git a/pub/lib/commands.cpp b/pub/lib/commands.cpp index 5d2284f3..87e5d40f 100644 --- a/pub/lib/commands.cpp +++ b/pub/lib/commands.cpp @@ -361,15 +361,15 @@ bool frida_command(string cmd) "Allow iterative refinement for curve plotting", SPloWin::instance()->current()->refine); } else if (cmd == "gp" || cmd == "gf" || cmd == "gfa") { - const string ps_head = CNode::eval("pshead")->to_s(); - const string ps_cont = CNode::eval("pscont")->to_s(); - const string ps_dict = (cmd == "gp") ? CNode::eval("psdict")->to_s() : ""; - const string ext = string(".") + (ps_dict == "" ? "psa" : "ps"); + const string ps_setup_dir = CNode::eval("ps_setup_dir")->to_s(); + const string ps_definitions = (cmd == "gp") ? CNode::eval("ps_definitions")->to_s() : ""; + const string ext = string(".") + (ps_definitions == "" ? "psa" : "ps"); static string fname = ""; string mode; if (cmd != "gfa") { fs::path defaultname = triv::next_tmp_file( - CNode::eval("psdir")->to_s() + (ps_dict == "" ? "l" : "L") + "%i" + ext); + CNode::eval("ps_output_dir")->to_s() + (ps_definitions == "" ? "l" : "L") + "%i" + + ext); defaultname.replace_extension(""); fname = sask("Graphic file name (without extension "+ext+")", defaultname.string()); if (fname=="") @@ -383,7 +383,7 @@ bool frida_command(string cmd) } if (fname != "") SPloWin::instance()->current()->write_postscript( - mode, triv::wordexp_unique(fname), ps_head, ps_cont, ps_dict); + mode, triv::wordexp_unique(fname), ps_setup_dir, ps_definitions); } else if (cmd == "gw") { SPloWin::instance()->display_list(); } else if (sscanf(cmd.c_str(), "g%i", &i) == 1) { diff --git a/pub/lib/plot.cpp b/pub/lib/plot.cpp index a6bd6d27..2d2e5055 100644 --- a/pub/lib/plot.cpp +++ b/pub/lib/plot.cpp @@ -554,12 +554,11 @@ namespace { for (int i = 0; i < fd->lDoc.size(); i++) plot->doc_TxLine(" " + fd->lDoc[i]); // plot -> file - const string ps_head = CNode::eval("pshead")->to_s(); - const string ps_cont = CNode::eval("pscont")->to_s(); - const string ps_dict = CNode::eval("psdict")->to_s(); + const string ps_setup_dir = CNode::eval("ps_setup_dir")->to_s(); + const string ps_definitions = CNode::eval("ps_definitions")->to_s(); static string fname = "~/P.ps"; plot->write_postscript( - "overwrite", triv::wordexp_unique(fname), ps_head, ps_cont, ps_dict); + "overwrite", triv::wordexp_unique(fname), ps_setup_dir, ps_definitions); } } // anonymous namespace diff --git a/pub/plot/dualplot.cpp b/pub/plot/dualplot.cpp index dc9b9889..b0620251 100644 --- a/pub/plot/dualplot.cpp +++ b/pub/plot/dualplot.cpp @@ -178,9 +178,9 @@ void CPlot::doc_CvTxLine(const string& line, int num) void CPlot::write_postscript( const string& mode, const string& fname, - const string& ps_head, const string& ps_cont, const string& ps_dict) + const string& ps_setup_dir, const string& ps_definitions) { - ps_Plotter->copy_header(mode, fname, ps_head, ps_cont, ps_dict); + ps_Plotter->copy_header(mode, fname, ps_setup_dir, ps_definitions); ps_Plotter->write_data(fname); } diff --git a/pub/plot/dualplot.hpp b/pub/plot/dualplot.hpp index e2bb3d6a..9e8ccf8a 100644 --- a/pub/plot/dualplot.hpp +++ b/pub/plot/dualplot.hpp @@ -51,7 +51,7 @@ public: void doc_CvTxLine(const std::string& line, int num); void write_postscript( const std::string& mode, const std::string& fname, - const std::string& ps_head, const std::string& ps_cont, const std::string& ps_dict); + const std::string& ps_setup_dir, const std::string& ps_definitions); void set_aux(const std::string& cmd); std::string info() const; diff --git a/pub/plot/ps_plotter.cpp b/pub/plot/ps_plotter.cpp index 6c9730db..67771482 100644 --- a/pub/plot/ps_plotter.cpp +++ b/pub/plot/ps_plotter.cpp @@ -82,7 +82,6 @@ void CPS_Plotter::close_frame2D( ps_accu += ps_axis(X, xlabel, 'x') + ps_horiz(); ps_accu += ps_axis(Z, zlabel, 'y') + ps_verti(); ps_accu += ps_axis(Y, ylabel, 'h') + ps_colorscale(); - ps_accu += "\n"; } void CPS_Plotter::add_spec( @@ -113,23 +112,25 @@ void CPS_Plotter::doc_line(const string& line) void CPS_Plotter::copy_header( const string& mode, const string& fname, - const string& ps_head, const string& ps_cont, const string& ps_dict) + const string& ps_setup_dir, const string& ps_definitions) { // copy headers to output file string cmd; if (mode=="append") { if (!triv::file_exists(fname)) throw "Cannot append graphic: file " + fname + " not found"; - cmd = "cat " + ps_cont + " >> " + fname; + cmd = "cat " + ps_setup_dir + "continuation.ps >> " + fname; } else { if (mode=="create") { if (triv::file_exists(fname)) throw "File " + fname + " already exists. Use " - + (ps_dict=="" ? "gf!" : "gp!") + " to overwrite"; + + (ps_definitions=="" ? "gf!" : "gp!") + " to overwrite"; } else if (mode=="overwrite") { } else throw "BUG: unexpected mode"; - cmd = "cat " + ps_dict + " " + ps_head + " > " + fname; + string setup_file = ps_setup_dir + "setup" + (p2D ? "2" : "1") + "D.ps"; + string def_file = ps_definitions=="" ? "" : (ps_setup_dir + ps_definitions); + cmd = "cat " + def_file + " " + setup_file + " > " + fname; } triv::system(cmd); } @@ -221,8 +222,7 @@ namespace { string ps_colorscale() { return - "/hxlow 11.3 def\n" - "/hxhig 12.3 def\n" + "ColorLegend\n" " hxlow hxhig 0 0 0 90 OneAxx Axx %% low x line\n" " hxlow hxhig 0 10 0 90 OneAxx Axx %% low x line\n" " 0 10 hxlow 0 90 0 OneAxx Tic Tac Axx %% left y axis\n" @@ -266,7 +266,7 @@ namespace { string ps_footer(const string& fname, const string& doc_lines) { - return "\n{ black 0 -3 13 1.65 NewList\n" + return "{ black 0 -3 13 1.65 NewList\n" + doc_lines + " {(plot -> " + fname + ")} TxLine\n" + "} oooinfo 1 eq { exec } { pop } ifelse\n\n" diff --git a/pub/plot/ps_plotter.hpp b/pub/plot/ps_plotter.hpp index 82bbeea7..84f15581 100644 --- a/pub/plot/ps_plotter.hpp +++ b/pub/plot/ps_plotter.hpp @@ -34,7 +34,7 @@ public: void doc_line(const std::string& line); void copy_header( const std::string& mode, const std::string& fname, - const std::string& ps_head, const std::string& ps_cont, const std::string& ps_dict); + const std::string& ps_setup_dir, const std::string& ps_definitions); void write_data(const std::string& fname); private: bool p2D; diff --git a/pub/share/CMakeLists.txt b/pub/share/CMakeLists.txt index aa2f286f..6868d357 100644 --- a/pub/share/CMakeLists.txt +++ b/pub/share/CMakeLists.txt @@ -1,3 +1,10 @@ configure_file(frida.ini.in frida.ini) -set(share_files ${CMAKE_CURRENT_BINARY_DIR}/frida.ini g4.ps c4.ps wups17a.ps gnuplot-default-symbols.eps) +set(share_files + ${CMAKE_CURRENT_BINARY_DIR}/frida.ini + wups17a.ps + setup1D.ps + setup2D.ps + continuation.ps + gnuplot-default-symbols.eps + ) install(FILES ${share_files} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/frida) diff --git a/pub/share/c4.ps b/pub/share/continuation.ps similarity index 100% rename from pub/share/c4.ps rename to pub/share/continuation.ps diff --git a/pub/share/frida.ini.in b/pub/share/frida.ini.in index ba5fbb00..a2be5e7d 100644 --- a/pub/share/frida.ini.in +++ b/pub/share/frida.ini.in @@ -1,8 +1,7 @@ pop($silent=1) -psdir="~/gnew/" -pshead="${CMAKE_INSTALL_PREFIX}/share/frida/g4.ps" -pscont="${CMAKE_INSTALL_PREFIX}/share/frida/c4.ps" -psdict="${CMAKE_INSTALL_PREFIX}/share/frida/wups17a.ps" +ps_output_dir="~/gnew/" +ps_setup_dir="${CMAKE_INSTALL_PREFIX}/share/frida/" +ps_definitions="wups17a.ps" psgsym="${CMAKE_INSTALL_PREFIX}/share/frida/gnuplot-default-symbols.eps" FK01="pv" FK02="pn" diff --git a/pub/share/g4.ps b/pub/share/setup1D.ps similarity index 95% rename from pub/share/g4.ps rename to pub/share/setup1D.ps index 75460440..03429028 100644 --- a/pub/share/g4.ps +++ b/pub/share/setup1D.ps @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Customizable plot setup, copied from g3.ps (editör: use latin-1) +%% Customizable plot setup, copied from g4.ps (editör: use latin-1) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% WuGdict17a begin diff --git a/pub/share/setup2D.ps b/pub/share/setup2D.ps new file mode 100644 index 00000000..333cc6e6 --- /dev/null +++ b/pub/share/setup2D.ps @@ -0,0 +1,31 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Customizable plot setup, copied from g4.ps (editör: use latin-1) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +WuGdict17a begin + +10 dup autolabel defsiz +1 dup geld stdred +2 -11 setnewpage newpage + +2 4 13 -14 setpagegrid +2 8 24 abcset % usage: {(text)} abc +/EndFrame { nextFrame end } def + +1 1 language +1 infSet % plot info block? +1 dup 2 SymGSet % srad slin serr(2=from pset) : graph symbols, global preset +% /setboxbackgroundcolor { 0.93 setgray } def % default is white +% setPalatino + +{ 10 aCol2 iColA } /icCol x bind def % number of colours and colour style + +/hxlow 11.3 def +/hxhig 12.3 def + +Resets +BoxBackground + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% Mark "ecu", end of the customization section +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/pub/share/wups17a.ps b/pub/share/wups17a.ps index 33c7adc3..d77cc9d9 100644 --- a/pub/share/wups17a.ps +++ b/pub/share/wups17a.ps @@ -1237,6 +1237,15 @@ WuGdict17a begin black } def +/ColorLegend { % - | - [plot color legend to rectangle hxlow hxhig 0 10] + /eps .05 def + eps eps 10.001 { + dup icCol + dup eps sub x + hxlow hxhig 4 2 roll rect fill + } for + } def + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% List %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- GitLab