ENH:add check machine sync status logic

1. Check machine sync logic before pop up filament map
2. Switch to auto for flush mode if is not synced

jira: NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I05ef0e610418767f763c5579f5fc85a4e9b79c47
This commit is contained in:
xun.zhang 2024-12-20 20:05:43 +08:00 committed by lane.wei
parent f1702a5c36
commit 5d7f8b1267
4 changed files with 37 additions and 2 deletions

View File

@ -11,9 +11,10 @@ static const wxString AutoForFlushLabel = _L("Filament-Saving Mode");
static const wxString AutoForMatchLabel = _L("Convenient Mode");
static const wxString ManualLabel = _L("Manual Mode");
static const wxString AutoForFlushDesp = _L("(Arrage after slicing)");
static const wxString AutoForFlushDesp = _L("(Arrange after slicing)");
static const wxString AutoForMatchDesp = _L("(Arrange before slicing)");
static const wxString ManualDesp = "";
static const wxString MachineSyncTip = _L("(Please sync printer)");
static const wxString AutoForFlushDetail = _L("Disregrad the filaments in AMS. Optimize filament usage "
"by calculating the best allocation for the left and right "
@ -220,7 +221,19 @@ void FilamentGroupPopup::Init(bool connect_status)
radio_btns[ButtonType::btForMatch]->Enable(connect_status);
button_labels[ButtonType::btForMatch]->Enable(connect_status);
if (connect_status) {
button_desps[ButtonType::btForMatch]->SetLabel(AutoForMatchDesp);
}
else {
button_desps[ButtonType::btForMatch]->SetLabel(MachineSyncTip);
}
m_mode = get_prefered_map_mode();
if (m_mode == fmmAutoForMatch && !connect_status) {
set_prefered_map_mode(fmmAutoForFlush);
m_mode = fmmAutoForFlush;
}
wxCheckBoxState check_state = get_pop_up_remind_flag() ? wxCheckBoxState::wxCHK_UNCHECKED : wxCheckBoxState::wxCHK_CHECKED;
remind_checkbox->Set3StateValue(check_state);

View File

@ -1653,7 +1653,7 @@ wxBoxSizer* MainFrame::create_side_tools()
pos.x -= (m_slice_option_btn->GetRect().width + m_filament_group_popup->GetRect().width * 0.6);
m_filament_group_popup->SetPosition(pos);
m_filament_group_popup->tryPopup(m_plater->check_ams_status());
m_filament_group_popup->tryPopup(m_plater->get_machine_sync_status());
});
m_slice_btn->Bind(wxEVT_LEAVE_WINDOW, [this](auto& event) {

View File

@ -3367,6 +3367,7 @@ struct Plater::priv
void unbind_canvas_event_handlers();
void reset_canvas_volumes();
bool check_ams_status_impl(); // Check whether the printer and ams status are consistent, for grouping algorithm
bool get_machine_sync_status(); // check whether the printer is linked and the printer type is same as selected profile
// BBS
bool init_collapse_toolbar();
@ -9178,6 +9179,20 @@ bool Plater::priv::check_ams_status_impl()
return true;
}
bool Plater::priv::get_machine_sync_status()
{
Slic3r::DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev)
return false;
MachineObject* obj = dev->get_selected_machine();
if (!obj)
return false;
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
return preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == obj->printer_type;
}
bool Plater::priv::init_collapse_toolbar()
{
if (wxGetApp().is_gcode_viewer())
@ -15865,6 +15880,11 @@ void Plater::update_machine_sync_status()
GUI::wxGetApp().sidebar().update_sync_status(obj);
}
bool Plater::get_machine_sync_status()
{
return p->get_machine_sync_status();
}
#if ENABLE_ENVIRONMENT_MAP
void Plater::init_environment_texture()
{

View File

@ -603,6 +603,8 @@ public:
void update_objects_position_when_select_preset(const std::function<void()> &select_prest);
bool check_ams_status();
// only check sync status and printer model id
bool get_machine_sync_status();
void update_machine_sync_status();