mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 08:55:37 +00:00
Plot: head command object
This commit is contained in:
parent
897dae5b2f
commit
1f21f7fb81
45
lib/Plot.cpp
45
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;
|
||||
}
|
||||
|
12
lib/Plot.hpp
12
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<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:
|
||||
|
Loading…
Reference in New Issue
Block a user