From 92953acc57971be634a905710e4ac274ef8d1e1b Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 23 Nov 2020 17:15:22 +0100 Subject: [PATCH] #5236 - Fixed color not correctly shown after slice The bug was introduced with 148f4fe766cb7cf63972686af600d83804a2e8d3 which is now replaced by this commit --- src/libslic3r/GCode/GCodeProcessor.cpp | 9 ++------- src/slic3r/GUI/GCodeViewer.cpp | 4 ++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index e2a3d0fd7c..d30ec70b5b 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -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(1, default_color); const ConfigOptionStrings* extruder_colour = config.option("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); diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 4a4a8e90e3..7101ee8111 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -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) {