ENH:optimize filament auto refill

Change-Id: I098ea5872061ba8c27e9240faa301db8fd3a1b82
This commit is contained in:
tao wang 2023-06-20 12:06:16 +08:00 committed by Lane.Wei
parent 85b44fbe1f
commit c26961218a
6 changed files with 48 additions and 65 deletions

View File

@ -1161,7 +1161,7 @@ void MappingContainer::doRender(wxDC& dc)
} }
AmsReplaceMaterialDialog::AmsReplaceMaterialDialog(wxWindow* parent) AmsReplaceMaterialDialog::AmsReplaceMaterialDialog(wxWindow* parent)
: DPIDialog(parent, wxID_ANY, _L("Filaments Auto refill"), wxDefaultPosition, wxDefaultSize, wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX) : DPIDialog(parent, wxID_ANY, _L("Auto Refill"), wxDefaultPosition, wxDefaultSize, wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX)
{ {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
SetDoubleBuffered(true); SetDoubleBuffered(true);
@ -1187,7 +1187,7 @@ void AmsReplaceMaterialDialog::create()
m_main_sizer->Add(m_top_line, 0, wxEXPAND, 0); m_main_sizer->Add(m_top_line, 0, wxEXPAND, 0);
auto label_title = new Label(this, _L("Auto refill")); auto label_title = new Label(this, _L("Auto Refill"));
label_title->SetFont(Label::Head_14); label_title->SetFont(Label::Head_14);
label_title->SetForegroundColour(0x00AE42); label_title->SetForegroundColour(0x00AE42);
auto label_txt = new Label(this, _L("When the current material run out, the printer will continue to print in the following order.")); auto label_txt = new Label(this, _L("When the current material run out, the printer will continue to print in the following order."));

View File

@ -1106,9 +1106,8 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_sizer_material_area->Add(m_sizer_material_tips, 0, wxALIGN_CENTER|wxLEFT, FromDIP(8)); m_sizer_material_area->Add(m_sizer_material_tips, 0, wxALIGN_CENTER|wxLEFT, FromDIP(8));
m_sizer_material_area->Add(m_sizer_material, 0, wxLEFT, FromDIP(15)); m_sizer_material_area->Add(m_sizer_material, 0, wxLEFT, FromDIP(15));
#ifdef FILAMENT_BACKUP m_sizer_backup = new wxBoxSizer(wxHORIZONTAL);
auto m_sizer_backup = new wxBoxSizer(wxHORIZONTAL); auto m_ams_backup_tip = new Label(this, _L("Auto Refill"));
auto m_ams_backup_tip = new Label(this, _L("Ams filament backup"));
m_ams_backup_tip->SetFont(::Label::Head_12); m_ams_backup_tip->SetFont(::Label::Head_12);
m_ams_backup_tip->SetForegroundColour(wxColour(0x00AE42)); m_ams_backup_tip->SetForegroundColour(wxColour(0x00AE42));
m_ams_backup_tip->SetBackgroundColour(*wxWHITE); m_ams_backup_tip->SetBackgroundColour(*wxWHITE);
@ -1118,6 +1117,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_sizer_backup->Add(0, 0, 1, wxEXPAND, 0); m_sizer_backup->Add(0, 0, 1, wxEXPAND, 0);
m_sizer_backup->Add(img_ams_backup, 0, wxALL, FromDIP(3)); m_sizer_backup->Add(img_ams_backup, 0, wxALL, FromDIP(3));
m_sizer_backup->Add(m_ams_backup_tip, 0, wxTOP, FromDIP(5)); m_sizer_backup->Add(m_ams_backup_tip, 0, wxTOP, FromDIP(5));
m_sizer_backup->Show(false);
m_ams_backup_tip->Bind(wxEVT_ENTER_WINDOW, [this, img_amsmapping_tip](auto& e) {SetCursor(wxCURSOR_HAND); }); m_ams_backup_tip->Bind(wxEVT_ENTER_WINDOW, [this, img_amsmapping_tip](auto& e) {SetCursor(wxCURSOR_HAND); });
img_ams_backup->Bind(wxEVT_ENTER_WINDOW, [this, img_amsmapping_tip](auto& e) {SetCursor(wxCURSOR_HAND); }); img_ams_backup->Bind(wxEVT_ENTER_WINDOW, [this, img_amsmapping_tip](auto& e) {SetCursor(wxCURSOR_HAND); });
@ -1127,7 +1127,6 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_ams_backup_tip->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {popup_filament_backup(); on_rename_enter(); }); m_ams_backup_tip->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {popup_filament_backup(); on_rename_enter(); });
img_ams_backup->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {popup_filament_backup(); }); img_ams_backup->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {popup_filament_backup(); });
#endif
m_statictext_ams_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL); m_statictext_ams_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
m_statictext_ams_msg->SetFont(::Label::Body_13); m_statictext_ams_msg->SetFont(::Label::Body_13);
@ -1358,10 +1357,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0); m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(13)); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(13));
m_sizer_main->Add(m_scrollable_view, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, FromDIP(25)); m_sizer_main->Add(m_scrollable_view, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, FromDIP(25));
#ifdef FILAMENT_BACKUP
m_sizer_main->Add(m_sizer_backup, 0, wxALIGN_CENTER_HORIZONTAL, 0); m_sizer_main->Add(m_sizer_backup, 0, wxALIGN_CENTER_HORIZONTAL, 0);
#endif
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(6)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(6));
m_sizer_main->Add(m_statictext_ams_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0); m_sizer_main->Add(m_statictext_ams_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0);
@ -1413,7 +1409,7 @@ void SelectMachineDialog::init_bind()
if (e.GetInt() == 0) { if (e.GetInt() == 0) {
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
if (dev->get_selected_machine()) { if (dev->get_selected_machine()->dev_id == e.GetString()) {
m_comboBox_printer->SetValue(dev->get_selected_machine()->dev_name + "(LAN)"); m_comboBox_printer->SetValue(dev->get_selected_machine()->dev_name + "(LAN)");
} }
}else if(e.GetInt() == 1){ }else if(e.GetInt() == 1){
@ -2876,6 +2872,20 @@ void SelectMachineDialog::on_timer(wxTimerEvent &event)
{ {
wxGetApp().reset_to_active(); wxGetApp().reset_to_active();
update_show_status(); update_show_status();
///show auto refill
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if(!dev) return;
MachineObject* obj_ = dev->get_selected_machine();
if(!obj_) return;
if (!obj_ || obj_->amsList.empty() || obj_->ams_exist_bits == 0 || !obj_->ams_auto_switch_filament_flag || !obj_->is_function_supported(PrinterFunction::FUNC_FILAMENT_BACKUP)) {
m_sizer_backup->Show(false);
Layout();
}
else {
m_sizer_backup->Show(true);
Layout();
}
} }
void SelectMachineDialog::on_selection_changed(wxCommandEvent &event) void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
@ -2926,6 +2936,7 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
return; return;
} }
//reset print status //reset print status
show_status(PrintDialogStatus::PrintStatusInit); show_status(PrintDialogStatus::PrintStatusInit);
@ -2965,7 +2976,6 @@ void SelectMachineDialog::update_show_status()
} }
if (!dev) return; if (!dev) return;
dev->check_pushing(); dev->check_pushing();
PartPlate* plate = m_plater->get_partplate_list().get_curr_plate(); PartPlate* plate = m_plater->get_partplate_list().get_curr_plate();
// blank plate has no valid gcode file // blank plate has no valid gcode file
@ -2975,7 +2985,6 @@ void SelectMachineDialog::update_show_status()
return; return;
} }
} }
MachineObject* obj_ = dev->get_my_machine(m_printer_last_select); MachineObject* obj_ = dev->get_my_machine(m_printer_last_select);
if (!obj_) { if (!obj_) {
update_ams_check(nullptr); update_ams_check(nullptr);

View File

@ -330,6 +330,7 @@ protected:
wxBoxSizer* m_sizer_scrollable_region{ nullptr }; wxBoxSizer* m_sizer_scrollable_region{ nullptr };
wxBoxSizer* rename_sizer_v{ nullptr }; wxBoxSizer* rename_sizer_v{ nullptr };
wxBoxSizer* rename_sizer_h{ nullptr }; wxBoxSizer* rename_sizer_h{ nullptr };
wxBoxSizer* m_sizer_backup{ nullptr };
Button* m_button_refresh{ nullptr }; Button* m_button_refresh{ nullptr };
Button* m_button_ensure{ nullptr }; Button* m_button_ensure{ nullptr };
ScalableButton * m_rename_button{nullptr}; ScalableButton * m_rename_button{nullptr};

View File

@ -2012,7 +2012,9 @@ void StatusPanel::update_ams(MachineObject *obj)
} }
if (m_filament_setting_dlg) { m_filament_setting_dlg->obj = obj; } if (m_filament_setting_dlg) { m_filament_setting_dlg->obj = obj; }
bool is_none_ams_mode = false; bool is_support_extrusion_cali = obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI);
bool is_support_virtual_tray = obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY);
bool is_support_filament_backup = obj->is_function_supported(PrinterFunction::FUNC_FILAMENT_BACKUP);
if (!obj if (!obj
|| !obj->is_connected() || !obj->is_connected()
@ -2027,31 +2029,19 @@ void StatusPanel::update_ams(MachineObject *obj)
last_ams_version = -1; last_ams_version = -1;
BOOST_LOG_TRIVIAL(trace) << "machine object" << obj->dev_name << " was disconnected, set show_ams_group is false"; BOOST_LOG_TRIVIAL(trace) << "machine object" << obj->dev_name << " was disconnected, set show_ams_group is false";
} }
bool is_support_extrusion_cali = obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI);
bool is_support_virtual_tray = obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY);
if (is_support_virtual_tray) { show_ams_group(false, obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY), is_support_extrusion_cali, obj->is_support_filament_edit_virtual_tray);
m_ams_control->update_vams_kn_value(obj->vt_tray, obj); m_ams_control->show_auto_refill(false);
} }
show_ams_group(false, obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY), obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI), obj->is_support_filament_edit_virtual_tray); else {
is_none_ams_mode = true;
//return; show_ams_group(true, obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY), is_support_extrusion_cali, obj->is_support_filament_edit_virtual_tray);
m_ams_control->show_auto_refill(is_support_filament_backup);
if(is_support_filament_backup) m_ams_control->show_auto_refill(obj->ams_auto_switch_filament_flag);
} }
bool is_support_extrusion_cali = obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI);
bool is_support_virtual_tray = obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY);
bool is_support_filament_backup = obj->is_function_supported(PrinterFunction::FUNC_FILAMENT_BACKUP);
m_ams_control->show_filament_backup(is_support_filament_backup);
if (is_support_virtual_tray) {
m_ams_control->update_vams_kn_value(obj->vt_tray, obj);
}
if (!is_none_ams_mode) {
show_ams_group(true, obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY), obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI), obj->is_support_filament_edit_virtual_tray);
}
if (is_support_virtual_tray) m_ams_control->update_vams_kn_value(obj->vt_tray, obj);
if (m_filament_setting_dlg) m_filament_setting_dlg->update(); if (m_filament_setting_dlg) m_filament_setting_dlg->update();
std::vector<AMSinfo> ams_info; std::vector<AMSinfo> ams_info;

View File

@ -1886,13 +1886,11 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
//backup tips //backup tips
m_ams_backup_tip = new Label(m_amswin, _L("Auto Refill"));
#ifdef FILAMENT_BACKUP
auto m_ams_backup_tip = new Label(m_amswin, _L("Ams filament backup"));
m_ams_backup_tip->SetFont(::Label::Head_12); m_ams_backup_tip->SetFont(::Label::Head_12);
m_ams_backup_tip->SetForegroundColour(wxColour(0x00AE42)); m_ams_backup_tip->SetForegroundColour(wxColour(0x00AE42));
m_ams_backup_tip->SetBackgroundColour(*wxWHITE); m_ams_backup_tip->SetBackgroundColour(*wxWHITE);
auto m_img_ams_backup = new wxStaticBitmap(m_amswin, wxID_ANY, create_scaled_bitmap("automatic_material_renewal", this, 16), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0); m_img_ams_backup = new wxStaticBitmap(m_amswin, wxID_ANY, create_scaled_bitmap("automatic_material_renewal", this, 16), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0);
m_img_ams_backup->SetBackgroundColour(*wxWHITE); m_img_ams_backup->SetBackgroundColour(*wxWHITE);
m_sizer_ams_tips->Add(0, 0, 1, wxEXPAND, 0); m_sizer_ams_tips->Add(0, 0, 1, wxEXPAND, 0);
@ -1907,9 +1905,6 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
m_ams_backup_tip->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {post_event(SimpleEvent(EVT_AMS_FILAMENT_BACKUP)); }); m_ams_backup_tip->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {post_event(SimpleEvent(EVT_AMS_FILAMENT_BACKUP)); });
m_img_ams_backup->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {post_event(SimpleEvent(EVT_AMS_FILAMENT_BACKUP)); }); m_img_ams_backup->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {post_event(SimpleEvent(EVT_AMS_FILAMENT_BACKUP)); });
#endif // FILAMENT_BACKUP
//ams cans //ams cans
@ -2656,8 +2651,15 @@ void AMSControl::show_noams_mode(bool show, bool support_virtual_tray, bool supp
} }
show?ExitNoneAMSMode() : EnterNoneAMSMode(support_vt_load); show?ExitNoneAMSMode() : EnterNoneAMSMode(support_vt_load);
if (simple_mode) if (simple_mode)EnterSimpleMode();
EnterSimpleMode(); }
void AMSControl::show_auto_refill(bool show)
{
m_ams_backup_tip->Show(show);
m_img_ams_backup->Show(show);
m_amswin->Layout();
m_amswin->Fit();
} }
void AMSControl::show_vams(bool show) void AMSControl::show_vams(bool show)
@ -2697,10 +2699,6 @@ void AMSControl::update_vams_kn_value(AmsTray tray, MachineObject* obj)
m_vams_lib->Refresh(); m_vams_lib->Refresh();
} }
void AMSControl::show_filament_backup(bool show)
{
}
void AMSControl::reset_vams() void AMSControl::reset_vams()
{ {
m_vams_lib->m_info.k = 0; m_vams_lib->m_info.k = 0;
@ -2761,22 +2759,6 @@ void AMSControl::UpdateAms(std::vector<AMSinfo> info, bool keep_selection, bool
} }
} }
/*if (m_current_senect.empty() && info.size() > 0) {
if (curr_ams_id.empty()) {
SwitchAms(info[0].ams_id);
return;
}
if (keep_selection) {
SwitchAms(curr_ams_id);
for (auto i = 0; i < m_ams_cans_list.GetCount(); i++) {
AmsCansWindow *cans = m_ams_cans_list[i];
if (i < info.size()) { cans->amsCans->SelectCan(curr_can_id); }
}
return;
}
}*/
if ( m_current_show_ams.empty() && !is_reset ) { if ( m_current_show_ams.empty() && !is_reset ) {
if (info.size() > 0) { if (info.size() > 0) {
SwitchAms(info[0].ams_id); SwitchAms(info[0].ams_id);

View File

@ -13,7 +13,6 @@
#include <wx/animate.h> #include <wx/animate.h>
#include <wx/dynarray.h> #include <wx/dynarray.h>
#define FILAMENT_BACKUP 1
#define AMS_CONTROL_BRAND_COLOUR wxColour(0, 174, 66) #define AMS_CONTROL_BRAND_COLOUR wxColour(0, 174, 66)
#define AMS_CONTROL_GRAY700 wxColour(107, 107, 107) #define AMS_CONTROL_GRAY700 wxColour(107, 107, 107)
#define AMS_CONTROL_GRAY800 wxColour(50, 58, 61) #define AMS_CONTROL_GRAY800 wxColour(50, 58, 61)
@ -564,6 +563,7 @@ protected:
wxBoxSizer* m_vams_sizer = {nullptr}; wxBoxSizer* m_vams_sizer = {nullptr};
wxBoxSizer* m_sizer_vams_tips = {nullptr}; wxBoxSizer* m_sizer_vams_tips = {nullptr};
Label* m_ams_backup_tip = {nullptr};
Caninfo m_vams_info; Caninfo m_vams_info;
StaticBox* m_panel_virtual = {nullptr}; StaticBox* m_panel_virtual = {nullptr};
AMSLib* m_vams_lib = {nullptr}; AMSLib* m_vams_lib = {nullptr};
@ -583,6 +583,7 @@ protected:
Button *m_button_extruder_feed = {nullptr}; Button *m_button_extruder_feed = {nullptr};
Button *m_button_extruder_back = {nullptr}; Button *m_button_extruder_back = {nullptr};
wxStaticBitmap* m_button_ams_setting = {nullptr}; wxStaticBitmap* m_button_ams_setting = {nullptr};
wxStaticBitmap* m_img_ams_backup = {nullptr};
ScalableBitmap m_button_ams_setting_normal; ScalableBitmap m_button_ams_setting_normal;
ScalableBitmap m_button_ams_setting_hover; ScalableBitmap m_button_ams_setting_hover;
ScalableBitmap m_button_ams_setting_press; ScalableBitmap m_button_ams_setting_press;
@ -640,10 +641,10 @@ public:
void Reset(); void Reset();
void show_noams_mode(bool show, bool support_virtual_tray, bool support_extrustion_cali, bool support_vt_load = false, bool simple_mode = false); void show_noams_mode(bool show, bool support_virtual_tray, bool support_extrustion_cali, bool support_vt_load = false, bool simple_mode = false);
void show_auto_refill(bool show);
void show_vams(bool show); void show_vams(bool show);
void show_vams_kn_value(bool show); void show_vams_kn_value(bool show);
void update_vams_kn_value(AmsTray tray, MachineObject* obj); void update_vams_kn_value(AmsTray tray, MachineObject* obj);
void show_filament_backup(bool show);
void reset_vams(); void reset_vams();
void post_event(wxEvent&& event); void post_event(wxEvent&& event);