From cda6860bcfdc4cd5e84673f6f1d5e3809563e2f1 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Fri, 24 Jan 2025 17:31:37 +0800 Subject: [PATCH] FIX:Synchronize the machine to maintain the same hot bed selection jira: STUDIO-10146 Change-Id: Ia2000bab1c41097ef50ee84aa35d9a5c8921ef56 (cherry picked from commit f95f88de0d7a789464046ba0837e3ff4da0ab5a6) --- src/slic3r/GUI/Plater.cpp | 33 +++++++++++++++++++++++++++++---- src/slic3r/GUI/Plater.hpp | 5 ++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 389d0403c5..1208b7d957 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2037,7 +2037,10 @@ void Sidebar::update_all_preset_comboboxes() p->combo_printer_bed->Enable(); // Orca: don't update bed type if loading project if (!p->plater->is_loading_project()) { - reset_bed_type_combox_choices(); + bool has_changed = reset_bed_type_combox_choices(); + if (m_begin_sync_printer_status && !has_changed) { + return; + } auto str_bed_type = wxGetApp().app_config->get_printer_setting(wxGetApp().preset_bundle->printers.get_selected_preset_name(), "curr_bed_type"); if (!str_bed_type.empty()) { @@ -2231,12 +2234,30 @@ BedType Sidebar::get_cur_select_bed_type() { return select_bed_type; } -void Sidebar::reset_bed_type_combox_choices() { - if (!p->combo_printer_bed) { return; } +void Sidebar::set_bed_type_accord_combox(BedType bed_type) { + for (size_t i = 0; i < m_cur_combox_bed_types.size(); i++) { + if (m_cur_combox_bed_types[i] == bed_type) { + p->combo_printer_bed->SelectAndNotify(i); + return; + } + } + p->combo_printer_bed->SelectAndNotify(0); +} + +bool Sidebar::reset_bed_type_combox_choices() { + if (!p->combo_printer_bed) { + return false; + } + auto bundle = wxGetApp().preset_bundle; const Preset * curr = &bundle->printers.get_selected_preset(); const VendorProfile::PrinterModel *pm = PresetUtils::system_printer_model(*curr); - + if (m_last_combo_bedtype_count != 0 && pm) { + auto cur_count = (int) BedType::btCount - 1 - pm->not_support_bed_types.size(); + if (cur_count == m_last_combo_bedtype_count) {//no change + return false; + } + } const ConfigOptionDef *bed_type_def = print_config_def.get("curr_bed_type"); p->combo_printer_bed->Clear(); m_cur_combox_bed_types.clear(); @@ -2260,6 +2281,8 @@ void Sidebar::reset_bed_type_combox_choices() { p->combo_printer_bed->AppendString(_L(item)); } } + m_last_combo_bedtype_count = p->combo_printer_bed->GetCount(); + return true; } void Sidebar::change_top_border_for_mode_sizer(bool increase_border) @@ -3042,11 +3065,13 @@ bool Sidebar::is_multifilament() } void Sidebar::deal_btn_sync() { + m_begin_sync_printer_status = true; bool only_external_material; auto ok = p->sync_extruder_list(only_external_material); if (ok) { pop_sync_nozzle_and_ams_ialog(); } + m_begin_sync_printer_status = false; } void Sidebar::pop_sync_nozzle_and_ams_ialog() { diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 502463df38..d339cac456 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -130,6 +130,8 @@ class Sidebar : public wxPanel std::shared_ptr m_sna_dialog{nullptr}; std::shared_ptr m_fna_dialog{nullptr}; std::vector m_cur_combox_bed_types; + int m_last_combo_bedtype_count{0}; + bool m_begin_sync_printer_status{false}; public: enum DockingState @@ -153,7 +155,8 @@ public: //BBS void update_presets_from_to(Slic3r::Preset::Type preset_type, std::string from, std::string to); BedType get_cur_select_bed_type(); - void reset_bed_type_combox_choices(); + void set_bed_type_accord_combox(BedType bed_type); + bool reset_bed_type_combox_choices(); void change_top_border_for_mode_sizer(bool increase_border); void msw_rescale(); void sys_color_changed();