1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-05-01 01:25:56 +01:00

Plot: dashed lines

This commit is contained in:
Antonin Portelli 2019-03-25 23:20:25 +00:00
parent e37f2ab124
commit cb2f6bf0aa
2 changed files with 31 additions and 0 deletions

View File

@ -356,6 +356,17 @@ void LineWidth::operator()(PlotOptions &option) const
option.lineWidth = static_cast<int>(width_); option.lineWidth = static_cast<int>(width_);
} }
// Dash constructor ///////////////////////////////////////////////////////////
Dash::Dash(const string &dash)
: dash_(dash)
{}
// Dash modifier //////////////////////////////////////////////////////////////
void Dash::operator()(PlotOptions &option) const
{
option.dashType = dash_;
}
// LogScale constructor //////////////////////////////////////////////////////// // LogScale constructor ////////////////////////////////////////////////////////
LogScale::LogScale(const Axis axis) LogScale::LogScale(const Axis axis)
: axis_(axis) : axis_(axis)
@ -470,6 +481,7 @@ void Plot::initOptions(void)
options_.label[1] = ""; options_.label[1] = "";
options_.lineColor = ""; options_.lineColor = "";
options_.lineWidth = -1; options_.lineWidth = -1;
options_.dashType = "";
options_.palette = Palette::category10; options_.palette = Palette::category10;
} }
@ -505,6 +517,11 @@ Plot & Plot::operator<<(PlotObject &&command)
commandStr += " lw " + strFrom(options_.lineWidth); commandStr += " lw " + strFrom(options_.lineWidth);
options_.lineWidth = -1; options_.lineWidth = -1;
} }
if (!options_.dashType.empty())
{
commandStr += " dt " + options_.dashType;
options_.dashType = "";
}
if (options_.title.empty()) if (options_.title.empty())
{ {
commandStr += " notitle"; commandStr += " notitle";

View File

@ -199,6 +199,7 @@ struct PlotOptions
std::string label[2]; std::string label[2];
std::string lineColor; std::string lineColor;
int lineWidth; int lineWidth;
std::string dashType;
std::vector<std::string> palette; std::vector<std::string> palette;
}; };
@ -264,6 +265,19 @@ private:
const unsigned width_; const unsigned width_;
}; };
class Dash: public PlotModifier
{
public:
// constructor
explicit Dash(const std::string &dash);
// destructor
virtual ~Dash(void) = default;
// modifier
virtual void operator()(PlotOptions &option) const;
private:
const std::string dash_;
};
class LogScale: public PlotModifier class LogScale: public PlotModifier
{ {
public: public: