NEW:update automatically when inserting materials

JIRA: STUDIO-6157
Change-Id: I2cefbb7b330ca4f13e841066548992b3fb3740f1
This commit is contained in:
hu.wang 2024-02-02 11:39:42 +08:00 committed by Lane.Wei
parent 7c9ab11bb5
commit 13d2f4e2a9
4 changed files with 55 additions and 20 deletions

View File

@ -21,13 +21,15 @@ void AMSSetting::create()
auto m_static_ams_settings = new wxStaticText(this, wxID_ANY, _L("AMS Settings"), wxDefaultPosition, wxDefaultSize, 0); auto m_static_ams_settings = new wxStaticText(this, wxID_ANY, _L("AMS Settings"), wxDefaultPosition, wxDefaultSize, 0);
m_static_ams_settings->SetFont(::Label::Head_14); m_static_ams_settings->SetFont(::Label::Head_14);
m_static_ams_settings->SetForegroundColour(AMS_SETTING_GREY800); m_static_ams_settings->SetForegroundColour(AMS_SETTING_GREY800);
m_sizer_main->Add(0,0,0,wxTOP,FromDIP(10));
m_sizer_main->Add(m_static_ams_settings, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(24));
m_panel_body = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxTAB_TRAVERSAL); m_panel_body = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxTAB_TRAVERSAL);
m_panel_body->SetBackgroundColour(*wxWHITE); m_panel_body->SetBackgroundColour(*wxWHITE);
wxBoxSizer *m_sizerl_body = new wxBoxSizer(wxVERTICAL); wxBoxSizer *m_sizerl_body = new wxBoxSizer(wxVERTICAL);
m_panel_Insert_material = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, -1), wxTAB_TRAVERSAL);
m_panel_Insert_material->SetBackgroundColour(*wxWHITE);
wxBoxSizer* m_sizer_main_Insert_material = new wxBoxSizer(wxVERTICAL);
// checkbox area 1 // checkbox area 1
wxBoxSizer *m_sizer_Insert_material = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *m_sizer_Insert_material = new wxBoxSizer(wxHORIZONTAL);
@ -43,7 +45,7 @@ void AMSSetting::create()
m_title_Insert_material_auto_read->SetFont(::Label::Head_13); m_title_Insert_material_auto_read->SetFont(::Label::Head_13);
m_title_Insert_material_auto_read->SetForegroundColour(AMS_SETTING_GREY800); m_title_Insert_material_auto_read->SetForegroundColour(AMS_SETTING_GREY800);
m_title_Insert_material_auto_read->Wrap(AMS_SETTING_BODY_WIDTH); m_title_Insert_material_auto_read->Wrap(AMS_SETTING_BODY_WIDTH);
m_sizer_Insert_material->Add(m_title_Insert_material_auto_read, 1, wxALL | wxEXPAND, 0); m_sizer_Insert_material->Add(m_title_Insert_material_auto_read, 0, wxALL | wxEXPAND, 0);
@ -74,7 +76,7 @@ void AMSSetting::create()
m_tip_Insert_material_line2->Hide(); m_tip_Insert_material_line2->Hide();
m_sizer_Insert_material_tip_inline->Add(m_tip_Insert_material_line2, 0, wxEXPAND | wxTOP, 8); m_sizer_Insert_material_tip_inline->Add(m_tip_Insert_material_line2, 0, wxEXPAND | wxTOP, 8);
// tip line2 // tip line3
m_tip_Insert_material_line3 = new Label(m_panel_body, m_tip_Insert_material_line3 = new Label(m_panel_body,
_L("When inserting a new filament, the AMS will not automatically read its information, leaving it blank for you to enter manually.") _L("When inserting a new filament, the AMS will not automatically read its information, leaving it blank for you to enter manually.")
); );
@ -87,6 +89,9 @@ void AMSSetting::create()
m_sizer_Insert_material_tip->Add(m_sizer_Insert_material_tip_inline, 1, wxALIGN_CENTER, 0); m_sizer_Insert_material_tip->Add(m_sizer_Insert_material_tip_inline, 1, wxALIGN_CENTER, 0);
m_sizer_main_Insert_material->Add(m_sizer_Insert_material, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizer_main_Insert_material->Add(m_sizer_Insert_material_tip, 0, wxEXPAND | wxLEFT | wxTOP, 10);
m_panel_Insert_material->SetSizer(m_sizer_main_Insert_material);
// checkbox area 2 // checkbox area 2
wxBoxSizer *m_sizer_starting = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *m_sizer_starting = new wxBoxSizer(wxHORIZONTAL);
@ -205,10 +210,7 @@ void AMSSetting::create()
m_sizer_remain_block->Add(m_sizer_remain_tip, 0, wxLEFT, 18); m_sizer_remain_block->Add(m_sizer_remain_tip, 0, wxLEFT, 18);
m_sizer_remain_block->Add(0, 0, 0, wxTOP, 15); m_sizer_remain_block->Add(0, 0, 0, wxTOP, 15);
m_sizerl_body->Add(m_sizer_Insert_material, 0, wxEXPAND, 0); m_sizerl_body->Add(m_panel_Insert_material, 0, 0, 0);
m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
m_sizerl_body->Add(m_sizer_Insert_material_tip, 0, wxEXPAND | wxLEFT, 18);
m_sizerl_body->Add(0, 0, 0, wxTOP, 15);
m_sizerl_body->Add(m_sizer_starting, 0, wxEXPAND | wxTOP, FromDIP(8)); m_sizerl_body->Add(m_sizer_starting, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizerl_body->Add(0, 0, 0, wxTOP, 8); m_sizerl_body->Add(0, 0, 0, wxTOP, 8);
m_sizerl_body->Add(m_sizer_starting_tip, 0, wxLEFT, 18); m_sizerl_body->Add(m_sizer_starting_tip, 0, wxLEFT, 18);
@ -224,6 +226,8 @@ void AMSSetting::create()
m_panel_body->SetSizer(m_sizerl_body); m_panel_body->SetSizer(m_sizerl_body);
m_panel_body->Layout(); m_panel_body->Layout();
m_sizerl_body->Fit(m_panel_body); m_sizerl_body->Fit(m_panel_body);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_static_ams_settings, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(24));
m_sizer_main->Add(m_panel_body, 1, wxALL | wxEXPAND, FromDIP(24)); m_sizer_main->Add(m_panel_body, 1, wxALL | wxEXPAND, FromDIP(24));
this->SetSizer(m_sizer_main); this->SetSizer(m_sizer_main);
@ -245,18 +249,34 @@ void AMSSetting::create()
}); });
} }
void AMSSetting::update_insert_material_read_mode(bool selected) void AMSSetting::update_insert_material_read_mode(bool selected, std::string version)
{ {
m_checkbox_Insert_material_auto_read->SetValue(selected); if (!version.empty() && version > AMS_F1_SUPPORT_INSERTION_UPDATE_DEFAULT) {
if (selected) { m_checkbox_Insert_material_auto_read->SetValue(true);
m_tip_Insert_material_line1->Show(); m_checkbox_Insert_material_auto_read->Hide();
m_tip_Insert_material_line2->Show(); m_title_Insert_material_auto_read->Hide();
m_tip_Insert_material_line3->Hide();
} else {
m_tip_Insert_material_line1->Hide(); m_tip_Insert_material_line1->Hide();
m_tip_Insert_material_line2->Hide(); m_tip_Insert_material_line2->Hide();
m_tip_Insert_material_line3->Show(); m_tip_Insert_material_line3->Hide();
m_panel_Insert_material->Hide();
} }
else {
m_panel_Insert_material->Show();
m_checkbox_Insert_material_auto_read->SetValue(selected);
m_checkbox_Insert_material_auto_read->Show();
m_title_Insert_material_auto_read->Show();
if (selected) {
m_tip_Insert_material_line1->Show();
m_tip_Insert_material_line2->Show();
m_tip_Insert_material_line3->Hide();
}
else {
m_tip_Insert_material_line1->Hide();
m_tip_Insert_material_line2->Hide();
m_tip_Insert_material_line3->Show();
}
}
m_panel_Insert_material->Layout();
m_sizer_Insert_material_tip_inline->Layout(); m_sizer_Insert_material_tip_inline->Layout();
Layout(); Layout();
Fit(); Fit();

View File

@ -17,6 +17,7 @@
#define AMS_SETTING_GREY200 wxColour(248, 248, 248) #define AMS_SETTING_GREY200 wxColour(248, 248, 248)
#define AMS_SETTING_BODY_WIDTH FromDIP(380) #define AMS_SETTING_BODY_WIDTH FromDIP(380)
#define AMS_SETTING_BUTTON_SIZE wxSize(FromDIP(150), FromDIP(24)) #define AMS_SETTING_BUTTON_SIZE wxSize(FromDIP(150), FromDIP(24))
#define AMS_F1_SUPPORT_INSERTION_UPDATE_DEFAULT std::string("00.00.07.89")
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
@ -27,7 +28,7 @@ public:
~AMSSetting(); ~AMSSetting();
void create(); void create();
void update_insert_material_read_mode(bool selected); void update_insert_material_read_mode(bool selected, std::string version);
void update_ams_img(std::string ams_icon_str); void update_ams_img(std::string ams_icon_str);
void update_starting_read_mode(bool selected); void update_starting_read_mode(bool selected);
void update_remain_mode(bool selected); void update_remain_mode(bool selected);
@ -49,6 +50,7 @@ protected:
protected: protected:
wxPanel * m_panel_body; wxPanel * m_panel_body;
wxPanel* m_panel_Insert_material;
CheckBox * m_checkbox_Insert_material_auto_read; CheckBox * m_checkbox_Insert_material_auto_read;
wxStaticText *m_title_Insert_material_auto_read; wxStaticText *m_title_Insert_material_auto_read;
Label* m_tip_Insert_material_line1; Label* m_tip_Insert_material_line1;

View File

@ -2438,7 +2438,7 @@ void StatusPanel::update_ams(MachineObject *obj)
m_ams_setting_dlg->obj = obj; m_ams_setting_dlg->obj = obj;
if (obj && m_ams_setting_dlg->IsShown()) { if (obj && m_ams_setting_dlg->IsShown()) {
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag); update_ams_insert_material(obj);
m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag); m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag);
m_ams_setting_dlg->update_remain_mode(obj->ams_calibrate_remain_flag); m_ams_setting_dlg->update_remain_mode(obj->ams_calibrate_remain_flag);
m_ams_setting_dlg->update_switch_filament(obj->ams_auto_switch_filament_flag); m_ams_setting_dlg->update_switch_filament(obj->ams_auto_switch_filament_flag);
@ -2692,6 +2692,18 @@ void StatusPanel::update_ams(MachineObject *obj)
update_ams_control_state(is_curr_tray_selected); update_ams_control_state(is_curr_tray_selected);
} }
void StatusPanel::update_ams_insert_material(MachineObject* obj) {
std::string extra_ams_str = (boost::format("ams_f1/%1%") % 0).str();
auto extra_ams_it = obj->module_vers.find(extra_ams_str);
if (extra_ams_it != obj->module_vers.end()) {
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag, extra_ams_it->second.sw_ver);
}
else {
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag, "");
}
}
void StatusPanel::update_ams_control_state(bool is_curr_tray_selected) void StatusPanel::update_ams_control_state(bool is_curr_tray_selected)
{ {
// set default value to true // set default value to true
@ -3388,7 +3400,7 @@ void StatusPanel::on_ams_setting_click(SimpleEvent &event)
{ {
if (!m_ams_setting_dlg) m_ams_setting_dlg = new AMSSetting((wxWindow *) this, wxID_ANY); if (!m_ams_setting_dlg) m_ams_setting_dlg = new AMSSetting((wxWindow *) this, wxID_ANY);
if (obj) { if (obj) {
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag); update_ams_insert_material(obj);
m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag); m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag);
m_ams_setting_dlg->update_ams_img(DeviceManager::get_printer_ams_img(obj->printer_type)); m_ams_setting_dlg->update_ams_img(DeviceManager::get_printer_ams_img(obj->printer_type));
std::string ams_id = m_ams_control->GetCurentShowAms(); std::string ams_id = m_ams_control->GetCurentShowAms();

View File

@ -587,6 +587,7 @@ protected:
void update_temp_ctrl(MachineObject *obj); void update_temp_ctrl(MachineObject *obj);
void update_misc_ctrl(MachineObject *obj); void update_misc_ctrl(MachineObject *obj);
void update_ams(MachineObject* obj); void update_ams(MachineObject* obj);
void update_ams_insert_material(MachineObject* obj);
void update_extruder_status(MachineObject* obj); void update_extruder_status(MachineObject* obj);
void update_ams_control_state(bool is_curr_tray_selected); void update_ams_control_state(bool is_curr_tray_selected);
void update_cali(MachineObject* obj); void update_cali(MachineObject* obj);