mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	ENH:filter useless filament backups
Change-Id: Ib68a7169d2091c253b4b33457d827b3795e753cb
This commit is contained in:
		
							parent
							
								
									cb76cf3fe0
								
							
						
					
					
						commit
						3aeb66174d
					
				
					 4 changed files with 47 additions and 15 deletions
				
			
		|  | @ -1260,6 +1260,14 @@ std::vector<bool> AmsReplaceMaterialDialog::GetStatus(unsigned int status) | |||
|     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) | ||||
| { | ||||
|     if (obj) {m_obj = obj;} | ||||
|  | @ -1284,32 +1292,41 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj) | |||
|     catch (...) {} | ||||
| 
 | ||||
|     //creat group
 | ||||
|     int group_index = 1; | ||||
|     int group_index = 0; | ||||
|     for (int filam : m_obj->filam_bak) { | ||||
|          auto status_list = GetStatus(filam); | ||||
| 
 | ||||
|          std::map<std::string, wxColour> group_info; | ||||
|          std::string    group_material; | ||||
|          bool   is_in_tray = false; | ||||
| 
 | ||||
|          //get color & material
 | ||||
|          for (auto i = 0; i < status_list.size(); i++) { | ||||
|              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(); | ||||
|              } | ||||
|          } | ||||
| 
 | ||||
|          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)); | ||||
|          group_index++; | ||||
|          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++; | ||||
|          }  | ||||
|     } | ||||
| 
 | ||||
|     if (m_obj->filam_bak.size() > 0) { | ||||
|     if (group_index > 0) { | ||||
|         auto height = 0; | ||||
|         if (m_obj->filam_bak.size() > 6) { | ||||
|         if (group_index > 6) { | ||||
|             height = FromDIP(550); | ||||
|         } | ||||
|         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->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); | ||||
|     void        create(); | ||||
|     void        update_machine_obj(MachineObject* obj); | ||||
|     void        update_mapping_result(std::vector<FilamentInfo> result); | ||||
|     void        paintEvent(wxPaintEvent& evt); | ||||
|     void        on_dpi_changed(const wxRect& suggested_rect) override; | ||||
|     std::vector<bool>        GetStatus(unsigned int status); | ||||
|  | @ -295,6 +296,7 @@ public: | |||
|     wxBoxSizer* m_main_sizer{ nullptr }; | ||||
|     wxWrapSizer* m_groups_sizer{ 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_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->SetForegroundColour(wxColour(0x00AE42)); | ||||
|     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); | ||||
| 
 | ||||
|     m_sizer_backup->Add(0, 0, 1, wxEXPAND, 0); | ||||
|     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->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); }); | ||||
|     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->get_selected_machine()/* && dev->get_selected_machine()->filam_bak.size() > 0*/) { | ||||
|         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->ShowModal(); | ||||
|     } | ||||
|  | @ -2879,12 +2882,18 @@ void SelectMachineDialog::on_timer(wxTimerEvent &event) | |||
|     MachineObject* obj_ = dev->get_selected_machine(); | ||||
|     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)) { | ||||
|         m_sizer_backup->Show(false); | ||||
|         Layout(); | ||||
|         if (m_ams_backup_tip->IsShown()) { | ||||
|             m_ams_backup_tip->Hide(); | ||||
|             img_ams_backup->Hide(); | ||||
|              Layout(); | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         m_sizer_backup->Show(true); | ||||
|         Layout(); | ||||
|         if (!m_ams_backup_tip->IsShown()) { | ||||
|             m_ams_backup_tip->Show(); | ||||
|             img_ams_backup->Show(); | ||||
|             Layout(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -2927,7 +2936,9 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event) | |||
|     if (obj && !obj->get_lan_mode_connection_state()) { | ||||
|         obj->command_get_version(); | ||||
|         obj->command_request_push_all(); | ||||
|         dev->set_selected_machine(m_printer_last_select, true); | ||||
|         if (dev->get_selected_machine()->dev_id != m_printer_last_select) { | ||||
|             dev->set_selected_machine(m_printer_last_select, true); | ||||
|         } | ||||
|         // Has changed machine unrecoverably
 | ||||
|         GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); | ||||
|         update_select_layout(obj); | ||||
|  |  | |||
|  | @ -359,6 +359,7 @@ protected: | |||
|     Label*                              m_st_txt_error_desc{nullptr}; | ||||
|     Label*                              m_st_txt_extra_info{nullptr}; | ||||
|     Label *                             m_link_network_state; | ||||
|     Label*                              m_ams_backup_tip{nullptr}; | ||||
|     wxSimplebook*                       m_rename_switch_panel{nullptr}; | ||||
|     wxSimplebook*                       m_simplebook{nullptr}; | ||||
|     wxStaticText*                       m_rename_text{nullptr}; | ||||
|  | @ -385,6 +386,7 @@ protected: | |||
|     wxStaticBitmap *                    amsmapping_tip{nullptr}; | ||||
|     ScalableBitmap *                    enable_ams_mapping{nullptr}; | ||||
|     wxStaticBitmap *                    ams_tip{nullptr}; | ||||
|     wxStaticBitmap *                    img_ams_backup{nullptr}; | ||||
|     ScalableBitmap *                    enable_ams{nullptr}; | ||||
| 
 | ||||
| public: | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tao wang
						tao wang