FIX: reduce ams update

Change-Id: I6a3c34580df77135c3b56e9273edc7643d58eec3
Jira: STUDIO-10383
This commit is contained in:
chunmao.guo 2025-02-13 18:57:05 +08:00 committed by lane.wei
parent 09c0b004cd
commit c52e54e58a
2 changed files with 18 additions and 10 deletions

View File

@ -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<Ams *> const &ams4, std::vector<Ams *> const &ams1)
{
auto sync = [obj](std::vector<AMSinfo> &infos, std::vector<Ams *> const &ams) {
infos.clear();
if (ams_4.empty() && ams4.empty()
&& ams_1.empty() && ams1.empty())
return;
auto sync = [obj](std::vector<AMSinfo> &infos, std::vector<Ams *> const &ams) -> bool {
std::vector<AMSinfo> infos2;
for (auto a : ams) {
AMSinfo ams_info;
ams_info.parse_ams_info(const_cast<MachineObject*>(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)

View File

@ -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();
}