diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 6c3fc1693..370fb2669 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -171,9 +171,9 @@ void AppConfig::set_defaults() set_bool("reverse_mouse_wheel_zoom", false); #endif 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 418d6f46f..cb1eb95ec 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -2048,7 +2048,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 25f92dbb7..5389bfab4 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2967,22 +2967,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 886c3f0d4..d7e56ce4c 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -65,7 +65,7 @@ namespace UndoRedo { } namespace GUI { - +class SyncAmsInfoDialog; class MainFrame; class ConfigOptionsGroup; class ObjectSettings; @@ -124,6 +124,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: Sidebar(Plater *parent); diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index ffeca591c..fd8036a39 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -400,7 +400,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()) { @@ -4362,6 +4364,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 02c159d04..c8fd67446 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; diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index 9362a5d53..f4597e9c1 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -1004,11 +1004,11 @@ std::string UrlEncode( const std::string &input ) escaped.fill('0'); escaped << std::hex; for (char c : input) { - // 如果字符是字母、数字、'-'、'.'、'_' 或 '~',则直接添加到结果中 + // 濡傛灉瀛楃鏄瓧姣嶃佹暟瀛椼'-'銆'.'銆'_' 鎴 '~'锛屽垯鐩存帴娣诲姞鍒扮粨鏋滀腑 if (std::isalnum(c) || c == '-' || c == '.' || c == '_' || c == '~') { escaped << c; } else { - // 对于其他字符,将其转换为 %XX 的形式 + // 瀵逛簬鍏朵粬瀛楃锛屽皢鍏惰浆鎹负 %XX 鐨勫舰寮 escaped << '%' << std::setw(2) << static_cast(static_cast(c)); } }