From c52e54e58a1250e7b0701a29771b130e7d5dc8b0 Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Thu, 13 Feb 2025 18:57:05 +0800 Subject: [PATCH] FIX: reduce ams update Change-Id: I6a3c34580df77135c3b56e9273edc7643d58eec3 Jira: STUDIO-10383 --- src/slic3r/GUI/Plater.cpp | 23 +++++++++++++++-------- src/slic3r/GUI/Widgets/StaticGroup.cpp | 5 +++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 5389bfab4..ed5f492dc 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -369,12 +369,12 @@ struct ExtruderGroup : StaticGroup void set_ams_count(int n4, int n1) { + if (n4 == ams_n4 || n1 == ams_n1) + return; ams_n4 = n4; ams_n1 = n1; - if (btn_edit) { - if (GUI::wxGetApp().plater()) - GUI::wxGetApp().plater()->update_machine_sync_status(); + update_ams(); } } @@ -967,6 +967,7 @@ ExtruderGroup::ExtruderGroup(wxWindow * parent, int index, wxString const &title hsizer_ams->Add(label_ams, 0, wxALIGN_CENTER); if (btn_edit) hsizer_ams->Add(btn_edit, 0, wxLEFT | wxALIGN_CENTER, FromDIP(2)); + hsizer_ams->Add(ams_not_installed_msg, 0, wxALIGN_CENTER); btn_up = new ScalableButton(this, wxID_ANY, "page_up", "", {-1, FromDIP(14)}); btn_up->SetBackgroundColour(*wxWHITE); @@ -1080,17 +1081,23 @@ void ExtruderGroup::update_ams() void ExtruderGroup::sync_ams(MachineObject const *obj, std::vector const &ams4, std::vector const &ams1) { - auto sync = [obj](std::vector &infos, std::vector const &ams) { - infos.clear(); + if (ams_4.empty() && ams4.empty() + && ams_1.empty() && ams1.empty()) + return; + auto sync = [obj](std::vector &infos, std::vector const &ams) -> bool { + std::vector infos2; for (auto a : ams) { AMSinfo ams_info; ams_info.parse_ams_info(const_cast(obj), a, obj->ams_calibrate_remain_flag, obj->is_support_ams_humidity); infos.push_back(ams_info); } + if (infos == infos2) + return false; + infos.swap(infos2); + return true; }; - sync(ams_4, ams4); - sync(ams_1, ams1); - update_ams(); + if (sync(ams_4, ams4) || sync(ams_1, ams1)) + update_ams(); } bool Sidebar::priv::switch_diameter(bool single) diff --git a/src/slic3r/GUI/Widgets/StaticGroup.cpp b/src/slic3r/GUI/Widgets/StaticGroup.cpp index 8f7c73b9c..24aa2beaa 100644 --- a/src/slic3r/GUI/Widgets/StaticGroup.cpp +++ b/src/slic3r/GUI/Widgets/StaticGroup.cpp @@ -26,7 +26,7 @@ void StaticGroup::ShowBadge(bool show) badge->SetBackgroundColour("#F7F7F7"); LayoutBadge(); } - if (badge) + if (badge && badge->IsShown() != show) badge->Show(show); #endif } @@ -75,8 +75,9 @@ void StaticGroup::PaintForeground(wxDC &dc, const struct tagRECT &rc) void StaticGroup::DoSetSize(int x, int y, int width, int height, int sizeFlags) { + auto size = GetSize(); wxStaticBox::DoSetSize(x, y, width, height, sizeFlags); - if (badge) + if (badge && size != GetSize()) LayoutBadge(); }