diff --git a/lib/Plot.cpp b/lib/Plot.cpp index 24e0a2a..7191bae 100644 --- a/lib/Plot.cpp +++ b/lib/Plot.cpp @@ -33,11 +33,21 @@ const string & PlotObject::getCommand(void) const return command_; } +const string & PlotObject::getHeadCommand(void) const +{ + return headCommand_; +} + void PlotObject::setCommand(const string &command) { command_ = command; } +void PlotObject::setHeadCommand(const string &command) +{ + headCommand_ = command; +} + string PlotObject::popTmpFile(void) { string res = tmpFileName_.top(); @@ -95,6 +105,12 @@ PlotCommand::PlotCommand(const string &command) setCommand(command); } +// PlotHeadCommand constructor ///////////////////////////////////////////////// +PlotHeadCommand::PlotHeadCommand(const string &command) +{ + setHeadCommand(command); +} + // PlotData constructor //////////////////////////////////////////////////////// PlotData::PlotData(const XYStatData &data, const Index i, const Index j) { @@ -311,21 +327,28 @@ Plot & Plot::operator<<(PlotObject &&command) commandStr += "'" + tmpFileName_.back() + "' "; } commandStr = command.getCommand(); - if (!options_.lineColor.empty()) + if (!commandStr.empty()) { - commandStr += " lc " + options_.lineColor; - options_.lineColor = ""; + if (!options_.lineColor.empty()) + { + commandStr += " lc " + options_.lineColor; + options_.lineColor = ""; + } + if (options_.title.empty()) + { + commandStr += " notitle"; + } + else + { + commandStr += " t '" + options_.title + "'"; + options_.title = ""; + } + plotCommand_.push_back(commandStr); } - if (options_.title.empty()) + if (!command.getHeadCommand().empty()) { - commandStr += " notitle"; + headCommand_.push_back(command.getHeadCommand()); } - else - { - commandStr += " t '" + options_.title + "'"; - options_.title = ""; - } - plotCommand_.push_back(commandStr); return *this; } diff --git a/lib/Plot.hpp b/lib/Plot.hpp index 51ae41d..f4b44f1 100644 --- a/lib/Plot.hpp +++ b/lib/Plot.hpp @@ -48,17 +48,20 @@ public: // access std::string popTmpFile(void); const std::string & getCommand(void) const; + const std::string & getHeadCommand(void) const; // test bool gotTmpFile(void) const; protected: // access void pushTmpFile(const std::string &fileName); void setCommand(const std::string &command); + void setHeadCommand(const std::string &command); // dump a matrix to a temporary file std::string dumpToTmpFile(const DMat &m); private: // plot command std::string command_; + std::string headCommand_; // stack of created temporary files std::stack tmpFileName_; }; @@ -72,6 +75,15 @@ public: virtual ~PlotCommand(void) = default; }; +class PlotHeadCommand: public PlotObject +{ +public: + // constructor + explicit PlotHeadCommand(const std::string &command); + // destructor + virtual ~PlotHeadCommand(void) = default; +}; + class PlotData: public PlotObject { public: