Skip to content
Snippets Groups Projects
Commit c089874c authored by Thomas Fetzer's avatar Thomas Fetzer
Browse files

[gnuplotinterface] Outsource closing and opening of gnuplot

parent 42500688
No related branches found
No related tags found
1 merge request!234Feature/improveplotmateriallaws
...@@ -72,17 +72,13 @@ public: ...@@ -72,17 +72,13 @@ public:
datafileSeparator_(' '), datafileSeparator_(' '),
gnuplotPath_(GNUPLOT_EXECUTABLE) gnuplotPath_(GNUPLOT_EXECUTABLE)
{ {
if (persist) open(persist);
pipe_ = popen((gnuplotPath_ + " -persist").c_str(), "w"); // "w" - writing
else
pipe_ = popen((gnuplotPath_).c_str(), "w");
} }
//! \brief The destructor //! \brief The destructor
~GnuplotInterface() ~GnuplotInterface()
{ {
if (pclose(pipe_) == -1) close();
assert("Could not close pipe to Gnuplot!");
} }
/*! /*!
...@@ -148,14 +144,36 @@ public: ...@@ -148,14 +144,36 @@ public:
/*! /*!
* \brief Deletes all plots from a plotting window and resets user-defined options * \brief Deletes all plots from a plotting window and resets user-defined options
*/ */
void reset() void reset(const bool persist = true)
{ {
close();
open(persist);
curveFile_.resize(0); curveFile_.resize(0);
curveOptions_.resize(0); curveOptions_.resize(0);
curveTitle_.resize(0); curveTitle_.resize(0);
plotOptions_ = ""; plotOptions_ = "";
} }
/*!
* \brief Closes gnuplot
*/
void open(const bool persist = true)
{
if (persist)
pipe_ = popen((gnuplotPath_ + " -persist").c_str(), "w"); // "w" - writing
else
pipe_ = popen((gnuplotPath_).c_str(), "w");
}
/*!
* \brief Closes gnuplot
*/
void close()
{
if (pclose(pipe_) == -1)
assert("Could not close pipe to Gnuplot!");
}
/*! /*!
* \brief Adds a function to list of plotted lines * \brief Adds a function to list of plotted lines
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment