mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	ENH:filter characters not supported by windows system
Change-Id: I0dcbf9535df7bdc4b19e095aa0c23223efa5087b
This commit is contained in:
		
							parent
							
								
									fa49bdebd3
								
							
						
					
					
						commit
						d8349610f7
					
				
					 6 changed files with 52 additions and 18 deletions
				
			
		|  | @ -218,13 +218,11 @@ void PrintJob::process() | |||
|         params.filename = ""; | ||||
|     } | ||||
| 
 | ||||
|     params.dev_id = m_dev_id; | ||||
|     params.ftp_folder = m_ftp_folder; | ||||
|      | ||||
|      | ||||
|     params.filename = job_data._3mf_path.string(); | ||||
|     params.config_filename = job_data._3mf_config_path.string(); | ||||
|     params.plate_index = curr_plate_idx; | ||||
|     params.dev_id               = m_dev_id; | ||||
|     params.ftp_folder           = m_ftp_folder; | ||||
|     params.filename             = job_data._3mf_path.string(); | ||||
|     params.config_filename      = job_data._3mf_config_path.string(); | ||||
|     params.plate_index          = curr_plate_idx; | ||||
|     params.task_bed_leveling    = this->task_bed_leveling; | ||||
|     params.task_flow_cali       = this->task_flow_cali; | ||||
|     params.task_vibration_cali  = this->task_vibration_cali; | ||||
|  | @ -235,7 +233,7 @@ void PrintJob::process() | |||
|     params.connection_type      = this->connection_type; | ||||
|     params.task_use_ams         = this->task_use_ams; | ||||
|     params.task_bed_type        = this->task_bed_type; | ||||
|     params.print_type            = this->m_print_type; | ||||
|     params.print_type           = this->m_print_type; | ||||
| 
 | ||||
|     if (wxGetApp().model().model_info && wxGetApp().model().model_info.get()) { | ||||
|         ModelInfo* model_info = wxGetApp().model().model_info.get(); | ||||
|  |  | |||
|  | @ -206,12 +206,12 @@ void SendJob::process() | |||
|     else if (job_data.plate_idx == PLATE_CURRENT_IDX) | ||||
|         curr_plate_idx = m_plater->get_partplate_list().get_curr_plate_index() + 1; | ||||
| 
 | ||||
|     params.dev_id = m_dev_id; | ||||
|     params.project_name = m_project_name + ".gcode.3mf"; | ||||
|     params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name(); | ||||
|     params.filename = job_data._3mf_path.string(); | ||||
|     params.config_filename = job_data._3mf_config_path.string(); | ||||
|     params.plate_index = curr_plate_idx; | ||||
|     params.dev_id               = m_dev_id; | ||||
|     params.project_name         = m_project_name + ".gcode.3mf"; | ||||
|     params.preset_name          = wxGetApp().preset_bundle->prints.get_selected_preset_name(); | ||||
|     params.filename             = job_data._3mf_path.string(); | ||||
|     params.config_filename      = job_data._3mf_config_path.string(); | ||||
|     params.plate_index          = curr_plate_idx; | ||||
|     params.ams_mapping          = this->task_ams_mapping; | ||||
|     params.connection_type      = this->connection_type; | ||||
|     params.task_use_ams         = this->task_use_ams; | ||||
|  |  | |||
|  | @ -3365,6 +3365,19 @@ void SelectMachineDialog::set_flow_calibration_state(bool state) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| std::string SelectMachineDialog::filter_characters(const std::string& str, const std::string& filterChars) | ||||
| { | ||||
|     std::string filteredStr = str; | ||||
| 
 | ||||
|     auto removeFunc = [&filterChars](char ch) { | ||||
|         return filterChars.find(ch) != std::string::npos; | ||||
|     }; | ||||
| 
 | ||||
|     filteredStr.erase(std::remove_if(filteredStr.begin(), filteredStr.end(), removeFunc), filteredStr.end()); | ||||
| 
 | ||||
|     return filteredStr; | ||||
| } | ||||
| 
 | ||||
| void SelectMachineDialog::set_default() | ||||
| { | ||||
|     if (m_print_type == PrintFromType::FROM_NORMAL) { | ||||
|  | @ -3394,9 +3407,13 @@ void SelectMachineDialog::set_default() | |||
|         filename = m_plater->get_export_gcode_filename("", true); | ||||
|         if (filename.empty()) filename = _L("Untitled"); | ||||
|     } | ||||
| 
 | ||||
|      | ||||
|     fs::path filename_path(filename.c_str()); | ||||
|     m_current_project_name = wxString::FromUTF8(filename_path.filename().string()); | ||||
| 
 | ||||
|     //unsupported character filter
 | ||||
|     m_current_project_name = filter_characters(m_current_project_name.ToStdString(), "<>[]:/\\|?*\""); | ||||
| 
 | ||||
|     m_rename_text->SetLabelText(m_current_project_name); | ||||
|     m_rename_normal_panel->Layout(); | ||||
| 
 | ||||
|  | @ -4008,7 +4025,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e) | |||
|     wxString info_line; | ||||
|     auto     new_dev_name = m_textCtr->GetTextCtrl()->GetValue(); | ||||
| 
 | ||||
|     const char *      unusable_symbols = "@~.<>[]:/\\|?*\""; | ||||
|     const char *      unusable_symbols = "<>[]:/\\|?*\""; | ||||
|     const std::string unusable_suffix  = PresetCollection::get_suffix_modified(); | ||||
| 
 | ||||
|     for (size_t i = 0; i < std::strlen(unusable_symbols); i++) { | ||||
|  |  | |||
|  | @ -455,6 +455,7 @@ public: | |||
|     wxWindow*   create_item_checkbox(wxString title, wxWindow* parent, wxString tooltip, std::string param); | ||||
|     wxImage *   LoadImageFromBlob(const unsigned char *data, int size); | ||||
|     PrintDialogStatus  get_status() { return m_print_status; } | ||||
|     std::string filter_characters(const std::string& str, const std::string& filterChars); | ||||
|     std::vector<std::string> sort_string(std::vector<std::string> strArray); | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -778,7 +778,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event) | |||
|     m_send_job->cloud_print_only    = true; | ||||
|     m_send_job->has_sdcard          = obj_->has_sdcard(); | ||||
|     m_send_job->set_project_name(m_current_project_name.utf8_string()); | ||||
| 
 | ||||
|   | ||||
|     enable_prepare_mode = false; | ||||
| 
 | ||||
|     m_send_job->on_check_ip_address_fail([this]() { | ||||
|  | @ -1211,6 +1211,19 @@ void SendToPrinterDialog::on_dpi_changed(const wxRect &suggested_rect) | |||
|     Refresh(); | ||||
| } | ||||
| 
 | ||||
| std::string SendToPrinterDialog::filter_characters(const std::string& str, const std::string& filterChars) | ||||
| { | ||||
|     std::string filteredStr = str; | ||||
| 
 | ||||
|     auto removeFunc = [&filterChars](char ch) { | ||||
|         return filterChars.find(ch) != std::string::npos; | ||||
|     }; | ||||
| 
 | ||||
|     filteredStr.erase(std::remove_if(filteredStr.begin(), filteredStr.end(), removeFunc), filteredStr.end()); | ||||
| 
 | ||||
|     return filteredStr; | ||||
| } | ||||
| 
 | ||||
| void SendToPrinterDialog::set_default() | ||||
| { | ||||
|     //project name
 | ||||
|  | @ -1229,6 +1242,10 @@ void SendToPrinterDialog::set_default() | |||
| 
 | ||||
|     fs::path filename_path(filename.c_str()); | ||||
|     m_current_project_name = wxString::FromUTF8(filename_path.filename().string()); | ||||
| 
 | ||||
|     //unsupported character filter
 | ||||
|     m_current_project_name = filter_characters(m_current_project_name.ToStdString(), "<>[]:/\\|?*\""); | ||||
| 
 | ||||
|     m_rename_text->SetLabelText(m_current_project_name); | ||||
|     m_rename_normal_panel->Layout(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -149,10 +149,11 @@ public: | |||
| 	void show_status(PrintDialogStatus status, std::vector<wxString> params = std::vector<wxString>()); | ||||
| 	void Enable_Send_Button(bool en); | ||||
| 	void on_dpi_changed(const wxRect& suggested_rect) override; | ||||
| 	void update_user_machine_list(); | ||||
|     void update_user_machine_list(); | ||||
|     void show_print_failed_info(bool show, int code = 0, wxString description = wxEmptyString, wxString extra = wxEmptyString); | ||||
|     void update_print_error_info(int code, std::string msg, std::string extra); | ||||
|     wxString format_text(wxString& m_msg); | ||||
|     std::string filter_characters(const std::string& str, const std::string& filterChars); | ||||
| 	std::vector<std::string> sort_string(std::vector<std::string> strArray); | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 tao wang
						tao wang