1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-20 05:25:37 +01:00

Plot: head command object

This commit is contained in:
Antonin Portelli 2015-06-26 20:33:57 +01:00
parent 897dae5b2f
commit 1f21f7fb81
2 changed files with 46 additions and 11 deletions

View File

@ -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,6 +327,8 @@ Plot & Plot::operator<<(PlotObject &&command)
commandStr += "'" + tmpFileName_.back() + "' ";
}
commandStr = command.getCommand();
if (!commandStr.empty())
{
if (!options_.lineColor.empty())
{
commandStr += " lc " + options_.lineColor;
@ -326,6 +344,11 @@ Plot & Plot::operator<<(PlotObject &&command)
options_.title = "";
}
plotCommand_.push_back(commandStr);
}
if (!command.getHeadCommand().empty())
{
headCommand_.push_back(command.getHeadCommand());
}
return *this;
}

View File

@ -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<std::string> 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: