FIX: fix some cali bug
In some cases, the PA value cannot be saved successfully jira: STUDIO-8832, STUDIO-8826, STUDIO-8825, STUDIO-8822, STUDIO-8821 Change-Id: I74cd2c6039c104f5e1ef1d03440e0b1914480d62
This commit is contained in:
parent
242554557b
commit
482af1849b
|
@ -417,7 +417,7 @@ void CalibrationWizard::cache_preset_info(MachineObject* obj, float nozzle_dia)
|
|||
int ams_id, slot_id, tray_id;
|
||||
get_tray_ams_and_slot_id(result.extruder_id, ams_id, slot_id, tray_id);
|
||||
result.extruder_id = preset_page->get_extruder_id(ams_id);
|
||||
result.nozzle_volume_type = preset_page->get_nozzle_volume_type(ams_id);
|
||||
result.nozzle_volume_type = preset_page->get_nozzle_volume_type(result.extruder_id);
|
||||
}
|
||||
else {
|
||||
result.extruder_id = 0;
|
||||
|
@ -848,6 +848,27 @@ bool PressureAdvanceWizard::can_save_cali_result(const std::vector<PACalibResult
|
|||
if (!curr_obj)
|
||||
return false;
|
||||
|
||||
std::vector<PACalibResult> to_save_result;
|
||||
for (auto &result : new_pa_cali_results) {
|
||||
auto iter = std::find_if(to_save_result.begin(), to_save_result.end(), [this, &result](const PACalibResult &item) {
|
||||
bool has_same_name = (item.name == result.name && item.filament_id == result.filament_id);
|
||||
if (curr_obj && curr_obj->is_multi_extruders()) {
|
||||
has_same_name &= (item.extruder_id == result.extruder_id && item.nozzle_volume_type == result.nozzle_volume_type);
|
||||
}
|
||||
return has_same_name;
|
||||
});
|
||||
if (iter != to_save_result.end()) {
|
||||
MessageDialog msg_dlg(nullptr, wxString::Format(_L("Only one of the results with the same name: %s will be saved. Are you sure you want to override the other results?"), iter->name), wxEmptyString,
|
||||
wxICON_WARNING | wxYES_NO);
|
||||
if (msg_dlg.ShowModal() != wxID_YES) {
|
||||
return false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
to_save_result.push_back(result);
|
||||
}
|
||||
|
||||
std::string same_pa_names;
|
||||
for (auto new_pa_cali_result : new_pa_cali_results) {
|
||||
auto iter = std::find_if(curr_obj->pa_calib_tab.begin(), curr_obj->pa_calib_tab.end(), [this, &new_pa_cali_result](const PACalibResult &item) {
|
||||
|
@ -861,12 +882,12 @@ bool PressureAdvanceWizard::can_save_cali_result(const std::vector<PACalibResult
|
|||
|
||||
if (iter != curr_obj->pa_calib_tab.end()) {
|
||||
same_pa_names += new_pa_cali_result.name;
|
||||
same_pa_names += ",";
|
||||
same_pa_names += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
if (!same_pa_names.empty()) {
|
||||
same_pa_names.pop_back();
|
||||
same_pa_names.erase(same_pa_names.size() - 2);
|
||||
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?"), same_pa_names), wxEmptyString, wxICON_WARNING | wxYES_NO);
|
||||
if (msg_dlg.ShowModal() != wxID_YES)
|
||||
|
|
|
@ -55,7 +55,7 @@ static wxString get_default_name(wxString filament_name, CalibMode mode){
|
|||
static wxString get_tray_name_by_tray_id(int tray_id)
|
||||
{
|
||||
wxString tray_name;
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID) {
|
||||
if (tray_id == VIRTUAL_TRAY_MAIN_ID || tray_id == VIRTUAL_TRAY_DEPUTY_ID) {
|
||||
tray_name = "Ext";
|
||||
}
|
||||
else {
|
||||
|
@ -405,6 +405,7 @@ bool CaliPASaveAutoPanel::get_result(std::vector<PACalibResult>& out_result) {
|
|||
// Check if the input value is valid and save to m_calib_results
|
||||
save_to_result_from_widgets(m_grid_panel, &is_valid, &err_msg);
|
||||
if (is_valid) {
|
||||
/*
|
||||
std::vector<PACalibResult> to_save_result;
|
||||
for (auto &result : m_calib_results) {
|
||||
auto iter = std::find_if(to_save_result.begin(), to_save_result.end(), [this, &result](const PACalibResult &item) {
|
||||
|
@ -437,8 +438,7 @@ bool CaliPASaveAutoPanel::get_result(std::vector<PACalibResult>& out_result) {
|
|||
|
||||
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?"),
|
||||
wxString::Format(_L("There is already a historical calibration result with the same name: %s. Are you sure you want to override the historical result?"),
|
||||
result.name),
|
||||
wxEmptyString, wxICON_WARNING | wxYES_NO);
|
||||
if (msg_dlg.ShowModal() != wxID_YES) {
|
||||
|
@ -446,6 +446,7 @@ bool CaliPASaveAutoPanel::get_result(std::vector<PACalibResult>& out_result) {
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for (auto& result : m_calib_results) {
|
||||
out_result.push_back(result.second);
|
||||
|
@ -481,6 +482,9 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
for (auto &item : cali_result) {
|
||||
if (item.confidence == 0) {
|
||||
int tray_id = 4 * item.ams_id + item.slot_id;
|
||||
if (item.ams_id == VIRTUAL_TRAY_MAIN_ID || item.ams_id == VIRTUAL_TRAY_DEPUTY_ID) {
|
||||
tray_id = item.ams_id;
|
||||
}
|
||||
m_calib_results[tray_id] = item;
|
||||
}
|
||||
}
|
||||
|
@ -531,6 +535,7 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
|
||||
std::vector<std::pair<int, std::string>> preset_names;
|
||||
int i = 1;
|
||||
std::unordered_set<std::string> set;
|
||||
for (auto &info : m_obj->selected_cali_preset) {
|
||||
std::string default_name;
|
||||
// extruder _id
|
||||
|
@ -566,7 +571,6 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
// filament_id
|
||||
{
|
||||
default_name += "_";
|
||||
std::unordered_set<std::string> set;
|
||||
default_name += get_default_name(info.name, CalibMode::Calib_PA_Line).ToUTF8().data();
|
||||
if (!set.insert(default_name).second) {
|
||||
default_name += "_" + std::to_string(i);
|
||||
|
@ -579,7 +583,11 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
|
||||
bool left_first_add_item = true;
|
||||
bool right_first_add_item = true;
|
||||
for (auto &item : cali_result) {
|
||||
std::vector<PACalibResult> sorted_cali_result = cali_result;
|
||||
std::sort(sorted_cali_result.begin(), sorted_cali_result.end(), [](const PACalibResult &left, const PACalibResult &right) {
|
||||
return left.tray_id < right.tray_id;
|
||||
});
|
||||
for (auto &item : sorted_cali_result) {
|
||||
bool result_failed = false;
|
||||
if (item.confidence != 0) {
|
||||
result_failed = true;
|
||||
|
|
Loading…
Reference in New Issue