FIX:display printer name when sending from storage

Change-Id: Ib26cb305468c96052e58b14e3b415ff2cd3a53d7
This commit is contained in:
tao wang 2024-12-22 13:36:47 +08:00 committed by lane.wei
parent 0cccc282c6
commit d78f7d6ca7
1 changed files with 73 additions and 43 deletions

View File

@ -338,6 +338,12 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_comboBox_printer->SetMaxSize(wxSize(FromDIP(250), FromDIP(60)));
m_comboBox_printer->SetBackgroundColor(*wxWHITE);
m_comboBox_printer->Bind(wxEVT_COMBOBOX, &SelectMachineDialog::on_selection_changed, this);
m_comboBox_printer->Bind(wxEVT_LEFT_DOWN, [=](auto& e) {
if (m_print_type != PrintFromType::FROM_SDCARD_VIEW) {e.Skip();}
});
m_comboBox_printer->Bind(wxEVT_LEFT_UP, [=](auto &e) {
if (m_print_type != PrintFromType::FROM_SDCARD_VIEW) {e.Skip();}
});
m_btn_bg_enable = StateColor(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
@ -1185,7 +1191,6 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_)
const auto& project_config = wxGetApp().preset_bundle->project_config;
size_t nozzle_nums = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size();
m_filaments_map = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_real_filament_maps(project_config);
int filament_result = 0;
std::vector<bool> map_opt; //four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
if (nozzle_nums > 1){
@ -1199,10 +1204,13 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_)
BOOST_LOG_TRIVIAL(info) << "m_filaments_map.size()" << m_filaments_map.size();
return false;
}
if (m_filaments_map[it->id] == 1)
m_filament_left.push_back(*it);
else if (m_filaments_map[it->id] == 2)
m_filament_right.push_back(*it);
if (it->id < m_filaments_map.size()) {
if (m_filaments_map[it->id] == 1)
m_filament_left.push_back(*it);
else if (m_filaments_map[it->id] == 2)
m_filament_right.push_back(*it);
}
}
bool has_left_ams = false, has_right_ams = false;
@ -3330,7 +3338,7 @@ void SelectMachineDialog::update_show_status()
size_t nozzle_nums = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size();
//the nozzle type of preset and machine are different
if (nozzle_nums > 1) {
if (nozzle_nums > 1 && m_print_type == FROM_NORMAL) {
if (!obj_->is_nozzle_data_invalid()) {
show_status(PrintDialogStatus::PrintStatusNozzleDataInvalid);
return;
@ -3365,28 +3373,25 @@ void SelectMachineDialog::update_show_status()
}
// check ams and vt_slot mix use status
struct ExtruderStatus
{
struct ExtruderStatus
{
bool has_ams{false};
bool has_vt_slot{false};
};
std::vector<ExtruderStatus> extruder_status(nozzle_nums);
for (const FilamentInfo &item : m_ams_mapping_result) {
if (item.ams_id.empty())
continue;
bool has_ams{false};
bool has_vt_slot{false};
};
std::vector<ExtruderStatus> extruder_status(nozzle_nums);
for (const FilamentInfo &item : m_ams_mapping_result) {
if (item.ams_id.empty()) continue;
int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id);
if (DeviceManager::is_virtual_slot(stoi(item.ams_id)))
extruder_status[extruder_id].has_vt_slot = true;
else
extruder_status[extruder_id].has_ams = true;
}
for (auto extruder : extruder_status) {
if (extruder.has_ams && extruder.has_vt_slot) {
show_status(PrintDialogStatus::PrintStatusMixAmsAndVtSlotWarning);
return;
}
int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id);
if (DeviceManager::is_virtual_slot(stoi(item.ams_id)))
extruder_status[extruder_id].has_vt_slot = true;
else
extruder_status[extruder_id].has_ams = true;
}
for (auto extruder : extruder_status) {
if (extruder.has_ams && extruder.has_vt_slot) {
show_status(PrintDialogStatus::PrintStatusMixAmsAndVtSlotWarning);
return;
}
}
@ -3580,7 +3585,7 @@ void SelectMachineDialog::set_default()
}
else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW) {
m_stext_printer_title->Show(false);
m_comboBox_printer->Show(false);
m_comboBox_printer->Show(true);
m_button_refresh->Show(false);
m_rename_normal_panel->Show(false);
m_hyperlink->Show(false);
@ -4157,6 +4162,14 @@ void SelectMachineDialog::set_default_normal(const ThumbnailData &data)
void SelectMachineDialog::set_default_from_sdcard()
{
DeviceManager *dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev_manager) return;
MachineObject *obj_ = dev_manager->get_selected_machine();
if (!obj_) { return; };
m_comboBox_printer->SetValue(obj_->dev_name);
m_print_plate_total = m_required_data_plate_data_list.size();
update_page_turn_state(true);
@ -4181,6 +4194,33 @@ void SelectMachineDialog::set_default_from_sdcard()
brands.push_back(fo.brand);
}
// ams mapping area
if (obj_->m_extder_data.total_extder_count > 1) {
m_filament_left_panel->Show();
m_filament_right_panel->Show();
m_filament_panel->Hide();
m_sizer_ams_mapping_left->SetCols(4);
m_sizer_ams_mapping_left->Layout();
m_filament_panel_left_sizer->Layout();
m_filament_left_panel->Layout();
m_sizer_ams_mapping_right->SetCols(4);
m_sizer_ams_mapping_right->Layout();
m_filament_panel_right_sizer->Layout();
m_filament_right_panel->Layout();
m_mapping_popup.set_show_type(ShowType::LEFT_AND_RIGHT);
} else {
m_filament_left_panel->Hide();
m_filament_right_panel->Hide();
m_filament_panel->Show();
m_sizer_ams_mapping->SetCols(8);
m_sizer_ams_mapping->Layout();
m_filament_panel_sizer->Layout();
m_mapping_popup.set_show_type(ShowType::RIGHT);
}
//init MaterialItem
MaterialHash::iterator iter = m_materialList.begin();
while (iter != m_materialList.end()) {
@ -4196,7 +4236,6 @@ void SelectMachineDialog::set_default_from_sdcard()
m_materialList.clear();
m_filaments.clear();
for (auto i = 0; i < m_required_data_plate_data_list[m_print_plate_idx]->slice_filaments_info.size(); i++) {
FilamentInfo fo = m_required_data_plate_data_list[m_print_plate_idx]->slice_filaments_info[i];
@ -4204,7 +4243,7 @@ void SelectMachineDialog::set_default_from_sdcard()
m_sizer_ams_mapping->Add(item, 0, wxALL, FromDIP(5));
item->Bind(wxEVT_LEFT_UP, [this, item, materials](wxMouseEvent& e) {});
item->Bind(wxEVT_LEFT_DOWN, [this, item, materials, fo](wxMouseEvent& e) {
item->Bind(wxEVT_LEFT_DOWN, [this, obj_, item, materials, fo](wxMouseEvent& e) {
MaterialHash::iterator iter = m_materialList.begin();
while (iter != m_materialList.end()) {
int id = iter->first;
@ -4223,10 +4262,6 @@ void SelectMachineDialog::set_default_from_sdcard()
auto mouse_pos = ClientToScreen(e.GetPosition());
wxPoint rect = item->ClientToScreen(wxPoint(0, 0));
// update ams data
DeviceManager* dev_manager = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev_manager) return;
MachineObject* obj_ = dev_manager->get_selected_machine();
if (obj_ && obj_->is_support_ams_mapping()) {
if (m_mapping_popup.IsShown()) return;
@ -4242,6 +4277,7 @@ void SelectMachineDialog::set_default_from_sdcard()
m_mapping_popup.set_parent_item(item);
m_mapping_popup.set_current_filament_id(fo.id);
m_mapping_popup.set_tag_texture(fo.type);
m_mapping_popup.set_send_win(this);
m_mapping_popup.update(obj_);
m_mapping_popup.Popup();
}
@ -4423,17 +4459,11 @@ void SelectMachineDialog::update_lan_machine_list()
if (!mobj->is_avaliable()) continue;
if (!mobj->is_online()) continue;
if (!mobj->is_lan_mode_printer()) continue;
if (mobj->has_access_right()) {
auto b = mobj->dev_name;
// clear machine list
//m_comboBox_printer->Clear();
std::vector<std::string> machine_list;
wxArrayString machine_list_name;
std::map<std::string, MachineObject*> option_list;
}
std::vector<std::string> machine_list;
wxArrayString machine_list_name;
std::map<std::string, MachineObject *> option_list;
}
}
BOOST_LOG_TRIVIAL(trace) << "SelectMachineDialog update_lan_devices end";