mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 08:55:37 +00:00
Plot: caption modifier
This commit is contained in:
parent
78372fb18a
commit
a29a4bde21
20
lib/Plot.cpp
20
lib/Plot.cpp
@ -162,6 +162,17 @@ PlotPredBand::PlotPredBand(const DoubleFunctionSample &function,
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Plot modifiers *
|
* Plot modifiers *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
// Caption constructor /////////////////////////////////////////////////////////
|
||||||
|
Caption::Caption(const string &caption)
|
||||||
|
: caption_(caption)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Caption modifier ////////////////////////////////////////////////////////////
|
||||||
|
void Caption::operator()(PlotOptions &option) const
|
||||||
|
{
|
||||||
|
option.caption = caption_;
|
||||||
|
}
|
||||||
|
|
||||||
// Color constructor ///////////////////////////////////////////////////////////
|
// Color constructor ///////////////////////////////////////////////////////////
|
||||||
Color::Color(const string &color)
|
Color::Color(const string &color)
|
||||||
: color_(color)
|
: color_(color)
|
||||||
@ -201,12 +212,12 @@ void PlotRange::operator()(PlotOptions &option) const
|
|||||||
option.scale[a].max = max_;
|
option.scale[a].max = max_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Title constructor ///////////////////////////////////////////////////////////
|
// Terminal constructor ////////////////////////////////////////////////////////
|
||||||
Terminal::Terminal(const string &terminal, const std::string &options)
|
Terminal::Terminal(const string &terminal, const std::string &options)
|
||||||
: terminalCmd_(terminal + " " + options)
|
: terminalCmd_(terminal + " " + options)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Title modifier //////////////////////////////////////////////////////////////
|
// Terminal modifier ///////////////////////////////////////////////////////////
|
||||||
void Terminal::operator()(PlotOptions &option) const
|
void Terminal::operator()(PlotOptions &option) const
|
||||||
{
|
{
|
||||||
option.terminal = terminalCmd_;
|
option.terminal = terminalCmd_;
|
||||||
@ -257,6 +268,7 @@ void Plot::initOptions(void)
|
|||||||
{
|
{
|
||||||
options_.terminal = "";
|
options_.terminal = "";
|
||||||
options_.output = "";
|
options_.output = "";
|
||||||
|
options_.caption = "";
|
||||||
options_.title = "";
|
options_.title = "";
|
||||||
options_.scaleMode[0] = Plot::Scale::reset;
|
options_.scaleMode[0] = Plot::Scale::reset;
|
||||||
options_.scaleMode[1] = Plot::Scale::reset;
|
options_.scaleMode[1] = Plot::Scale::reset;
|
||||||
@ -415,6 +427,10 @@ ostream & Latan::operator<<(ostream &out, const Plot &plot)
|
|||||||
{
|
{
|
||||||
out << "set output '" << plot.options_.terminal << "'" << endl;
|
out << "set output '" << plot.options_.terminal << "'" << endl;
|
||||||
}
|
}
|
||||||
|
if (!plot.options_.caption.empty())
|
||||||
|
{
|
||||||
|
out << "set title '" << plot.options_.caption << "'" << endl;
|
||||||
|
}
|
||||||
if (plot.options_.scaleMode[x] & Plot::Scale::manual)
|
if (plot.options_.scaleMode[x] & Plot::Scale::manual)
|
||||||
{
|
{
|
||||||
out << "xMin = " << plot.options_.scale[x].min << endl;
|
out << "xMin = " << plot.options_.scale[x].min << endl;
|
||||||
|
15
lib/Plot.hpp
15
lib/Plot.hpp
@ -117,6 +117,7 @@ struct PlotOptions
|
|||||||
{
|
{
|
||||||
std::string terminal;
|
std::string terminal;
|
||||||
std::string output;
|
std::string output;
|
||||||
|
std::string caption;
|
||||||
std::string title;
|
std::string title;
|
||||||
unsigned int scaleMode[2];
|
unsigned int scaleMode[2];
|
||||||
Range scale[2];
|
Range scale[2];
|
||||||
@ -133,6 +134,19 @@ public:
|
|||||||
virtual void operator()(PlotOptions &option) const = 0;
|
virtual void operator()(PlotOptions &option) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Caption: public PlotModifier
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructor
|
||||||
|
explicit Caption(const std::string &title);
|
||||||
|
// destructor
|
||||||
|
virtual ~Caption(void) = default;
|
||||||
|
// modifier
|
||||||
|
virtual void operator()(PlotOptions &option) const;
|
||||||
|
private:
|
||||||
|
const std::string caption_;
|
||||||
|
};
|
||||||
|
|
||||||
class Color: public PlotModifier
|
class Color: public PlotModifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -186,7 +200,6 @@ private:
|
|||||||
const std::string terminalCmd_;
|
const std::string terminalCmd_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Title: public PlotModifier
|
class Title: public PlotModifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user