Skip to content

Commit

Permalink
Adding the possibility to add a background the the EpsPlumes.
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvielamythepaut committed Jan 11, 2023
1 parent a0f543f commit 4ddd74a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/attributes/EpsPlumeAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ EpsPlumeAttributes::EpsPlumeAttributes():
median_line_thickness_(ParameterManager::getInt("eps_plume_median_line_thickness")),
shading_(ParameterManager::getBool("eps_plume_shading")),
shading_levels_(ParameterManager::getDoubleArray("eps_plume_shading_level_list")),
shading_colours_(ParameterManager::getStringArray("eps_plume_shading_colour_list"))
shading_colours_(ParameterManager::getStringArray("eps_plume_shading_colour_list")),
background_level_list_(ParameterManager::getDoubleArray("eps_plume_background_level_list")),
background_colour_list_(ParameterManager::getStringArray("eps_plume_background_colour_list"))
,
line_colour_(MagTranslator<string, Colour>().magics("eps_plume_line_colour")),
line_style_(MagTranslator<string, LineStyle>().magics("eps_plume_line_style")),
Expand Down Expand Up @@ -78,6 +80,8 @@ void EpsPlumeAttributes::set(const std::map<string, string>& params)
setAttribute(prefix, "eps_plume_shading", shading_, params);
setAttribute(prefix, "eps_plume_shading_level_list", shading_levels_, params);
setAttribute(prefix, "eps_plume_shading_colour_list", shading_colours_, params);
setAttribute(prefix, "eps_plume_background_level_list", background_level_list_, params);
setAttribute(prefix, "eps_plume_background_colour_list", background_colour_list_, params);

setMember(prefix, "eps_plume_line_colour", line_colour_, params);
setAttribute(prefix, "eps_plume_line_style", line_style_, params);
Expand Down Expand Up @@ -105,6 +109,8 @@ void EpsPlumeAttributes::copy(const EpsPlumeAttributes& other)
shading_ = other.shading_;
shading_levels_ = other.shading_levels_;
shading_colours_ = other.shading_colours_;
background_level_list_ = other.background_level_list_;
background_colour_list_ = other.background_colour_list_;
line_colour_ = unique_ptr<Colour>(other.line_colour_->clone());
line_style_ = other.line_style_;
forecast_line_colour_ = unique_ptr<Colour>(other.forecast_line_colour_->clone());
Expand Down Expand Up @@ -164,6 +170,8 @@ void EpsPlumeAttributes::print(ostream& out) const
out << " shading = " << shading_;
out << " shading_levels = " << shading_levels_;
out << " shading_colours = " << shading_colours_;
out << " background_level_list = " << background_level_list_;
out << " background_colour_list = " << background_colour_list_;
out << " line_colour = " << *line_colour_;
out << " line_style = " << line_style_;
out << " forecast_line_colour = " << *forecast_line_colour_;
Expand Down Expand Up @@ -205,6 +213,10 @@ void EpsPlumeAttributes::toxml(ostream& out) const
niceprint(out,shading_levels_);
out << ", \"eps_plume_shading_colour_list\":";
niceprint(out,shading_colours_);
out << ", \"eps_plume_background_level_list\":";
niceprint(out,background_level_list_);
out << ", \"eps_plume_background_colour_list\":";
niceprint(out,background_colour_list_);
out << ", \"eps_plume_line_colour\":";
niceprint(out, *line_colour_);
out << ", \"eps_plume_line_style\":";
Expand Down Expand Up @@ -237,6 +249,8 @@ static MagicsParameter<int> eps_plume_median_line_thickness("eps_plume_median_li
static MagicsParameter<string> eps_plume_shading("eps_plume_shading", "off");
static MagicsParameter<doublearray> eps_plume_shading_level_list("eps_plume_shading_level_list", floatarray());
static MagicsParameter<stringarray> eps_plume_shading_colour_list("eps_plume_shading_colour_list", stringarray());
static MagicsParameter<doublearray> eps_plume_background_level_list("eps_plume_background_level_list", floatarray());
static MagicsParameter<stringarray> eps_plume_background_colour_list("eps_plume_background_colour_list", stringarray());
static MagicsParameter<string> eps_plume_line_colour("eps_plume_line_colour", "magenta");
static MagicsParameter<string> eps_plume_line_style("eps_plume_line_style", "solid");
static MagicsParameter<string> eps_plume_forecast_line_colour("eps_plume_forecast_line_colour", "cyan");
Expand Down
2 changes: 2 additions & 0 deletions src/attributes/EpsPlumeAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class EpsPlumeAttributes
bool shading_;
doublearray shading_levels_;
stringarray shading_colours_;
doublearray background_level_list_;
stringarray background_colour_list_;
unique_ptr<Colour> line_colour_;
LineStyle line_style_;
unique_ptr<Colour> forecast_line_colour_;
Expand Down
10 changes: 10 additions & 0 deletions src/attributes/EpsPlumeWrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ void EpsPlumeWrapper::set(const MagRequest& request)
shading_colours_value.push_back((string)request("EPS_PLUME_SHADING_COLOUR_LIST", i));
if ( !shading_colours_value.empty() )
epsplume_->shading_colours_ = shading_colours_value;
doublearray background_level_list_value;
for (int i = 0; i < request.countValues("EPS_PLUME_BACKGROUND_LEVEL_LIST"); i++)
background_level_list_value.push_back((double)request("EPS_PLUME_BACKGROUND_LEVEL_LIST", i));
if ( !background_level_list_value.empty() )
epsplume_->background_level_list_ = background_level_list_value;
stringarray background_colour_list_value;
for (int i = 0; i < request.countValues("EPS_PLUME_BACKGROUND_COLOUR_LIST"); i++)
background_colour_list_value.push_back((string)request("EPS_PLUME_BACKGROUND_COLOUR_LIST", i));
if ( !background_colour_list_value.empty() )
epsplume_->background_colour_list_ = background_colour_list_value;

if (request.countValues("EPS_PLUME_LINE_COLOUR") ) {
string line_colour_value = request("EPS_PLUME_LINE_COLOUR");
Expand Down
15 changes: 15 additions & 0 deletions src/params/EpsPlume.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,20 @@ does it submit to any jurisdiction.
name="eps_plume_shading_colour_list">
<documentation>colours used for plumes shading</documentation>
</parameter>
<parameter member="background_level_list"
to="floatarray"
default="floatarray()"
from="floatarray"
name="eps_plume_background_level_list">
<documentation>Background level list</documentation>
</parameter>
<parameter member="background_colour_list"
to="stringarray"
default="stringarray()"
from="stringarray"
name="eps_plume_background_colour_list">
<documentation>Background colour list</documentation>
</parameter>

</class>
</magics>
38 changes: 38 additions & 0 deletions src/visualisers/EpsGraph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2660,14 +2660,52 @@ void EpsPlume::verticalprofile(Data& data, BasicGraphicsObjectContainer& visitor
visitor.push_back(control);
visitor.push_back(forecast);
}

void EpsPlume::background(BasicGraphicsObjectContainer& visitor) {
// Add background
const Transformation& transformation = visitor.transformation();

double from = transformation.getMinY();
auto colour = background_colour_list_.begin();
for (const auto& level : background_level_list_ ) {
Polyline* area = new Polyline();
area->setColour(Colour(*colour));
area->setFilled(true);
area->setShading(new FillShadingProperties());
area->setFillColour(Colour(*colour));
visitor.push_back(area);
area->push_back(PaperPoint(transformation.getMinX(), from));
area->push_back(PaperPoint(transformation.getMinX(), level));
area->push_back(PaperPoint(transformation.getMaxX(), level));
area->push_back(PaperPoint(transformation.getMaxX(), from));
area->push_back(PaperPoint(transformation.getMinX(), from));
from = level;
colour++;
}
Polyline* area = new Polyline();
area->setColour(Colour(*colour));
area->setFilled(true);
area->setShading(new FillShadingProperties());
area->setFillColour(Colour(*colour));
visitor.push_back(area);
area->push_back(PaperPoint(transformation.getMinX(), from));
area->push_back(PaperPoint(transformation.getMinX(), transformation.getMaxY()));
area->push_back(PaperPoint(transformation.getMaxX(), transformation.getMaxY()));
area->push_back(PaperPoint(transformation.getMaxX(), from));
area->push_back(PaperPoint(transformation.getMinX(), from));

}

void EpsPlume::operator()(Data& data, BasicGraphicsObjectContainer& visitor) {
background(visitor);
method_ = lowerCase(method_);
std::map<string, Method>::iterator method = methods_.find(method_);
if (method == methods_.end()) {
MagLog::warning() << "Could not find method [" << method_ << "] for plotting : no plot could be done." << endl;
return;
}
(this->*method->second)(data, visitor);

}


Expand Down
2 changes: 1 addition & 1 deletion src/visualisers/EpsGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class EpsPlume : public Visdef, public EpsPlumeAttributes {
vector<Colour> shading_legend_;
void timeserie(Data&, BasicGraphicsObjectContainer&);
void verticalprofile(Data&, BasicGraphicsObjectContainer&);

void background(BasicGraphicsObjectContainer& visitor);
private:
//! Copy constructor - No copy allowed
EpsPlume(const EpsPlume&);
Expand Down

0 comments on commit 4ddd74a

Please sign in to comment.