mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 20:51:12 -06:00 
			
		
		
		
	ENH:popup msg for user when printing with unknown filaments
Change-Id: Ic1dfa9d70e7bd5ed0e4220b718e261ecf4ef64a8
This commit is contained in:
		
							parent
							
								
									64ae3c3a56
								
							
						
					
					
						commit
						06ac3f73a6
					
				
					 4 changed files with 94 additions and 20 deletions
				
			
		|  | @ -334,6 +334,48 @@ void AmsMapingPopup::update_ams_data(std::map<std::string, Ams*> amsList) | |||
|     Fit(); | ||||
| } | ||||
| 
 | ||||
| std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(std::map<std::string, Ams*> amsList) | ||||
| { | ||||
|     std::vector<TrayData> m_tray_data; | ||||
|     std::map<std::string, Ams *>::iterator ams_iter; | ||||
| 
 | ||||
|     for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) { | ||||
| 
 | ||||
|         BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str(); | ||||
| 
 | ||||
|         auto ams_indx = atoi(ams_iter->first.c_str()); | ||||
|         Ams* ams_group = ams_iter->second; | ||||
|         std::vector<TrayData>                      tray_datas; | ||||
|         std::map<std::string, AmsTray*>::iterator tray_iter; | ||||
| 
 | ||||
|         for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) { | ||||
|             AmsTray* tray_data = tray_iter->second; | ||||
|             TrayData td; | ||||
| 
 | ||||
|             td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str()); | ||||
| 
 | ||||
|             if (!tray_data->is_exists) { | ||||
|                 td.type = EMPTY; | ||||
|             } | ||||
|             else { | ||||
|                 if (!tray_data->is_tray_info_ready()) { | ||||
|                     td.type = THIRD; | ||||
|                 } | ||||
|                 else { | ||||
|                     td.type = NORMAL; | ||||
|                     td.colour = AmsTray::decode_color(tray_data->color); | ||||
|                     td.name = tray_data->get_display_filament_type(); | ||||
|                     td.filament_type = tray_data->get_filament_type(); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             m_tray_data.push_back(td); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return m_tray_data; | ||||
| } | ||||
| 
 | ||||
| void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data) | ||||
| {  | ||||
|     auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL); | ||||
|  |  | |||
|  | @ -134,7 +134,8 @@ public: | |||
|     void         on_left_down(wxMouseEvent &evt); | ||||
|     virtual void OnDismiss() wxOVERRIDE; | ||||
|     virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE; | ||||
|     void paintEvent(wxPaintEvent &evt); | ||||
|     void         paintEvent(wxPaintEvent &evt); | ||||
|     std::vector<TrayData> parse_ams_mapping(std::map<std::string, Ams*> amsList); | ||||
| }; | ||||
| 
 | ||||
| class AmsMapingTipPopup : public wxPopupTransientWindow | ||||
|  |  | |||
|  | @ -370,7 +370,7 @@ SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent, wxWindowID id, cons | |||
|     StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered), | ||||
|         std::pair<wxColour, int>(*wxWHITE, StateColor::Normal)); | ||||
| 
 | ||||
|     m_button_ok = new Button(this, _L("OK")); | ||||
|     m_button_ok = new Button(this, _L("Confirm")); | ||||
|     m_button_ok->SetBackgroundColor(btn_bg_green); | ||||
|     m_button_ok->SetBorderColor(*wxWHITE); | ||||
|     m_button_ok->SetTextColor(*wxWHITE); | ||||
|  | @ -414,8 +414,9 @@ SecondaryCheckDialog::SecondaryCheckDialog(wxWindow* parent, wxWindowID id, cons | |||
|     sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5)); | ||||
| 
 | ||||
| 
 | ||||
|     m_sizer_right->Add(m_vebview_release_note, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(20)); | ||||
|     m_sizer_right->Add(sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(20)); | ||||
|     m_sizer_right->Add(m_vebview_release_note, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(35)); | ||||
|     m_sizer_right->Add(sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(35)); | ||||
|     m_sizer_right->Add(0, 0, 0, wxTOP,FromDIP(18)); | ||||
| 
 | ||||
| 
 | ||||
|     SetSizer(m_sizer_right); | ||||
|  |  | |||
|  | @ -1773,38 +1773,68 @@ bool SelectMachineDialog::is_same_printer_model() | |||
| 
 | ||||
| void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) | ||||
| { | ||||
|     wxString confirm_text = _L("Please check the following infomation and click Confirm to continue sending print:\n"); | ||||
|     std::vector<wxString> confirm_text; | ||||
|     confirm_text.push_back(_L("Please check the following infomation and click Confirm to continue sending print:\n")); | ||||
| 
 | ||||
|     //Check Printer Model Id
 | ||||
|     bool is_same_printer_type = is_same_printer_model(); | ||||
|     if (!is_same_printer_type) | ||||
|         confirm_text += _L("The printer type used to generate G-code is not the same type as the currently selected physical printer. It is recommend to re-slice by selecting the same printer type.\n"); | ||||
|         confirm_text.push_back(_L("The printer type used to generate G-code is not the same type as the currently selected physical printer. It is recommend to re-slice by selecting the same printer type.\n")); | ||||
| 
 | ||||
|     //Check slice warnings
 | ||||
|     bool has_slice_warnings = false; | ||||
|     PartPlate* plate = m_plater->get_partplate_list().get_curr_plate(); | ||||
|     DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); | ||||
|     if (dev) { | ||||
|         MachineObject* obj_ = dev->get_selected_machine(); | ||||
|         for (auto warning : plate->get_slice_result()->warnings) { | ||||
|             if (warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) { | ||||
|                 if ((obj_->printer_type == "BL-P001" || obj_->printer_type == "BL-P002")) { | ||||
|                     confirm_text += Plater::get_slice_warning_string(warning) + "\n"; | ||||
|                     has_slice_warnings = true; | ||||
|                 } | ||||
|             } | ||||
|             else { | ||||
| 
 | ||||
|     if(!dev) return; | ||||
| 
 | ||||
|     MachineObject* obj_ = dev->get_selected_machine(); | ||||
|     for (auto warning : plate->get_slice_result()->warnings) { | ||||
|         if (warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) { | ||||
|             if ((obj_->printer_type == "BL-P001" || obj_->printer_type == "BL-P002")) { | ||||
|                 confirm_text.push_back(Plater::get_slice_warning_string(warning) + "\n"); | ||||
|                 has_slice_warnings = true; | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             has_slice_warnings = true; | ||||
|         } | ||||
|     } | ||||
|   | ||||
| 
 | ||||
|     //check for unidentified material
 | ||||
|     auto mapping_result = m_mapping_popup.parse_ams_mapping(obj_->amsList); | ||||
|     auto has_unknown_filament = false; | ||||
| 
 | ||||
|     for (auto i = 0; i < m_ams_mapping_result.size(); i++) { | ||||
|         auto tid = m_ams_mapping_result[i].tray_id; | ||||
|         for (auto miter : mapping_result) { | ||||
|             //matching
 | ||||
|             if (miter.id == tid) { | ||||
|                 if (miter.type == TrayType::THIRD || miter.type == TrayType::EMPTY) { | ||||
|                     has_unknown_filament = true; | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (!is_same_printer_type | ||||
|         || has_slice_warnings | ||||
|         ) { | ||||
|     if (has_unknown_filament) { | ||||
|         has_slice_warnings = true; | ||||
|         confirm_text.push_back(_L("There are some unknown filaments in the AMS mappings. Please check whether they are the required filaments. If they are okay, press \"Confirm\" to start printing.") + "\n"); | ||||
|     } | ||||
| 
 | ||||
|     if (!is_same_printer_type || has_slice_warnings) { | ||||
|         wxString confirm_title = _L("Warning"); | ||||
|         SecondaryCheckDialog confirm_dlg(this, wxID_ANY, confirm_title); | ||||
|         confirm_dlg.update_text(confirm_text); | ||||
|         wxString info_msg = wxEmptyString; | ||||
| 
 | ||||
|         for (auto i = 0; i < confirm_text.size(); i++) { | ||||
|             if (i == 0) | ||||
|                 continue; | ||||
|             info_msg += wxString::Format("%d:%s\n",i, confirm_text[i]); | ||||
|         } | ||||
|         confirm_dlg.update_text(info_msg); | ||||
|         if (confirm_dlg.ShowModal() == wxID_YES) { | ||||
|             this->on_ok(); | ||||
|         } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tao wang
						tao wang