FIX: Unable to edit existing flow calibration result

github: 6274
Change-Id: I96ef3e2f62a28ee8343c25799a75ddc940948c18
This commit is contained in:
zhimin.zeng 2025-03-31 17:06:38 +08:00 committed by lane.wei
parent 09313c8542
commit 27f60bd85b
2 changed files with 18 additions and 14 deletions

View File

@ -491,6 +491,7 @@ EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow
: DPIDialog(parent, wxID_ANY, _L("Edit Flow Dynamics Calibration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE) : DPIDialog(parent, wxID_ANY, _L("Edit Flow Dynamics Calibration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
, m_new_result(result) , m_new_result(result)
, m_history_results(history_results) , m_history_results(history_results)
, m_old_name(result.name)
{ {
curr_obj = obj; curr_obj = obj;
@ -617,6 +618,7 @@ void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) {
m_k_value->GetTextCtrl()->SetValue(k_str); m_k_value->GetTextCtrl()->SetValue(k_str);
m_new_result.k_value = k; m_new_result.k_value = k;
if (m_new_result.name != m_old_name) {
auto iter = std::find_if(m_history_results.begin(), m_history_results.end(), [this](const PACalibResult &item) { auto iter = std::find_if(m_history_results.begin(), m_history_results.end(), [this](const PACalibResult &item) {
bool has_same_name = item.name == m_new_result.name && item.filament_id == m_new_result.filament_id; bool has_same_name = item.name == m_new_result.name && item.filament_id == m_new_result.filament_id;
if (curr_obj && curr_obj->is_multi_extruders()) { if (curr_obj && curr_obj->is_multi_extruders()) {
@ -626,13 +628,14 @@ void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) {
}); });
if (iter != m_history_results.end()) { if (iter != m_history_results.end()) {
wxString duplicate_name_info = wxString::Format( wxString duplicate_name_info = wxString::Format(_L("Within the same extruder, the name '%s' must be unique when the filament type, nozzle diameter, and nozzle flow "
_L("Within the same extruder, the name '%s' must be unique when the filament type, nozzle diameter, and nozzle flow are identical. Please choose a different name."), "are identical. Please choose a different name."),
m_new_result.name); m_new_result.name);
MessageDialog msg_dlg(nullptr, duplicate_name_info, wxEmptyString, wxICON_WARNING | wxOK); MessageDialog msg_dlg(nullptr, duplicate_name_info, wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal(); msg_dlg.ShowModal();
return; return;
} }
}
EndModal(wxID_OK); EndModal(wxID_OK);
} }

View File

@ -54,6 +54,7 @@ protected:
virtual void on_cancel(wxCommandEvent& event); virtual void on_cancel(wxCommandEvent& event);
protected: protected:
std::string m_old_name;
PACalibResult m_new_result; PACalibResult m_new_result;
std::vector<PACalibResult> m_history_results; std::vector<PACalibResult> m_history_results;
const MachineObject * curr_obj; const MachineObject * curr_obj;