#5236 - Fixed color not correctly shown after slice

The bug was introduced with 148f4fe766 which is now replaced by this commit
This commit is contained in:
enricoturri1966 2020-11-23 17:15:22 +01:00
parent 95d65f9f30
commit 92953acc57
2 changed files with 6 additions and 7 deletions

View file

@ -598,9 +598,6 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
}
}
// ensure at least one (default) color is defined
std::string default_color = "#FF8000";
m_result.extruder_colors = std::vector<std::string>(1, default_color);
const ConfigOptionStrings* extruder_colour = config.option<ConfigOptionStrings>("extruder_colour");
if (extruder_colour != nullptr) {
// takes colors from config
@ -615,7 +612,9 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
}
}
// replace missing values with default
std::string default_color = "#FF8000";
for (size_t i = 0; i < m_result.extruder_colors.size(); ++i) {
if (m_result.extruder_colors[i].empty())
m_result.extruder_colors[i] = default_color;
@ -837,10 +836,6 @@ void GCodeProcessor::process_file(const std::string& filename, bool apply_postpr
update_estimated_times_stats();
// ensure at least one (default) color is defined
if (m_result.extruder_colors.empty())
m_result.extruder_colors.push_back("#FF8000");
// post-process to add M73 lines into the gcode
if (apply_postprocess)
m_time_processor.post_process(filename);

View file

@ -373,6 +373,10 @@ void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std:
// update tool colors
m_tool_colors = decode_colors(str_tool_colors);
// ensure at least one (default) color is defined
if (m_tool_colors.empty())
m_tool_colors.push_back(decode_color("#FF8000"));
// update ranges for coloring / legend
m_extrusions.reset_ranges();
for (size_t i = 0; i < m_moves_count; ++i) {