ENH:filter useless filament backups
Change-Id: Ib68a7169d2091c253b4b33457d827b3795e753cb
This commit is contained in:
parent
cb76cf3fe0
commit
3aeb66174d
|
@ -1260,6 +1260,14 @@ std::vector<bool> AmsReplaceMaterialDialog::GetStatus(unsigned int status)
|
||||||
return listStatus;
|
return listStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AmsReplaceMaterialDialog::update_mapping_result( std::vector<FilamentInfo> result)
|
||||||
|
{
|
||||||
|
m_tray_used.clear();
|
||||||
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
m_tray_used.push_back(wxGetApp().transition_tridid(result[i].tray_id).ToStdString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
|
void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
|
||||||
{
|
{
|
||||||
if (obj) {m_obj = obj;}
|
if (obj) {m_obj = obj;}
|
||||||
|
@ -1284,32 +1292,41 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
|
||||||
catch (...) {}
|
catch (...) {}
|
||||||
|
|
||||||
//creat group
|
//creat group
|
||||||
int group_index = 1;
|
int group_index = 0;
|
||||||
for (int filam : m_obj->filam_bak) {
|
for (int filam : m_obj->filam_bak) {
|
||||||
auto status_list = GetStatus(filam);
|
auto status_list = GetStatus(filam);
|
||||||
|
|
||||||
std::map<std::string, wxColour> group_info;
|
std::map<std::string, wxColour> group_info;
|
||||||
std::string group_material;
|
std::string group_material;
|
||||||
|
bool is_in_tray = false;
|
||||||
|
|
||||||
//get color & material
|
//get color & material
|
||||||
for (auto i = 0; i < status_list.size(); i++) {
|
for (auto i = 0; i < status_list.size(); i++) {
|
||||||
if (status_list[i] && tray_list[i] != nullptr) {
|
if (status_list[i] && tray_list[i] != nullptr) {
|
||||||
group_info[wxGetApp().transition_tridid(i).ToStdString()] = AmsTray::decode_color(tray_list[i]->color);
|
auto tray_name = wxGetApp().transition_tridid(i).ToStdString();
|
||||||
|
auto it = std::find(m_tray_used.begin(), m_tray_used.end(), tray_name);
|
||||||
|
if (it != m_tray_used.end()) {
|
||||||
|
is_in_tray = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
group_info[tray_name] = AmsTray::decode_color(tray_list[i]->color);
|
||||||
group_material = tray_list[i]->get_display_filament_type();
|
group_material = tray_list[i]->get_display_filament_type();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_groups_sizer->Add(create_backup_group(wxString::Format("%s%d", _L("Group"), group_index), group_info, group_material, status_list), 0, wxALL, FromDIP(10));
|
if (is_in_tray) {
|
||||||
|
m_groups_sizer->Add(create_backup_group(wxString::Format("%s%d", _L("Group"), group_index + 1), group_info, group_material, status_list), 0, wxALL, FromDIP(10));
|
||||||
group_index++;
|
group_index++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_obj->filam_bak.size() > 0) {
|
if (group_index > 0) {
|
||||||
auto height = 0;
|
auto height = 0;
|
||||||
if (m_obj->filam_bak.size() > 6) {
|
if (group_index > 6) {
|
||||||
height = FromDIP(550);
|
height = FromDIP(550);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
height = FromDIP(200) * (std::ceil(m_obj->filam_bak.size() / 2.0));
|
height = FromDIP(200) * (std::ceil(group_index / 2.0));
|
||||||
}
|
}
|
||||||
m_scrollview_groups->SetMinSize(wxSize(FromDIP(400), height));
|
m_scrollview_groups->SetMinSize(wxSize(FromDIP(400), height));
|
||||||
m_scrollview_groups->SetMaxSize(wxSize(FromDIP(400), height));
|
m_scrollview_groups->SetMaxSize(wxSize(FromDIP(400), height));
|
||||||
|
|
|
@ -285,6 +285,7 @@ public:
|
||||||
AmsRMGroup* create_backup_group(wxString gname, std::map<std::string, wxColour> group_info, wxString material, std::vector<bool> status_list);
|
AmsRMGroup* create_backup_group(wxString gname, std::map<std::string, wxColour> group_info, wxString material, std::vector<bool> status_list);
|
||||||
void create();
|
void create();
|
||||||
void update_machine_obj(MachineObject* obj);
|
void update_machine_obj(MachineObject* obj);
|
||||||
|
void update_mapping_result(std::vector<FilamentInfo> result);
|
||||||
void paintEvent(wxPaintEvent& evt);
|
void paintEvent(wxPaintEvent& evt);
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
std::vector<bool> GetStatus(unsigned int status);
|
std::vector<bool> GetStatus(unsigned int status);
|
||||||
|
@ -295,6 +296,7 @@ public:
|
||||||
wxBoxSizer* m_main_sizer{ nullptr };
|
wxBoxSizer* m_main_sizer{ nullptr };
|
||||||
wxWrapSizer* m_groups_sizer{ nullptr };
|
wxWrapSizer* m_groups_sizer{ nullptr };
|
||||||
MachineObject* m_obj{ nullptr };
|
MachineObject* m_obj{ nullptr };
|
||||||
|
std::vector<std::string> m_tray_used;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1107,17 +1107,19 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
|
||||||
m_sizer_material_area->Add(m_sizer_material, 0, wxLEFT, FromDIP(15));
|
m_sizer_material_area->Add(m_sizer_material, 0, wxLEFT, FromDIP(15));
|
||||||
|
|
||||||
m_sizer_backup = new wxBoxSizer(wxHORIZONTAL);
|
m_sizer_backup = new wxBoxSizer(wxHORIZONTAL);
|
||||||
auto m_ams_backup_tip = new Label(this, _L("Auto Refill"));
|
m_ams_backup_tip = new Label(this, _L("Auto Refill"));
|
||||||
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 img_ams_backup = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("automatic_material_renewal", this, 16), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0);
|
img_ams_backup = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("automatic_material_renewal", this, 16), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0);
|
||||||
img_ams_backup->SetBackgroundColour(*wxWHITE);
|
img_ams_backup->SetBackgroundColour(*wxWHITE);
|
||||||
|
|
||||||
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->Hide();
|
||||||
|
img_ams_backup->Hide();
|
||||||
|
|
||||||
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); });
|
||||||
|
@ -1507,6 +1509,7 @@ void SelectMachineDialog::popup_filament_backup()
|
||||||
if (!dev) return;
|
if (!dev) return;
|
||||||
if (dev->get_selected_machine()/* && dev->get_selected_machine()->filam_bak.size() > 0*/) {
|
if (dev->get_selected_machine()/* && dev->get_selected_machine()->filam_bak.size() > 0*/) {
|
||||||
AmsReplaceMaterialDialog* m_replace_material_popup = new AmsReplaceMaterialDialog(this);
|
AmsReplaceMaterialDialog* m_replace_material_popup = new AmsReplaceMaterialDialog(this);
|
||||||
|
m_replace_material_popup->update_mapping_result(m_ams_mapping_result);
|
||||||
m_replace_material_popup->update_machine_obj(dev->get_selected_machine());
|
m_replace_material_popup->update_machine_obj(dev->get_selected_machine());
|
||||||
m_replace_material_popup->ShowModal();
|
m_replace_material_popup->ShowModal();
|
||||||
}
|
}
|
||||||
|
@ -2879,14 +2882,20 @@ void SelectMachineDialog::on_timer(wxTimerEvent &event)
|
||||||
MachineObject* obj_ = dev->get_selected_machine();
|
MachineObject* obj_ = dev->get_selected_machine();
|
||||||
if(!obj_) return;
|
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)) {
|
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);
|
if (m_ams_backup_tip->IsShown()) {
|
||||||
|
m_ams_backup_tip->Hide();
|
||||||
|
img_ams_backup->Hide();
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
m_sizer_backup->Show(true);
|
if (!m_ams_backup_tip->IsShown()) {
|
||||||
|
m_ams_backup_tip->Show();
|
||||||
|
img_ams_backup->Show();
|
||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
|
void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
|
@ -2927,7 +2936,9 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
|
||||||
if (obj && !obj->get_lan_mode_connection_state()) {
|
if (obj && !obj->get_lan_mode_connection_state()) {
|
||||||
obj->command_get_version();
|
obj->command_get_version();
|
||||||
obj->command_request_push_all();
|
obj->command_request_push_all();
|
||||||
|
if (dev->get_selected_machine()->dev_id != m_printer_last_select) {
|
||||||
dev->set_selected_machine(m_printer_last_select, true);
|
dev->set_selected_machine(m_printer_last_select, true);
|
||||||
|
}
|
||||||
// Has changed machine unrecoverably
|
// Has changed machine unrecoverably
|
||||||
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
|
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
|
||||||
update_select_layout(obj);
|
update_select_layout(obj);
|
||||||
|
|
|
@ -359,6 +359,7 @@ protected:
|
||||||
Label* m_st_txt_error_desc{nullptr};
|
Label* m_st_txt_error_desc{nullptr};
|
||||||
Label* m_st_txt_extra_info{nullptr};
|
Label* m_st_txt_extra_info{nullptr};
|
||||||
Label * m_link_network_state;
|
Label * m_link_network_state;
|
||||||
|
Label* m_ams_backup_tip{nullptr};
|
||||||
wxSimplebook* m_rename_switch_panel{nullptr};
|
wxSimplebook* m_rename_switch_panel{nullptr};
|
||||||
wxSimplebook* m_simplebook{nullptr};
|
wxSimplebook* m_simplebook{nullptr};
|
||||||
wxStaticText* m_rename_text{nullptr};
|
wxStaticText* m_rename_text{nullptr};
|
||||||
|
@ -385,6 +386,7 @@ protected:
|
||||||
wxStaticBitmap * amsmapping_tip{nullptr};
|
wxStaticBitmap * amsmapping_tip{nullptr};
|
||||||
ScalableBitmap * enable_ams_mapping{nullptr};
|
ScalableBitmap * enable_ams_mapping{nullptr};
|
||||||
wxStaticBitmap * ams_tip{nullptr};
|
wxStaticBitmap * ams_tip{nullptr};
|
||||||
|
wxStaticBitmap * img_ams_backup{nullptr};
|
||||||
ScalableBitmap * enable_ams{nullptr};
|
ScalableBitmap * enable_ams{nullptr};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue