ENH:optimize ams settings and virtual tray

1. separate virtual tray and extrustion calibrations
2. only when confirming will the disabled materials be checked
3. uptimize ams style

Change-Id: Ie435555d0cad45fbc0cb1bf7e1706985ec1aaa78
This commit is contained in:
tao wang 2023-04-06 09:37:19 +08:00 committed by Lane.Wei
parent 4c6623848d
commit f06b214c30
8 changed files with 89 additions and 59 deletions

View File

@ -26,22 +26,23 @@
"ftp_folder" : "sdcard/",
"printer_thumbnail_image": "printer_thumbnail_p1p"
},
{
"display_name": "Bambu Lab X1",
"func": {
"FUNC_EXTRUSION_CALI": true,
"FUNC_LOCAL_TUNNEL": false
{
"display_name": "Bambu Lab X1",
"func": {
"FUNC_VIRTUAL_TYAY" : true,
"FUNC_EXTRUSION_CALI": false,
"FUNC_LOCAL_TUNNEL": false
},
"model_id": "BL-P002",
"camera_resolution":["720p","1080p"],
"printer_type": "3DPrinter-X1",
"printer_thumbnail_image": "printer_thumbnail"
},
"camera_resolution": [ "720p", "1080p" ],
"model_id": "BL-P002",
"printer_type": "3DPrinter-X1",
"printer_thumbnail_image": "printer_thumbnail"
},
{
"display_name": "Bambu Lab X1 Carbon",
"func": {
"FUNC_EXTRUSION_CALI": true,
"FUNC_VIRTUAL_TYAY" : true,
"FUNC_EXTRUSION_CALI": false,
"FUNC_LOCAL_TUNNEL": false
},
"model_id": "BL-P001",

View File

@ -530,9 +530,39 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
if (preset_bundle) {
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
if (it->alias.compare(m_comboBox_filament->GetValue().ToStdString()) == 0) {
//check is it in the filament blacklist
if(!is_virtual_tray()){
bool in_blacklist = false;
std::string action;
std::string info;
std::string filamnt_type;
it->get_filament_type(filamnt_type);
if (it->vendor) {
DeviceManager::check_filaments_in_blacklist(it->vendor->name, filamnt_type, in_blacklist, action, info);
}
if (in_blacklist) {
if (action == "prohibition") {
MessageDialog msg_wingow(nullptr, info, _L("Error"), wxICON_WARNING | wxOK);
msg_wingow.ShowModal();
//m_comboBox_filament->SetSelection(m_filament_selection);
return;
}
else if (action == "warning") {
MessageDialog msg_wingow(nullptr, info, _L("Warning"), wxICON_INFORMATION | wxOK);
msg_wingow.ShowModal();
}
}
}
ams_filament_id = it->filament_id;
ams_setting_id = it->setting_id;
break;
}
}
}
@ -835,30 +865,6 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
if (!m_comboBox_filament->GetValue().IsEmpty() && it->alias.compare(m_comboBox_filament->GetValue().ToStdString()) == 0) {
//check is it in the filament blacklist
bool in_blacklist = false;
std::string action;
std::string info;
std::string filamnt_type;
it->get_filament_type(filamnt_type);
if (it->vendor) {
DeviceManager::check_filaments_in_blacklist(it->vendor->name, filamnt_type, in_blacklist, action, info);
}
if (in_blacklist) {
if (action == "prohibition") {
MessageDialog msg_wingow(nullptr, info, _L("Error"), wxICON_WARNING | wxOK);
msg_wingow.ShowModal();
m_comboBox_filament->SetSelection(m_filament_selection);
return;
}
else if (action == "warning") {
MessageDialog msg_wingow(nullptr, info, _L("Warning"), wxICON_INFORMATION | wxOK);
msg_wingow.ShowModal();
}
}
// ) if nozzle_temperature_range is found
ConfigOption* opt_min = it->config.option("nozzle_temperature_range_low");
if (opt_min) {

View File

@ -2283,6 +2283,9 @@ bool MachineObject::is_function_supported(PrinterFunction func)
case FUNC_PRINT_ALL:
func_name = "FUNC_PRINT_ALL";
break;
case FUNC_VIRTUAL_TYAY:
func_name = "FUNC_VIRTUAL_TYAY";
break;
default:
return true;
}

View File

@ -91,6 +91,7 @@ enum PrinterFunction {
FUNC_AUTO_SWITCH_FILAMENT,
FUNC_CHAMBER_FAN,
FUNC_EXTRUSION_CALI,
FUNC_VIRTUAL_TYAY,
FUNC_PRINT_ALL,
FUNC_MAX
};

View File

@ -1096,11 +1096,11 @@ wxBoxSizer *StatusBasePanel::create_ams_group(wxWindow *parent)
return sizer;
}
void StatusBasePanel::show_ams_group(bool show, bool support_virtual_tray, bool support_vt_load)
void StatusBasePanel::show_ams_group(bool show, bool support_virtual_tray, bool support_extrustion_cali, bool support_vt_load)
{
m_ams_control->Show(true);
m_ams_control_box->Show(true);
m_ams_control->show_noams_mode(show, support_virtual_tray, support_vt_load);
m_ams_control->show_noams_mode(show, support_virtual_tray, support_extrustion_cali, support_vt_load);
if (m_show_ams_group != show) {
Fit();
}
@ -1924,7 +1924,7 @@ void StatusPanel::update_ams(MachineObject *obj)
if (is_support_extrusion_cali) {
m_ams_control->update_vams_kn_value(obj->vt_tray);
}
show_ams_group(false, obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI), obj->is_support_filament_edit_virtual_tray);
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);
return;
}
@ -1933,7 +1933,7 @@ void StatusPanel::update_ams(MachineObject *obj)
m_ams_control->update_vams_kn_value(obj->vt_tray);
}
show_ams_group(true, obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI), obj->is_support_filament_edit_virtual_tray);
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 (m_filament_setting_dlg) m_filament_setting_dlg->update();
std::vector<AMSinfo> ams_info;
@ -2684,11 +2684,11 @@ void StatusPanel::on_ams_setting_click(SimpleEvent &event)
if (obj) {
m_ams_setting_dlg->update_insert_material_read_mode(obj->ams_insert_flag);
m_ams_setting_dlg->update_starting_read_mode(obj->ams_power_on_flag);
std::string ams_id = m_ams_control->GetCurentAms();
if (ams_id.compare(std::to_string(VIRTUAL_TRAY_ID)) == 0) {
wxString txt = _L("AMS settings are not supported for external spool");
MessageDialog msg_dlg(nullptr, txt, wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
std::string ams_id = m_ams_control->GetCurentShowAms();
if (obj->amsList.size() == 0) {
/* wxString txt = _L("AMS settings are not supported for external spool");
MessageDialog msg_dlg(nullptr, txt, wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();*/
return;
} else {
try {

View File

@ -253,7 +253,7 @@ public:
wxBoxSizer *create_ams_group(wxWindow *parent);
wxBoxSizer *create_settings_group(wxWindow *parent);
void show_ams_group(bool show = true, bool support_virtual_tray = true, bool support_vt_load = true);
void show_ams_group(bool show = true, bool support_virtual_tray = true, bool support_extrustion_cali = true, bool support_vt_load = true);
};

View File

@ -757,16 +757,25 @@ void AMSLib::render(wxDC &dc)
}
//draw k&n
if (m_show_kn) {
wxString str_k = wxString::Format("K %1.3f", m_info.k);
wxString str_n = wxString::Format("N %1.3f", m_info.n);
dc.SetFont(::Label::Body_11);
auto tsize = dc.GetMultiLineTextExtent(str_k);
auto pot_k = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9) + tsize.y);
dc.DrawText(str_k, pot_k);
//auto pot_n = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(18) + tsize.y * 2);
//dc.DrawText(str_n, pot_n);
if (m_obj && m_obj->is_function_supported(PrinterFunction::FUNC_EXTRUSION_CALI)) {
if (m_show_kn){
wxString str_k = wxString::Format("K %1.3f", m_info.k);
wxString str_n = wxString::Format("N %1.3f", m_info.n);
dc.SetFont(::Label::Body_11);
auto tsize = dc.GetMultiLineTextExtent(str_k);
auto pot_k = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9) + tsize.y);
dc.DrawText(str_k, pot_k);
}
}
else if(m_info.material_state == AMSCanType::AMS_CAN_TYPE_VIRTUAL){
if (m_show_kn) {
wxString str_k = wxString::Format("K %1.3f", m_info.k);
wxString str_n = wxString::Format("N %1.3f", m_info.n);
dc.SetFont(::Label::Body_11);
auto tsize = dc.GetMultiLineTextExtent(str_k);
auto pot_k = wxPoint((libsize.x - tsize.x) / 2, (libsize.y - tsize.y) / 2 - FromDIP(9) + tsize.y);
dc.DrawText(str_k, pot_k);
}
}
}
@ -939,6 +948,12 @@ void AMSLib::doRender(wxDC &dc)
void AMSLib::Update(Caninfo info, bool refresh)
{
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
if (dev->get_selected_machine() && dev->get_selected_machine() != m_obj) {
m_obj = dev->get_selected_machine();
}
m_info = info;
Layout();
if (refresh) Refresh();
@ -2250,6 +2265,7 @@ void AMSControl::init_scaled_buttons()
}
std::string AMSControl::GetCurentAms() { return m_current_ams; }
std::string AMSControl::GetCurentShowAms() { return m_current_show_ams; }
std::string AMSControl::GetCurrentCan(std::string amsid)
{
@ -2497,11 +2513,12 @@ void AMSControl::Reset()
m_current_senect = "";
}
void AMSControl::show_noams_mode(bool show, bool support_virtual_tray, bool support_vt_load)
void AMSControl::show_noams_mode(bool show, bool support_virtual_tray, bool support_extrustion_cali, bool support_vt_load)
{
show_vams(support_virtual_tray);
m_sizer_ams_tips->Show(support_virtual_tray);
if (!support_virtual_tray)
if (!support_extrustion_cali)
m_button_extrusion_cali->Hide();
else {
m_button_extrusion_cali->Show();

View File

@ -284,6 +284,7 @@ public:
public:
wxColour GetLibColour();
Caninfo m_info;
MachineObject* m_obj = {nullptr};
int m_can_index;
void Update(Caninfo info, bool refresh = true);
void UnableSelected() { m_unable_selected = true; };
@ -571,6 +572,7 @@ protected:
std::string m_last_tray_id;
public:
std::string GetCurentAms();
std::string GetCurentShowAms();
std::string GetCurrentCan(std::string amsid);
wxColour GetCanColour(std::string amsid, std::string canid);
@ -610,7 +612,7 @@ public:
void on_clibration_cancel_click(wxMouseEvent &event);
void Reset();
void show_noams_mode(bool show, bool support_virtual_tray, bool support_vt_load = false);
void show_noams_mode(bool show, bool support_virtual_tray, bool support_extrustion_cali, bool support_vt_load = false);
void show_vams(bool show);
void show_vams_kn_value(bool show);
void update_vams_kn_value(AmsTray tray);