diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 6b45dc121d..587b44bcca 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -807,36 +807,6 @@ void PresetBundle::update_system_preset_setting_ids(std::mapfilament_presets = config_filament_presets; - - auto config_filament_colors = config.get_filament_colors(); - if (!config_filament_colors.empty()) { - ConfigOptionStrings *filament_color = project_config.option("filament_colour"); - filament_color->resize(config_filament_colors.size()); - filament_color->values = config_filament_colors; - } - - auto config_flush_volumes_matrix = config.get_flush_volumes_matrix(); - if (!config_flush_volumes_matrix.empty()) { - ConfigOptionFloats *flush_volumes_matrix = project_config.option("flush_volumes_matrix"); - flush_volumes_matrix->values = std::vector(config_flush_volumes_matrix.begin(), config_flush_volumes_matrix.end()); - } -} - -void PresetBundle::update_filament_info_to_app_config(AppConfig &config) -{ - config.set_filament_presets(this->filament_presets); - - ConfigOptionStrings *filament_color = project_config.option("filament_colour"); - config.set_filament_colors(filament_color->values); - - ConfigOptionFloats *flush_volumes_matrix = project_config.option("flush_volumes_matrix"); - config.set_flush_volumes_matrix(std::vector(flush_volumes_matrix->values.begin(), flush_volumes_matrix->values.end())); -} - //BBS: validate printers from previous project bool PresetBundle::validate_printers(const std::string &name, DynamicPrintConfig& config) { @@ -1346,6 +1316,15 @@ void PresetBundle::load_selections(AppConfig &config, const PresetPreferences& p } } + std::string first_visible_filament_name; + for (auto & fp : filament_presets) { + if (auto it = filaments.find_preset_internal(fp); it == filaments.end() || !it->is_visible || !it->is_compatible) { + if (first_visible_filament_name.empty()) + first_visible_filament_name = filaments.first_compatible().name; + fp = first_visible_filament_name; + } + } + // Parse the initial physical printer name. std::string initial_physical_printer_name = remove_ini_suffix(config.get("presets", "physical_printer")); diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 6cfb7b0e28..8c0e2dd825 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -54,8 +54,6 @@ public: void update_user_presets_directory(const std::string preset_folder); void remove_user_presets_directory(const std::string preset_folder); void update_system_preset_setting_ids(std::map>& system_presets); - void load_default_setting_from_app_config(const AppConfig &config); - void update_filament_info_to_app_config(AppConfig &config); //BBS: add API to get previous machine bool validate_printers(const std::string &name, DynamicPrintConfig& config); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index bf7e22d9e3..5f10fea72c 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -2198,7 +2198,6 @@ bool GUI_App::on_init_inner() BOOST_LOG_TRIVIAL(info) << "loading systen presets..."; preset_bundle = new PresetBundle(); - preset_bundle->load_default_setting_from_app_config(*app_config); // just checking for existence of Slic3r::data_dir is not enough : it may be an empty directory // supplied as argument to --datadir; in that case we should still run the wizard diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7c8839ebb1..136cfbcd63 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -703,7 +703,7 @@ Sidebar::Sidebar(Plater *parent) (project_config.option("flush_multiplier"))->set(new ConfigOptionFloat(dlg.get_flush_multiplier())); wxGetApp().app_config->set("flush_multiplier", std::to_string(dlg.get_flush_multiplier())); - wxGetApp().preset_bundle->update_filament_info_to_app_config(*wxGetApp().app_config); + wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); wxGetApp().plater()->update_project_dirty_from_presets(); wxPostEvent(parent, SimpleEvent(EVT_SCHEDULE_BACKGROUND_PROCESS, parent)); @@ -726,7 +726,7 @@ Sidebar::Sidebar(Plater *parent) wxGetApp().preset_bundle->set_num_filaments(filament_count, new_color); wxGetApp().plater()->on_filaments_change(filament_count); wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); - wxGetApp().preset_bundle->update_filament_info_to_app_config(*wxGetApp().app_config); + wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); }); p->m_bpButton_add_filament = add_btn; @@ -751,7 +751,7 @@ Sidebar::Sidebar(Plater *parent) wxGetApp().preset_bundle->set_num_filaments(filament_count); wxGetApp().plater()->on_filaments_change(filament_count); wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); - wxGetApp().preset_bundle->update_filament_info_to_app_config(*wxGetApp().app_config); + wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); }); p->m_bpButton_del_filament = del_btn; @@ -1352,7 +1352,7 @@ void Sidebar::sync_ams_list() for (auto &c : p->combos_filament) c->update(); wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); - wxGetApp().preset_bundle->update_filament_info_to_app_config(*wxGetApp().app_config); + wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); } ObjectList* Sidebar::obj_list() @@ -5382,7 +5382,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt) if (preset_type == Preset::TYPE_FILAMENT) { wxGetApp().preset_bundle->set_filament_preset(idx, preset_name); wxGetApp().plater()->update_project_dirty_from_presets(); - wxGetApp().preset_bundle->update_filament_info_to_app_config(*wxGetApp().app_config); + wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); } bool select_preset = !combo->selection_is_changed_according_to_physical_printers(); @@ -7376,7 +7376,7 @@ void Plater::load_project(wxString const& filename2, reset_project_dirty_initial_presets(); update_project_dirty_from_presets(); - wxGetApp().preset_bundle->update_filament_info_to_app_config(*wxGetApp().app_config); + wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); // if res is empty no data has been loaded if (!res.empty() && (load_restore || !(strategy & LoadStrategy::Silence))) { diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 9e2a05e8db..2662bcb5ae 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -697,7 +697,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset //wxGetApp().get_tab(Preset::TYPE_PRINTER)->load_config(cfg_new); cfg->apply(cfg_new); wxGetApp().plater()->update_project_dirty_from_presets(); - wxGetApp().preset_bundle->update_filament_info_to_app_config(*wxGetApp().app_config); + wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); update(); wxGetApp().plater()->on_config_change(cfg_new); @@ -1094,9 +1094,6 @@ void PlaterPresetComboBox::update() } update_selection(); - if (selected_system_preset != GetValue()) { - sendComboBoxEvent(); - } Thaw(); if (!tooltip.IsEmpty()) {