diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 0204393ac..ed8bf03c7 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -13,6 +13,13 @@ namespace Slic3r { namespace GUI { wxDEFINE_EVENT(EVT_SELECTED_COLOR, wxCommandEvent); +static std::string float_to_string_with_precision(float value, int precision = 3) +{ + std::stringstream stream; + stream << std::fixed << std::setprecision(precision) << value; + return stream.str(); +} + AMSMaterialsSetting::AMSMaterialsSetting(wxWindow *parent, wxWindowID id) : DPIDialog(parent, id, _L("AMS Materials Setting"), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE) , m_color_picker_popup(ColorPickerPopup(this)) @@ -940,8 +947,8 @@ void AMSMaterialsSetting::on_select_cali_result(wxCommandEvent &evt) { m_pa_cali_select_id = evt.GetSelection(); if (m_pa_cali_select_id >= 0) { - m_input_k_val->GetTextCtrl()->SetValue(std::to_string(m_pa_profile_items[m_pa_cali_select_id].k_value)); - m_input_n_val->GetTextCtrl()->SetValue(std::to_string(m_pa_profile_items[m_pa_cali_select_id].n_coef)); + m_input_k_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[m_pa_cali_select_id].k_value)); + m_input_n_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[m_pa_cali_select_id].n_coef)); } else{ m_input_k_val->GetTextCtrl()->SetValue(std::to_string(0.00)); @@ -1030,6 +1037,8 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt) m_button_confirm->SetBorderColor(wxColour(0x90, 0x90, 0x90)); m_comboBox_cali_result->Clear(); m_comboBox_cali_result->SetValue(wxEmptyString); + m_input_k_val->GetTextCtrl()->SetValue(wxEmptyString); + m_input_n_val->GetTextCtrl()->SetValue(wxEmptyString); return; } else { @@ -1094,8 +1103,8 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt) } if (cali_select_idx >= 0) { - m_input_k_val->GetTextCtrl()->SetValue(std::to_string(m_pa_profile_items[cali_select_idx].k_value)); - m_input_n_val->GetTextCtrl()->SetValue(std::to_string(m_pa_profile_items[cali_select_idx].n_coef)); + m_input_k_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].k_value)); + m_input_n_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].n_coef)); } } else { diff --git a/src/slic3r/GUI/CaliHistoryDialog.cpp b/src/slic3r/GUI/CaliHistoryDialog.cpp index 96ba66ab1..ed6fb030e 100644 --- a/src/slic3r/GUI/CaliHistoryDialog.cpp +++ b/src/slic3r/GUI/CaliHistoryDialog.cpp @@ -711,13 +711,14 @@ void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event) return item.name == m_new_result.name && item.filament_id == m_new_result.filament_id; }); - if (iter != curr_obj->pa_calib_tab.end()) { + if (iter != m_history_results.end()) { MessageDialog msg_dlg(nullptr, wxString::Format(_L("There is already a historical calibration result with the same name: %s. Only one of the results with the same name " "is saved. Are you sure you want to override the historical result?"), m_new_result.name), wxEmptyString, wxICON_WARNING | wxYES_NO); - if (msg_dlg.ShowModal() != wxID_YES) return; + if (msg_dlg.ShowModal() != wxID_YES) + return; } }