From 43959714eecb191316638f99365181ada4dbb61d Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 11 Jun 2019 16:13:50 -0500 Subject: [PATCH] Allowing overlap color setting via plots.xml --- include/openmc/plot.h | 2 +- src/plot.cpp | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 1621def93..e08e62d5f 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -210,7 +210,7 @@ private: void set_user_colors(pugi::xml_node plot_node); void set_meshlines(pugi::xml_node plot_node); void set_mask(pugi::xml_node plot_node); - void set_color_overlaps(pugi::xml_node plot_node); + void set_overlap_color(pugi::xml_node plot_node); // Members public: diff --git a/src/plot.cpp b/src/plot.cpp index da880a5b1..60c39389f 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -155,7 +155,7 @@ void create_ppm(Plot pl) // no setting needed if not found if (id == NOT_FOUND) { continue; } if (id == OVERLAP) { - data(x,y) = RED; + data(x,y) = pl.overlap_color_; continue; } if (PlotColorBy::cells == pl.color_by_) { @@ -657,10 +657,28 @@ Plot::set_mask(pugi::xml_node plot_node) } } -void Plot::set_color_overlaps(pugi::xml_node plot_node) { +void Plot::set_overlap_color(pugi::xml_node plot_node) { color_overlaps_ = false; if (check_for_node(plot_node, "show_overlaps")) { color_overlaps_ = get_node_value_bool(plot_node, "show_overlaps"); + overlap_color_ = RED; + // check for custom overlap color + if (check_for_node(plot_node, "overlap_color")) { + if (!color_overlaps_) { + std::stringstream wrn_msg; + wrn_msg << "Overlap color specified in plot " << id_ + << " but overlaps won't be shown."; + warning(wrn_msg); + } + std::vector olap_clr = get_node_array(plot_node, "overlap_color"); + if (olap_clr.size() == 3) { + overlap_color_ = olap_clr; + } else { + std::stringstream err_msg; + err_msg << "Bad overlap RGB in plot " << id_; + fatal_error(err_msg); + } + } } // make sure we allocate the vector for counting overlap checks if @@ -686,7 +704,7 @@ Plot::Plot(pugi::xml_node plot_node) set_user_colors(plot_node); set_meshlines(plot_node); set_mask(plot_node); - set_color_overlaps(plot_node); + set_overlap_color(plot_node); } // End Plot constructor //==============================================================================