Skip to content

Commit

Permalink
Improve handling of legend for the plumes for Miha
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Sep 15, 2023
1 parent b0e208d commit b276ff6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
6 changes: 6 additions & 0 deletions share/magics/styles/ecmwf/test/styles.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"red_lines" : {
"contour" : "on",
"contour_line_colour" : "red"
}
}
7 changes: 7 additions & 0 deletions src/attributes/EpsPlumeAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ using namespace magics;
EpsPlumeAttributes::EpsPlumeAttributes():
method_(ParameterManager::getString("eps_plume_method")),
legend_(ParameterManager::getBool("eps_plume_legend")),
legend_grey_style_(ParameterManager::getBool("eps_plume_legend_grey_style")),
line_(ParameterManager::getBool("eps_plume_members")),
line_thickness_(ParameterManager::getInt("eps_plume_line_thickness")),
forecast_(ParameterManager::getBool("eps_plume_forecast")),
Expand Down Expand Up @@ -79,6 +80,7 @@ void EpsPlumeAttributes::set(const std::map<string, string>& params)

setAttribute(prefix, "eps_plume_method", method_, params);
setAttribute(prefix, "eps_plume_legend", legend_, params);
setAttribute(prefix, "eps_plume_legend_grey_style", legend_grey_style_, params);
setAttribute(prefix, "eps_plume_members", line_, params);
setAttribute(prefix, "eps_plume_line_thickness", line_thickness_, params);
setAttribute(prefix, "eps_plume_forecast", forecast_, params);
Expand Down Expand Up @@ -118,6 +120,7 @@ void EpsPlumeAttributes::copy(const EpsPlumeAttributes& other)
{
method_ = other.method_;
legend_ = other.legend_;
legend_grey_style_ = other.legend_grey_style_;
line_ = other.line_;
line_thickness_ = other.line_thickness_;
forecast_ = other.forecast_;
Expand Down Expand Up @@ -189,6 +192,7 @@ void EpsPlumeAttributes::print(ostream& out) const
out << "Attributes[";
out << " method = " << method_;
out << " legend = " << legend_;
out << " legend_grey_style = " << legend_grey_style_;
out << " line = " << line_;
out << " line_thickness = " << line_thickness_;
out << " forecast = " << forecast_;
Expand Down Expand Up @@ -231,6 +235,8 @@ void EpsPlumeAttributes::toxml(ostream& out) const
niceprint(out,method_);
out << ", \"eps_plume_legend\":";
niceprint(out,legend_);
out << ", \"eps_plume_legend_grey_style\":";
niceprint(out,legend_grey_style_);
out << ", \"eps_plume_members\":";
niceprint(out,line_);
out << ", \"eps_plume_line_thickness\":";
Expand Down Expand Up @@ -298,6 +304,7 @@ void EpsPlumeAttributes::toxml(ostream& out) const

static MagicsParameter<string> eps_plume_method("eps_plume_method", "time_serie");
static MagicsParameter<string> eps_plume_legend("eps_plume_legend", "on");
static MagicsParameter<string> eps_plume_legend_grey_style("eps_plume_legend_grey_style", "on");
static MagicsParameter<string> eps_plume_members("eps_plume_members", "on");
static MagicsParameter<int> eps_plume_line_thickness("eps_plume_line_thickness", 1);
static MagicsParameter<string> eps_plume_forecast("eps_plume_forecast", "on");
Expand Down
1 change: 1 addition & 0 deletions src/attributes/EpsPlumeAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class EpsPlumeAttributes
string tag_;
string method_;
bool legend_;
bool legend_grey_style_;
bool line_;
int line_thickness_;
bool forecast_;
Expand Down
8 changes: 8 additions & 0 deletions src/params/EpsPlume.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ does it submit to any jurisdiction.
visible='false'>
<documentation>ignore legend</documentation>
</parameter>
<parameter from="string"
name="eps_plume_legend_grey_style"
default="on"
member="legend_grey_style"
to="bool"
>
<documentation>if On ( default) the legend will use a grey scale ootherwise it will use user defined colour</documentation>
</parameter>
<parameter member="line"
to="bool"
default="on"
Expand Down
7 changes: 4 additions & 3 deletions src/visualisers/EpsGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2625,9 +2625,10 @@ void EpsPlume::timeserie(Data& data, BasicGraphicsObjectContainer& visitor) {
for (vector<PaperPoint>::reverse_iterator point = shading[top].rbegin(); point != shading[top].rend(); ++point)
line->push_back(*point);

double grey = ((col.red() + col.blue() + col.green()) / 3.);

col.setColour(grey, grey, grey);
if ( legend_grey_style_ ) {
double grey = ((col.red() + col.blue() + col.green()) / 3.);
col.setColour(grey, grey, grey);
}

++colour;
shading_legend_.push_back(col);
Expand Down

0 comments on commit b276ff6

Please sign in to comment.