mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-04-10 19:20:44 +01: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_;
|
return command_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string & PlotObject::getHeadCommand(void) const
|
||||||
|
{
|
||||||
|
return headCommand_;
|
||||||
|
}
|
||||||
|
|
||||||
void PlotObject::setCommand(const string &command)
|
void PlotObject::setCommand(const string &command)
|
||||||
{
|
{
|
||||||
command_ = command;
|
command_ = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlotObject::setHeadCommand(const string &command)
|
||||||
|
{
|
||||||
|
headCommand_ = command;
|
||||||
|
}
|
||||||
|
|
||||||
string PlotObject::popTmpFile(void)
|
string PlotObject::popTmpFile(void)
|
||||||
{
|
{
|
||||||
string res = tmpFileName_.top();
|
string res = tmpFileName_.top();
|
||||||
@ -95,6 +105,12 @@ PlotCommand::PlotCommand(const string &command)
|
|||||||
setCommand(command);
|
setCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PlotHeadCommand constructor /////////////////////////////////////////////////
|
||||||
|
PlotHeadCommand::PlotHeadCommand(const string &command)
|
||||||
|
{
|
||||||
|
setHeadCommand(command);
|
||||||
|
}
|
||||||
|
|
||||||
// PlotData constructor ////////////////////////////////////////////////////////
|
// PlotData constructor ////////////////////////////////////////////////////////
|
||||||
PlotData::PlotData(const XYStatData &data, const Index i, const Index j)
|
PlotData::PlotData(const XYStatData &data, const Index i, const Index j)
|
||||||
{
|
{
|
||||||
@ -311,21 +327,28 @@ Plot & Plot::operator<<(PlotObject &&command)
|
|||||||
commandStr += "'" + tmpFileName_.back() + "' ";
|
commandStr += "'" + tmpFileName_.back() + "' ";
|
||||||
}
|
}
|
||||||
commandStr = command.getCommand();
|
commandStr = command.getCommand();
|
||||||
if (!options_.lineColor.empty())
|
if (!commandStr.empty())
|
||||||
{
|
{
|
||||||
commandStr += " lc " + options_.lineColor;
|
if (!options_.lineColor.empty())
|
||||||
options_.lineColor = "";
|
{
|
||||||
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
|
12
lib/Plot.hpp
12
lib/Plot.hpp
@ -48,17 +48,20 @@ public:
|
|||||||
// access
|
// access
|
||||||
std::string popTmpFile(void);
|
std::string popTmpFile(void);
|
||||||
const std::string & getCommand(void) const;
|
const std::string & getCommand(void) const;
|
||||||
|
const std::string & getHeadCommand(void) const;
|
||||||
// test
|
// test
|
||||||
bool gotTmpFile(void) const;
|
bool gotTmpFile(void) const;
|
||||||
protected:
|
protected:
|
||||||
// access
|
// access
|
||||||
void pushTmpFile(const std::string &fileName);
|
void pushTmpFile(const std::string &fileName);
|
||||||
void setCommand(const std::string &command);
|
void setCommand(const std::string &command);
|
||||||
|
void setHeadCommand(const std::string &command);
|
||||||
// dump a matrix to a temporary file
|
// dump a matrix to a temporary file
|
||||||
std::string dumpToTmpFile(const DMat &m);
|
std::string dumpToTmpFile(const DMat &m);
|
||||||
private:
|
private:
|
||||||
// plot command
|
// plot command
|
||||||
std::string command_;
|
std::string command_;
|
||||||
|
std::string headCommand_;
|
||||||
// stack of created temporary files
|
// stack of created temporary files
|
||||||
std::stack<std::string> tmpFileName_;
|
std::stack<std::string> tmpFileName_;
|
||||||
};
|
};
|
||||||
@ -72,6 +75,15 @@ public:
|
|||||||
virtual ~PlotCommand(void) = default;
|
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
|
class PlotData: public PlotObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user