FIX: modify for cali
1. add repeat pa name check 2. display tray icon in save page 3. incorrect extruder id for left virtual slot 4. fix crash when enter save page jira:none Change-Id: Iae00788094d182ae84fff2aa71fedbb35ea938c6
This commit is contained in:
parent
7bcf4b6cc5
commit
be256c0a6d
|
@ -841,6 +841,45 @@ void PressureAdvanceWizard::on_cali_start()
|
|||
cali_page->clear_last_job_status();
|
||||
}
|
||||
|
||||
bool PressureAdvanceWizard::can_save_cali_result(const std::vector<PACalibResult> &new_pa_cali_results)
|
||||
{
|
||||
if (!curr_obj)
|
||||
return false;
|
||||
|
||||
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) {
|
||||
bool is_same_name = (item.name == new_pa_cali_result.name && item.filament_id == new_pa_cali_result.filament_id &&
|
||||
item.nozzle_diameter == new_pa_cali_result.nozzle_diameter);
|
||||
if (curr_obj && curr_obj->is_multi_extruders()) {
|
||||
is_same_name &= (item.extruder_id == new_pa_cali_result.extruder_id && item.nozzle_volume_type == new_pa_cali_result.nozzle_volume_type);
|
||||
}
|
||||
return is_same_name;
|
||||
});
|
||||
|
||||
if (iter != curr_obj->pa_calib_tab.end()) {
|
||||
same_pa_names += new_pa_cali_result.name;
|
||||
same_pa_names += ",";
|
||||
}
|
||||
}
|
||||
|
||||
if (!same_pa_names.empty()) {
|
||||
same_pa_names.pop_back();
|
||||
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)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (curr_obj->get_printer_series() != PrinterSeries::SERIES_X1 && curr_obj->pa_calib_tab.size() >= MAX_PA_HISTORY_RESULTS_NUMS) {
|
||||
MessageDialog msg_dlg(nullptr, wxString::Format(_L("This machine type can only hold %d history results per nozzle. This result will not be saved."), MAX_PA_HISTORY_RESULTS_NUMS),
|
||||
wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PressureAdvanceWizard::on_cali_save()
|
||||
{
|
||||
if (curr_obj) {
|
||||
|
@ -864,7 +903,8 @@ void PressureAdvanceWizard::on_cali_save()
|
|||
show_step(start_step);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!can_save_cali_result(new_pa_cali_results))
|
||||
return;
|
||||
CalibUtils::set_PA_calib_result(new_pa_cali_results, true);
|
||||
}
|
||||
else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
|
||||
|
@ -873,6 +913,8 @@ void PressureAdvanceWizard::on_cali_save()
|
|||
if (!save_page->get_manual_result(new_pa_cali_result)) {
|
||||
return;
|
||||
}
|
||||
if (!can_save_cali_result({new_pa_cali_result}))
|
||||
return;
|
||||
CalibUtils::set_PA_calib_result({ new_pa_cali_result }, false);
|
||||
}
|
||||
|
||||
|
@ -887,28 +929,8 @@ void PressureAdvanceWizard::on_cali_save()
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
auto iter = std::find_if(curr_obj->pa_calib_tab.begin(), curr_obj->pa_calib_tab.end(), [&new_pa_cali_result](const PACalibResult &item) {
|
||||
return item.name == new_pa_cali_result.name && item.filament_id == item.filament_id;
|
||||
});
|
||||
|
||||
if (iter != curr_obj->pa_calib_tab.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?"),
|
||||
new_pa_cali_result.name),
|
||||
wxEmptyString, wxICON_WARNING | wxYES_NO);
|
||||
if (msg_dlg.ShowModal() != wxID_YES)
|
||||
return;
|
||||
}
|
||||
else if (curr_obj->pa_calib_tab.size() >= MAX_PA_HISTORY_RESULTS_NUMS) {
|
||||
MessageDialog msg_dlg(nullptr,
|
||||
wxString::Format(_L("This machine type can only hold %d history results per nozzle. This result will not be saved."), MAX_PA_HISTORY_RESULTS_NUMS),
|
||||
wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
if (!can_save_cali_result({new_pa_cali_result}))
|
||||
return;
|
||||
}
|
||||
|
||||
CalibUtils::set_PA_calib_result({new_pa_cali_result}, false);
|
||||
} else {
|
||||
|
|
|
@ -129,6 +129,8 @@ protected:
|
|||
|
||||
void on_device_connected(MachineObject* obj) override;
|
||||
|
||||
bool can_save_cali_result(const std::vector<PACalibResult> &new_pa_cali_results);
|
||||
|
||||
bool m_show_result_dialog = false;
|
||||
std::vector<PACalibResult> m_calib_results_history;
|
||||
int cali_version = -1;
|
||||
|
|
|
@ -2075,6 +2075,10 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
|
|||
}
|
||||
m_ams_id_to_extruder_id_map[stoi(info.ams_id)] = info.nozzle_id;
|
||||
}
|
||||
if (obj->is_multi_extruders()) {
|
||||
m_ams_id_to_extruder_id_map[VIRTUAL_TRAY_MAIN_ID] = 0;
|
||||
m_ams_id_to_extruder_id_map[VIRTUAL_TRAY_DEPUTY_ID] = 1;
|
||||
}
|
||||
|
||||
// update for multi_exturder preview
|
||||
for (auto i = 0; i < 4; i++) {
|
||||
|
|
|
@ -450,6 +450,13 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
if (!m_obj)
|
||||
return;
|
||||
|
||||
std::map<int, DynamicPrintConfig> old_full_filament_ams_list = wxGetApp().sidebar().build_filament_ams_list(m_obj);
|
||||
std::map<int, DynamicPrintConfig> full_filament_ams_list;
|
||||
for (auto ams_item : old_full_filament_ams_list) {
|
||||
int key = ams_item.first & 0x0FFFF;
|
||||
full_filament_ams_list[key] = std::move(ams_item.second);
|
||||
}
|
||||
|
||||
m_is_all_failed = true;
|
||||
bool part_failed = false;
|
||||
if (cali_result.empty())
|
||||
|
@ -468,6 +475,9 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
const int COLUMN_GAP = FromDIP(10);
|
||||
const int ROW_GAP = FromDIP(10);
|
||||
|
||||
m_grid_panel->SetSizer(grid_sizer, true);
|
||||
m_grid_panel->Bind(wxEVT_LEFT_DOWN, [this](auto &e) { SetFocusIgnoringChildren(); });
|
||||
|
||||
wxStaticBoxSizer* left_sizer = new wxStaticBoxSizer(wxVERTICAL, m_grid_panel, "Left extruder");
|
||||
wxStaticBoxSizer* right_sizer = new wxStaticBoxSizer(wxVERTICAL, m_grid_panel, "Right extruder");
|
||||
grid_sizer->Add(left_sizer);
|
||||
|
@ -522,11 +532,11 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
m_is_all_failed = false;
|
||||
}
|
||||
|
||||
//wxBoxSizer *item_data_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto tray_title = new Label(m_grid_panel, "", 0, CALIBRATION_SAVE_AMS_NAME_SIZE);
|
||||
tray_title->SetFont(Label::Head_14);
|
||||
wxString tray_name = get_tray_name_by_tray_id(item.tray_id);
|
||||
tray_title->SetLabel(tray_name);
|
||||
wxButton *tray_title = new wxButton(m_grid_panel, wxID_ANY, {}, wxDefaultPosition, wxSize(FromDIP(20), FromDIP(20)), wxBU_EXACTFIT | wxBU_AUTODRAW | wxBORDER_NONE);
|
||||
tray_title->SetBackgroundColour(*wxWHITE);
|
||||
tray_title->SetBitmap(*get_extruder_color_icon(full_filament_ams_list[item.tray_id].opt_string("filament_colour", 0u), tray_name.ToStdString(), FromDIP(20), FromDIP(20)));
|
||||
tray_title->SetToolTip("");
|
||||
|
||||
auto k_value = new GridTextInput(m_grid_panel, "", "", CALIBRATION_SAVE_NUMBER_INPUT_SIZE, item.tray_id, GridTextInputType::K);
|
||||
auto n_value = new GridTextInput(m_grid_panel, "", "", CALIBRATION_SAVE_NUMBER_INPUT_SIZE, item.tray_id, GridTextInputType::N);
|
||||
|
@ -650,9 +660,6 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
|
|||
if (right_first_add_item)
|
||||
right_sizer->Show(false);
|
||||
|
||||
m_grid_panel->SetSizer(grid_sizer, true);
|
||||
m_grid_panel->Bind(wxEVT_LEFT_DOWN, [this](auto &e) { SetFocusIgnoringChildren(); });
|
||||
|
||||
if (part_failed) {
|
||||
m_part_failed_panel->Show();
|
||||
m_complete_text_panel->Show();
|
||||
|
|
Loading…
Reference in New Issue