diff --git a/pub/lib/plot.cpp b/pub/lib/plot.cpp index 1d6d7339c272f2fba94a554003ddaf5d03980a29..637ad4ab9e72be77914414a7c289c701b652ef8a 100644 --- a/pub/lib/plot.cpp +++ b/pub/lib/plot.cpp @@ -470,7 +470,7 @@ namespace { if (!add) { plot->start_frame1D("Frida version " VERSION, xCo.str_ps(), yCo.str_ps()); } else - plot->reopen_frame1D(xCo.str_ps(), yCo.str_ps()); + plot->reopen_frame1D("Frida version " VERSION, xCo.str_ps(), yCo.str_ps()); // Plot slices. fiter.reset(); diff --git a/pub/plot/dualplot.cpp b/pub/plot/dualplot.cpp index f31eafa881eb10a89ab5fa6611784306e660513b..ae7f057d66f061fb384079eb3fcb7688e0d04a9b 100644 --- a/pub/plot/dualplot.cpp +++ b/pub/plot/dualplot.cpp @@ -118,17 +118,18 @@ void CPlot::set_aux(const string& cmd) void CPlot::start_frame1D(const string& caller, const string& xlabel, const string& ylabel) { gnuPlotter->start_frame(X, Y); - ps_Plotter->start_frame1D(caller, X, Y, xlabel, ylabel); + ps_Plotter->start_frame1D(caller, X, Y); + ps_Plotter->set_labels(xlabel, ylabel); open1D = true; } //! Start adding to plot. -void CPlot::reopen_frame1D(const string& /*xlabel*/, const string& /*ylabel*/) +void CPlot::reopen_frame1D(const string& caller, const string& xlabel, const string& ylabel) { - // TODO: react to modified labels if (!open1D) throw S("plot frame is not open for adding"); + ps_Plotter->set_labels(xlabel, ylabel); } //! Clear 2D plot canvas, and print coordinate ranges diff --git a/pub/plot/dualplot.hpp b/pub/plot/dualplot.hpp index b549d815da06b60d60a5db708143788df3915248..4c0729a390c8fe8ae7b79d85d2ebb18ca82a4a1a 100644 --- a/pub/plot/dualplot.hpp +++ b/pub/plot/dualplot.hpp @@ -40,7 +40,8 @@ public: void gp_write(const std::string& in); void start_frame1D( const std::string& caller, const std::string& xlabel, const std::string& ylabel); - void reopen_frame1D(const std::string& xlabel, const std::string& ylabel); + void reopen_frame1D( + const std::string& caller, const std::string& xlabel, const std::string& ylabel); void start_frame2D(const std::string& caller); void close_frame2D( const std::string& xlabel, const std::string& zlabel, const std::string& ylabel); diff --git a/pub/plot/ps_plotter.cpp b/pub/plot/ps_plotter.cpp index 1e63ea0ecd605644059d2aa233a7ec95f7820d92..ba3892a00bfafc49eaf89f3fbbb9535f646c64f8 100644 --- a/pub/plot/ps_plotter.cpp +++ b/pub/plot/ps_plotter.cpp @@ -39,34 +39,32 @@ namespace { const string& fname, const string& doc_lines); } -void CPS_Plotter::start_frame1D( - const string& caller, const CAxis& _X, const CAxis& _Y, - const string& xlabel, const string& ylabel) +void CPS_Plotter::start_frame1D(const string& _caller, const CAxis& _X, const CAxis& _Y) { p2D = false; + caller = _caller; X = &_X; Y = &_Y; ps_snum = 0; ps_Doc = ""; - ps_accu = "\n%% output created by " + caller + "\n\n"; - ps_accu += ps_coord(X); - ps_accu += ps_coord(Y); - ps_accu += "\n"; - ps_accu += ps_axis(X) + ps_horiz(xlabel); - ps_accu += ps_axis(Y) + ps_verti(ylabel); - ps_accu += "\n"; +} + +void CPS_Plotter::set_labels(const std::string& _xlabel, const std::string& _ylabel) +{ + xlabel = _xlabel; + ylabel = _ylabel; } void CPS_Plotter::start_frame2D( - const std::string& caller, const CAxis& _X, const CAxis& _Z, const CAxis& _Y) + const std::string& _caller, const CAxis& _X, const CAxis& _Z, const CAxis& _Y) { p2D = true; + caller = _caller; X = &_X; Z = &_Z; Y = &_Y; ps_snum = 0; ps_Doc = ""; - ps_accu = "\n%% output created by " + caller + "\n\n"; ps_accu += ps_coord(X); ps_accu += ps_coord(Z); ps_accu += ps_coord(Y); @@ -144,6 +142,15 @@ void CPS_Plotter::write_data(const string& fname) if (!triv::file_exists(fname)) throw "BUG: after copying headers, graphic output file " + fname + " still doesn't exist"; std::fstream fs(fname, std::fstream::out | std::fstream::app); + fs << "\n%% output created by " << caller << "\n\n"; + if (!p2D) { + fs << ps_coord(X); + fs << ps_coord(Y); + fs << "\n"; + fs << ps_axis(X) + ps_horiz(xlabel); + fs << ps_axis(Y) + ps_verti(ylabel); + fs << "\n"; + } fs << ps_accu; fs << ps_footer(fname, ps_Doc); fs.close(); diff --git a/pub/plot/ps_plotter.hpp b/pub/plot/ps_plotter.hpp index edc39be074064a123d01d459ee919fbc58bb92a2..d874f1b892a45f495fc806fa9699a77e1b99d5dc 100644 --- a/pub/plot/ps_plotter.hpp +++ b/pub/plot/ps_plotter.hpp @@ -18,9 +18,8 @@ public: CPS_Plotter() {} CPS_Plotter(CPS_Plotter const&) = delete; CPS_Plotter& operator=(CPS_Plotter const&) = delete; - void start_frame1D( - const std::string& caller, const CAxis& _X, const CAxis& _Y, - const std::string& xlabel, const std::string& ylabel); + void start_frame1D(const std::string& caller, const CAxis& _X, const CAxis& _Y); + void set_labels(const std::string& _xlabel, const std::string& _ylabel); void start_frame2D( const std::string& caller, const CAxis& _X, const CAxis& _Z, const CAxis& _Y); void close_frame2D( @@ -43,6 +42,8 @@ private: const CAxis* Y; const CAxis* Z; int ps_snum; //!< Slice number in Postscript file. + std::string caller; + std::string xlabel, ylabel; std::string ps_accu; //!< Main Postscript cache. std::string ps_Doc; //!< Special Postscript cache for doc lines ?. };