diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 874a92eb36..ec82566e3d 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -185,9 +185,9 @@ void AppConfig::set_defaults() set_bool("reverse_mouse_wheel_zoom", false); if (get("enable_append_color_by_sync_ams").empty()) - set_bool("enable_append_color_by_sync_ams", false); + set_bool("enable_append_color_by_sync_ams", true); if (get("enable_merge_color_by_sync_ams").empty()) - set_bool("enable_merge_color_by_sync_ams", true); + set_bool("enable_merge_color_by_sync_ams", false); if (get("ams_sync_match_full_use_color_dist").empty()) set_bool("ams_sync_match_full_use_color_dist", false); diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index ff8f76869e..a934292ee7 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -2184,7 +2184,22 @@ unsigned int PresetBundle::sync_ams_list(unsigned int &unknowns, bool use_map, s [](std::vector &value) { return value.empty(); }), ams_multi_color_filment.end()); if (need_append_colors.size() > 0 && enable_append) { + auto get_idx_in_array = [](std::vector &presets, std::vector &colors, const std::string &preset, const std::string &color) -> int { + for (size_t i = 0; i < presets.size(); i++) { + if (presets[i] == preset && colors[i] == color) { + return i; + } + } + return -1; + }; for (size_t i = 0; i < need_append_colors.size(); i++){ + if (exist_filament_presets.size() >= size_t(EnforcerBlockerType::ExtruderMax)){ + break; + } + auto idx = get_idx_in_array(exist_filament_presets, exist_colors, need_append_colors[i].filament_preset, need_append_colors[i].filament_color); + if (idx >= 0) { + continue; + } exist_filament_presets.push_back(need_append_colors[i].filament_preset); exist_colors.push_back(need_append_colors[i].filament_color); std::vector value = {need_append_colors[i].filament_color}; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 8078e7e82e..db076401e6 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2839,22 +2839,26 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn) temp_info.use_dialog_pos = false; temp_info.cancel_text_to_later = is_from_big_sync_btn; temp_info.connected_printer = true; - SyncAmsInfoDialog sync_dlg(this, temp_info); + if (m_sync_dlg == nullptr) { + m_sync_dlg = std::make_shared(this, temp_info); + } else { + m_sync_dlg->set_info(temp_info); + } int dlg_res{(int) wxID_CANCEL}; - if (sync_dlg.is_need_show()) { - if (sync_dlg.is_dirty_filament()){ + if (m_sync_dlg->is_need_show()) { + if (m_sync_dlg->is_dirty_filament()) { wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filament_presets[0], false, "", false, true); wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); dynamic_filament_list.update(); } - sync_dlg.set_check_dirty_fialment(false); - dlg_res = sync_dlg.ShowModal(); + m_sync_dlg->set_check_dirty_fialment(false); + dlg_res = m_sync_dlg->ShowModal(); } else { dlg_res =(int) wxID_YES; } if (dlg_res == wxID_CANCEL) return; - auto sync_result = sync_dlg.get_result(); + auto sync_result = m_sync_dlg->get_result(); if (!sync_result.is_same_printer) { return; } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 3f936c628c..965985ccb6 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -64,7 +64,7 @@ namespace UndoRedo { } namespace GUI { - +class SyncAmsInfoDialog; class MainFrame; class ConfigOptionsGroup; class ObjectSettings; @@ -132,6 +132,7 @@ class Sidebar : public wxPanel std::vector m_cur_combox_bed_types; int m_last_combo_bedtype_count{0}; bool m_begin_sync_printer_status{false}; + std::shared_ptr m_sync_dlg{nullptr}; public: enum DockingState diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index f3277f51f5..0489ef1efb 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -402,7 +402,9 @@ void SyncAmsInfoDialog::update_map_when_change_map_mode() for (size_t i = 0; i < m_preview_colors_in_thumbnail.size(); i++) { if (i < m_ams_combo_info.ams_filament_colors.size()) { auto result = decode_ams_color(m_ams_combo_info.ams_filament_colors[i]); - m_cur_colors_in_thumbnail[i] = result; + if (i < m_cur_colors_in_thumbnail.size()) { + m_cur_colors_in_thumbnail[i] = result; + } } else { if (!m_cur_colors_in_thumbnail.empty()) { @@ -4355,6 +4357,11 @@ SyncAmsInfoDialog::~SyncAmsInfoDialog() { } } +void SyncAmsInfoDialog::set_info(SyncInfo &info) +{ + m_input_info = info; +} + void SyncAmsInfoDialog::update_lan_machine_list() { DeviceManager *dev = wxGetApp().getDeviceManager(); diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.hpp b/src/slic3r/GUI/SyncAmsInfoDialog.hpp index a8732e02ed..592ac3a21c 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.hpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.hpp @@ -270,6 +270,7 @@ public: }; SyncAmsInfoDialog(wxWindow *parent, SyncInfo &info); ~SyncAmsInfoDialog(); + void set_info(SyncInfo &info); void on_dpi_changed(const wxRect &suggested_rect) override; const SyncResult &get_result() { return m_result; } @@ -351,7 +352,7 @@ private: bool m_is_empty_project = true; bool m_check_dirty_fialment = true; - bool m_expand_more_settings = false; + bool m_expand_more_settings = true; bool m_image_is_top = false; const int LEFT_THUMBNAIL_SIZE_WIDTH = 100;