diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 71e17b489..f6b22a5b2 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2384,6 +2384,10 @@ std::vector Plater::priv::load_files(const std::vector& input_ CustomGCode::update_custom_gcode_per_print_z_from_config(model.custom_gcode_per_print_z, &wxGetApp().preset_bundle->project_config); // For exporting from the amf/3mf we shouldn't check printer_presets for the containing information about "Print Host upload" wxGetApp().load_current_presets(false); + // Update filament colors for the MM-printer profile in the full config + // to avoid black (default) colors for Extruders in the ObjectList, + // when for extruder colors are used filament colors + q->update_filament_colors_in_full_config(); is_project_file = true; } wxGetApp().app_config->update_config_dir(path.parent_path().string()); @@ -5786,6 +5790,26 @@ void Plater::on_extruders_change(size_t num_extruders) sidebar().scrolled_panel()->Refresh(); } +bool Plater::update_filament_colors_in_full_config() +{ + // There is a case, when we use filament_color instead of extruder_color (when extruder_color == ""). + // Thus plater config option "filament_colour" should be filled with filament_presets values. + // Otherwise, on 3dScene will be used last edited filament color for all volumes with extruder_color == "". + const std::vector filament_presets = wxGetApp().preset_bundle->filament_presets; + if (filament_presets.size() == 1 || !p->config->has("filament_colour")) + return false; + + const PresetCollection& filaments = wxGetApp().preset_bundle->filaments; + std::vector filament_colors; + filament_colors.reserve(filament_presets.size()); + + for (const std::string& filament_preset : filament_presets) + filament_colors.push_back(filaments.find_preset(filament_preset, true)->config.opt_string("filament_colour", (unsigned)0)); + + p->config->option("filament_colour")->values = filament_colors; + return true; +} + void Plater::on_config_change(const DynamicPrintConfig &config) { bool update_scheduled = false; @@ -5795,22 +5819,7 @@ void Plater::on_config_change(const DynamicPrintConfig &config) { update_scheduled = true; // update should be scheduled (for update 3DScene) #2738 - /* There is a case, when we use filament_color instead of extruder_color (when extruder_color == ""). - * Thus plater config option "filament_colour" should be filled with filament_presets values. - * Otherwise, on 3dScene will be used last edited filament color for all volumes with extruder_color == "". - */ - const std::vector filament_presets = wxGetApp().preset_bundle->filament_presets; - if (filament_presets.size() > 1 && - p->config->option(opt_key)->values.size() != config.option(opt_key)->values.size()) - { - const PresetCollection& filaments = wxGetApp().preset_bundle->filaments; - std::vector filament_colors; - filament_colors.reserve(filament_presets.size()); - - for (const std::string& filament_preset : filament_presets) - filament_colors.push_back(filaments.find_preset(filament_preset, true)->config.opt_string("filament_colour", (unsigned)0)); - - p->config->option(opt_key)->values = filament_colors; + if (update_filament_colors_in_full_config()) { p->sidebar->obj_list()->update_extruder_colors(); continue; } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 5c7c6d7c9..5407a6e85 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -233,6 +233,7 @@ public: void leave_gizmos_stack(); void on_extruders_change(size_t extruders_count); + bool update_filament_colors_in_full_config(); void on_config_change(const DynamicPrintConfig &config); void force_filament_colors_update(); void force_print_bed_update();