mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	FIX: fix some display problem
1. check the flow rate save name valid 2. fix the crash when saving with Chinese symbols 3. handle the display of Chinese symbols Change-Id: I3abe99ba17b2cc5893431d48de11a9597bf489a6
This commit is contained in:
		
							parent
							
								
									2e208063f6
								
							
						
					
					
						commit
						44b232bcae
					
				
					 4 changed files with 37 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -23,9 +23,9 @@ static wxString get_preset_name_by_filament_id(std::string filament_id)
 | 
			
		|||
    for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
 | 
			
		||||
        if (filament_id.compare(it->filament_id) == 0) {
 | 
			
		||||
            if (!it->alias.empty())
 | 
			
		||||
                preset_name = it->alias;
 | 
			
		||||
                preset_name = from_u8(it->alias);
 | 
			
		||||
            else
 | 
			
		||||
                preset_name = it->name;
 | 
			
		||||
                preset_name = from_u8(it->name);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return preset_name;
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +220,7 @@ void HistoryWindow::sync_history_data() {
 | 
			
		|||
 | 
			
		||||
    int i = 1;
 | 
			
		||||
    for (auto& result : m_calib_results_history) {
 | 
			
		||||
        auto name_value = new wxStaticText(m_history_data_panel, wxID_ANY, result.name);
 | 
			
		||||
        auto name_value = new wxStaticText(m_history_data_panel, wxID_ANY, from_u8(result.name));
 | 
			
		||||
 | 
			
		||||
        wxString preset_name = get_preset_name_by_filament_id(result.filament_id);
 | 
			
		||||
        auto preset_name_value = new wxStaticText(m_history_data_panel, wxID_ANY, preset_name);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,20 @@ wxDEFINE_EVENT(EVT_CALIBRATION_JOB_FINISHED, wxCommandEvent);
 | 
			
		|||
 | 
			
		||||
static const wxString NA_STR = _L("N/A");
 | 
			
		||||
 | 
			
		||||
bool check_preset_name_valid(const wxString& name) {
 | 
			
		||||
    wxString error_message;
 | 
			
		||||
    if (name.IsEmpty()) {
 | 
			
		||||
        error_message = _L("Please enter the name you want to save to printer.");
 | 
			
		||||
    } else if (name.Length() > 40) {
 | 
			
		||||
        error_message = _L("The name cannot exceed 40 characters.");
 | 
			
		||||
    }
 | 
			
		||||
    if (!error_message.IsEmpty()) {
 | 
			
		||||
        MessageDialog error_msg_dlg(nullptr, error_message, wxEmptyString, wxICON_WARNING | wxOK);
 | 
			
		||||
        error_msg_dlg.ShowModal();
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
CalibrationWizard::CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
 | 
			
		||||
    : wxPanel(parent, id, pos, size, style) 
 | 
			
		||||
| 
						 | 
				
			
			@ -889,6 +903,7 @@ void FlowRateWizard::on_cali_save()
 | 
			
		|||
            {
 | 
			
		||||
                auto coarse_save_page = static_cast<CalibrationFlowCoarseSavePage*>(m_curr_step->page);
 | 
			
		||||
                if (!coarse_save_page->get_result(&new_flow_ratio, &new_preset_name)) {
 | 
			
		||||
                    BOOST_LOG_TRIVIAL(info) << "flow_rate_cali: get coarse result failed";
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -896,12 +911,18 @@ void FlowRateWizard::on_cali_save()
 | 
			
		|||
            {
 | 
			
		||||
                auto fine_save_page = static_cast<CalibrationFlowFineSavePage*>(m_curr_step->page);
 | 
			
		||||
                if (!fine_save_page->get_result(&new_flow_ratio, &new_preset_name)) {
 | 
			
		||||
                    BOOST_LOG_TRIVIAL(info) << "flow_rate_cali: get fine result failed";
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            else {
 | 
			
		||||
                BOOST_LOG_TRIVIAL(info) << "flow_rate_cali: get result failed, not get result";
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (!check_preset_name_valid(new_preset_name))
 | 
			
		||||
                return;
 | 
			
		||||
 | 
			
		||||
            std::string old_preset_name;
 | 
			
		||||
            CalibrationPresetPage* preset_page = (static_cast<CalibrationPresetPage*>(preset_step->page));
 | 
			
		||||
            std::map<int, Preset*> selected_filaments = preset_page->get_selected_filaments();
 | 
			
		||||
| 
						 | 
				
			
			@ -912,7 +933,7 @@ void FlowRateWizard::on_cali_save()
 | 
			
		|||
            key_value_map.insert(std::make_pair("filament_flow_ratio", new ConfigOptionFloats{ new_flow_ratio }));
 | 
			
		||||
 | 
			
		||||
            std::string message;
 | 
			
		||||
            if (!save_preset(old_preset_name, new_preset_name.ToStdString(), key_value_map, message)) {
 | 
			
		||||
            if (!save_preset(old_preset_name, into_u8(new_preset_name), key_value_map, message)) {
 | 
			
		||||
                MessageDialog error_msg_dlg(nullptr, message, wxEmptyString, wxICON_WARNING | wxOK);
 | 
			
		||||
                error_msg_dlg.ShowModal();
 | 
			
		||||
                return;
 | 
			
		||||
| 
						 | 
				
			
			@ -1177,9 +1198,13 @@ void MaxVolumetricSpeedWizard::on_cali_save()
 | 
			
		|||
    double value = 0;
 | 
			
		||||
    CalibrationMaxVolumetricSpeedSavePage *save_page = (static_cast<CalibrationMaxVolumetricSpeedSavePage *>(save_step->page));
 | 
			
		||||
    if (!save_page->get_save_result(value, new_preset_name)) {
 | 
			
		||||
        BOOST_LOG_TRIVIAL(info) << "max_volumetric_speed_cali: get result failed";
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!check_preset_name_valid(new_preset_name))
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    std::map<std::string, ConfigOption *> key_value_map;
 | 
			
		||||
    key_value_map.insert(std::make_pair("filament_max_volumetric_speed", new ConfigOptionFloats{ value }));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,9 +12,9 @@ static wxString get_default_name(wxString filament_name, CalibMode mode){
 | 
			
		|||
    for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
 | 
			
		||||
        if (filament_name.compare(it->name) == 0) {
 | 
			
		||||
            if (!it->alias.empty())
 | 
			
		||||
                filament_name = it->alias;
 | 
			
		||||
                filament_name = from_u8(it->alias);
 | 
			
		||||
            else
 | 
			
		||||
                filament_name = it->name;
 | 
			
		||||
                filament_name = from_u8(it->name);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -347,7 +347,7 @@ void CaliPASaveAutoPanel::save_to_result_from_widgets(wxWindow* window, bool* ou
 | 
			
		|||
            *out_msg = _L("The name cannot exceed 40 characters.");
 | 
			
		||||
            *out_is_valid = false;
 | 
			
		||||
        }
 | 
			
		||||
        m_calib_results[tray_id].name = name.ToStdString();
 | 
			
		||||
        m_calib_results[tray_id].name = into_u8(name);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    auto childern = window->GetChildren();
 | 
			
		||||
| 
						 | 
				
			
			@ -503,7 +503,7 @@ bool CaliPASaveManualPanel::get_result(PACalibResult& out_result) {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    out_result.k_value = k;
 | 
			
		||||
    out_result.name = name.ToStdString();
 | 
			
		||||
    out_result.name = into_u8(name);
 | 
			
		||||
    if (m_obj) {
 | 
			
		||||
        assert(m_obj->selected_cali_preset.size() <= 1);
 | 
			
		||||
        if (!m_obj->selected_cali_preset.empty()) {
 | 
			
		||||
| 
						 | 
				
			
			@ -679,7 +679,7 @@ void CaliSavePresetValuePanel::get_value(double& value)
 | 
			
		|||
 | 
			
		||||
void CaliSavePresetValuePanel::get_save_name(std::string& name)
 | 
			
		||||
{ 
 | 
			
		||||
    name = m_input_name->GetTextCtrl()->GetValue().ToStdString(); 
 | 
			
		||||
    name = into_u8(m_input_name->GetTextCtrl()->GetValue()); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CaliSavePresetValuePanel::set_save_name(const std::string& name)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -316,6 +316,9 @@ void CalibUtils::calib_flowrate_X1C(const X1CCalibInfos& calib_infos, std::strin
 | 
			
		|||
 | 
			
		||||
    if (calib_infos.calib_datas.size() > 0)
 | 
			
		||||
        obj_->command_start_flow_ratio_calibration(calib_infos);
 | 
			
		||||
    else {
 | 
			
		||||
        BOOST_LOG_TRIVIAL(info) << "flow_rate_cali: auto | send info | cali_datas is empty.";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CalibUtils::emit_get_flow_ratio_calib_results(float nozzle_diameter)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue