mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 09:47:58 -06:00
FIX: cali status recover incorrect after save result
STUDIO-3602 Change-Id: I1a47e40ca4d571ab37f52b87109d809279d3145e
This commit is contained in:
parent
583c6c86c2
commit
90e1ed7335
5 changed files with 39 additions and 12 deletions
|
@ -513,6 +513,8 @@ std::string AppConfig::load()
|
||||||
PrinterCaliInfo cali_info;
|
PrinterCaliInfo cali_info;
|
||||||
if (calis_j.contains("dev_id"))
|
if (calis_j.contains("dev_id"))
|
||||||
cali_info.dev_id = calis_j["dev_id"].get<std::string>();
|
cali_info.dev_id = calis_j["dev_id"].get<std::string>();
|
||||||
|
if (calis_j.contains("cali_finished"))
|
||||||
|
cali_info.cali_finished = bool(calis_j["cali_finished"].get<int>());
|
||||||
if (calis_j.contains("flow_ratio"))
|
if (calis_j.contains("flow_ratio"))
|
||||||
cali_info.cache_flow_ratio = calis_j["flow_ratio"].get<float>();
|
cali_info.cache_flow_ratio = calis_j["flow_ratio"].get<float>();
|
||||||
if (calis_j.contains("presets")) {
|
if (calis_j.contains("presets")) {
|
||||||
|
@ -638,6 +640,7 @@ void AppConfig::save()
|
||||||
json cali_json;
|
json cali_json;
|
||||||
cali_json["dev_id"] = cali_info.dev_id;
|
cali_json["dev_id"] = cali_info.dev_id;
|
||||||
cali_json["flow_ratio"] = cali_info.cache_flow_ratio;
|
cali_json["flow_ratio"] = cali_info.cache_flow_ratio;
|
||||||
|
cali_json["cali_finished"] = cali_info.cali_finished ? 1 : 0;
|
||||||
for (auto filament_preset : cali_info.selected_presets) {
|
for (auto filament_preset : cali_info.selected_presets) {
|
||||||
json preset_json;
|
json preset_json;
|
||||||
preset_json["tray_id"] = filament_preset.tray_id;
|
preset_json["tray_id"] = filament_preset.tray_id;
|
||||||
|
@ -985,6 +988,7 @@ void AppConfig::save_printer_cali_infos(const PrinterCaliInfo &cali_info)
|
||||||
if (iter == m_printer_cali_infos.end()) {
|
if (iter == m_printer_cali_infos.end()) {
|
||||||
m_printer_cali_infos.emplace_back(cali_info);
|
m_printer_cali_infos.emplace_back(cali_info);
|
||||||
} else {
|
} else {
|
||||||
|
(*iter).cali_finished = cali_info.cali_finished;
|
||||||
(*iter).cache_flow_ratio = cali_info.cache_flow_ratio;
|
(*iter).cache_flow_ratio = cali_info.cache_flow_ratio;
|
||||||
(*iter).selected_presets = cali_info.selected_presets;
|
(*iter).selected_presets = cali_info.selected_presets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ public:
|
||||||
struct PrinterCaliInfo
|
struct PrinterCaliInfo
|
||||||
{
|
{
|
||||||
std::string dev_id;
|
std::string dev_id;
|
||||||
|
bool cali_finished = true;
|
||||||
float cache_flow_ratio;
|
float cache_flow_ratio;
|
||||||
std::vector<CaliPresetInfo> selected_presets;
|
std::vector<CaliPresetInfo> selected_presets;
|
||||||
};
|
};
|
||||||
|
|
|
@ -249,11 +249,7 @@ void CalibrationWizard::cache_preset_info(MachineObject* obj, float nozzle_dia)
|
||||||
CaliPresetStage stage;
|
CaliPresetStage stage;
|
||||||
preset_page->get_cali_stage(stage, obj->cache_flow_ratio);
|
preset_page->get_cali_stage(stage, obj->cache_flow_ratio);
|
||||||
|
|
||||||
PrinterCaliInfo printer_cali_info;
|
back_preset_info(obj, false);
|
||||||
printer_cali_info.dev_id = obj->dev_id;
|
|
||||||
printer_cali_info.cache_flow_ratio = obj->cache_flow_ratio;
|
|
||||||
printer_cali_info.selected_presets = obj->selected_cali_preset;
|
|
||||||
wxGetApp().app_config->save_printer_cali_infos(printer_cali_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CalibrationWizard::recover_preset_info(MachineObject *obj)
|
void CalibrationWizard::recover_preset_info(MachineObject *obj)
|
||||||
|
@ -262,12 +258,23 @@ void CalibrationWizard::recover_preset_info(MachineObject *obj)
|
||||||
for (const auto& back_info : back_infos) {
|
for (const auto& back_info : back_infos) {
|
||||||
if (obj && (obj->dev_id == back_info.dev_id) ) {
|
if (obj && (obj->dev_id == back_info.dev_id) ) {
|
||||||
obj->dev_id = back_info.dev_id;
|
obj->dev_id = back_info.dev_id;
|
||||||
|
obj->cali_finished = back_info.cali_finished;
|
||||||
obj->cache_flow_ratio = back_info.cache_flow_ratio;
|
obj->cache_flow_ratio = back_info.cache_flow_ratio;
|
||||||
obj->selected_cali_preset = back_info.selected_presets;
|
obj->selected_cali_preset = back_info.selected_presets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CalibrationWizard::back_preset_info(MachineObject *obj, bool cali_finish)
|
||||||
|
{
|
||||||
|
PrinterCaliInfo printer_cali_info;
|
||||||
|
printer_cali_info.dev_id = obj->dev_id;
|
||||||
|
printer_cali_info.cali_finished = cali_finish;
|
||||||
|
printer_cali_info.cache_flow_ratio = obj->cache_flow_ratio;
|
||||||
|
printer_cali_info.selected_presets = obj->selected_cali_preset;
|
||||||
|
wxGetApp().app_config->save_printer_cali_infos(printer_cali_info);
|
||||||
|
}
|
||||||
|
|
||||||
void CalibrationWizard::on_cali_go_home()
|
void CalibrationWizard::on_cali_go_home()
|
||||||
{
|
{
|
||||||
// can go home? confirm to continue
|
// can go home? confirm to continue
|
||||||
|
@ -294,14 +301,19 @@ void CalibrationWizard::on_cali_go_home()
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
if (!m_page_steps.empty())
|
if (!m_page_steps.empty()) {
|
||||||
|
back_preset_info(curr_obj, true);
|
||||||
show_step(m_page_steps.front());
|
show_step(m_page_steps.front());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
go_home_dialog->update_text(_L("Are you sure to cancel the current calibration and return to the home page?"));
|
go_home_dialog->update_text(_L("Are you sure to cancel the current calibration and return to the home page?"));
|
||||||
go_home_dialog->on_show();
|
go_home_dialog->on_show();
|
||||||
} else {
|
} else {
|
||||||
if (!m_page_steps.empty()) show_step(m_page_steps.front());
|
if (!m_page_steps.empty()) {
|
||||||
|
back_preset_info(curr_obj, true);
|
||||||
|
show_step(m_page_steps.front());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,7 +413,7 @@ void PressureAdvanceWizard::on_device_connected(MachineObject* obj)
|
||||||
|
|
||||||
if (m_curr_step != cali_step) {
|
if (m_curr_step != cali_step) {
|
||||||
if (obj_cali_mode == m_mode) {
|
if (obj_cali_mode == m_mode) {
|
||||||
if (obj->is_in_printing() /*|| obj->is_printing_finished()*/ || obj->print_status == "FINISH") {
|
if (!obj->cali_finished && (obj->is_in_printing() || obj->is_printing_finished())) {
|
||||||
CalibrationWizard::set_cali_method(method);
|
CalibrationWizard::set_cali_method(method);
|
||||||
show_step(cali_step);
|
show_step(cali_step);
|
||||||
}
|
}
|
||||||
|
@ -568,6 +580,9 @@ void PressureAdvanceWizard::on_cali_save()
|
||||||
}
|
}
|
||||||
CalibUtils::set_PA_calib_result({ new_pa_cali_result });
|
CalibUtils::set_PA_calib_result({ new_pa_cali_result });
|
||||||
}
|
}
|
||||||
|
back_preset_info(curr_obj, true);
|
||||||
|
MessageDialog msg_dlg(nullptr, _L("Flow Dynamics Calibration result has been saved to the printer"), wxEmptyString, wxOK);
|
||||||
|
msg_dlg.ShowModal();
|
||||||
}
|
}
|
||||||
else if (curr_obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
|
else if (curr_obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
|
||||||
auto save_page = static_cast<CalibrationPASavePage*>(save_step->page);
|
auto save_page = static_cast<CalibrationPASavePage*>(save_step->page);
|
||||||
|
@ -598,12 +613,13 @@ void PressureAdvanceWizard::on_cali_save()
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_obj->command_extrusion_cali_set(tray_id, setting_id, "", new_k_value, new_n_value, bed_temp, nozzle_temp, max_volumetric_speed);
|
curr_obj->command_extrusion_cali_set(tray_id, setting_id, "", new_k_value, new_n_value, bed_temp, nozzle_temp, max_volumetric_speed);
|
||||||
|
back_preset_info(curr_obj, true);
|
||||||
|
MessageDialog msg_dlg(nullptr, _L("Flow Dynamics Calibration result has been saved to the printer"), wxEmptyString, wxOK);
|
||||||
|
msg_dlg.ShowModal();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
MessageDialog msg_dlg(nullptr, _L("Flow Dynamics Calibration result has been saved to the printer"), wxEmptyString, wxOK);
|
|
||||||
msg_dlg.ShowModal();
|
|
||||||
}
|
}
|
||||||
show_step(start_step);
|
show_step(start_step);
|
||||||
}
|
}
|
||||||
|
@ -928,6 +944,7 @@ void FlowRateWizard::on_cali_save()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
back_preset_info(curr_obj, true);
|
||||||
MessageDialog msg_dlg(nullptr, _L("Flow rate calibration result has been saved to preset"), wxEmptyString, wxOK);
|
MessageDialog msg_dlg(nullptr, _L("Flow rate calibration result has been saved to preset"), wxEmptyString, wxOK);
|
||||||
msg_dlg.ShowModal();
|
msg_dlg.ShowModal();
|
||||||
}
|
}
|
||||||
|
@ -974,6 +991,7 @@ void FlowRateWizard::on_cali_save()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
back_preset_info(curr_obj, true);
|
||||||
MessageDialog msg_dlg(nullptr, _L("Flow rate calibration result has been saved to preset"), wxEmptyString, wxOK);
|
MessageDialog msg_dlg(nullptr, _L("Flow rate calibration result has been saved to preset"), wxEmptyString, wxOK);
|
||||||
msg_dlg.ShowModal();
|
msg_dlg.ShowModal();
|
||||||
}
|
}
|
||||||
|
@ -1001,7 +1019,7 @@ void FlowRateWizard::on_device_connected(MachineObject* obj)
|
||||||
if (obj) {
|
if (obj) {
|
||||||
this->set_cali_method(method);
|
this->set_cali_method(method);
|
||||||
if (obj_cali_mode == m_mode) {
|
if (obj_cali_mode == m_mode) {
|
||||||
if (obj->is_in_printing() /*|| obj->is_printing_finished()*/ || obj->print_status == "FINISH") {
|
if (!obj->cali_finished && (obj->is_in_printing() || obj->is_printing_finished())) {
|
||||||
if (method == CalibrationMethod::CALI_METHOD_MANUAL) {
|
if (method == CalibrationMethod::CALI_METHOD_MANUAL) {
|
||||||
if (cali_stage == 1) {
|
if (cali_stage == 1) {
|
||||||
if (m_curr_step != cali_coarse_step)
|
if (m_curr_step != cali_coarse_step)
|
||||||
|
@ -1089,6 +1107,8 @@ void FlowRateWizard::cache_coarse_info(MachineObject *obj)
|
||||||
|
|
||||||
wxString out_name;
|
wxString out_name;
|
||||||
coarse_page->get_result(&obj->cache_flow_ratio, &out_name);
|
coarse_page->get_result(&obj->cache_flow_ratio, &out_name);
|
||||||
|
|
||||||
|
back_preset_info(obj, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
MaxVolumetricSpeedWizard::MaxVolumetricSpeedWizard(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
MaxVolumetricSpeedWizard::MaxVolumetricSpeedWizard(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
||||||
|
@ -1280,7 +1300,7 @@ void MaxVolumetricSpeedWizard::on_device_connected(MachineObject *obj)
|
||||||
if (obj) {
|
if (obj) {
|
||||||
this->set_cali_method(method);
|
this->set_cali_method(method);
|
||||||
if (obj_cali_mode == m_mode) {
|
if (obj_cali_mode == m_mode) {
|
||||||
if (obj->is_in_printing() /*|| obj->is_printing_finished()*/ || obj->print_status == "FINISH") {
|
if (!obj->cali_finished && (obj->is_in_printing() || obj->is_printing_finished())) {
|
||||||
if (m_curr_step != cali_step) {
|
if (m_curr_step != cali_step) {
|
||||||
show_step(cali_step);
|
show_step(cali_step);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ public:
|
||||||
|
|
||||||
virtual void cache_preset_info(MachineObject* obj, float nozzle_dia);
|
virtual void cache_preset_info(MachineObject* obj, float nozzle_dia);
|
||||||
virtual void recover_preset_info(MachineObject *obj);
|
virtual void recover_preset_info(MachineObject *obj);
|
||||||
|
virtual void back_preset_info(MachineObject *obj, bool cali_finish);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void on_cali_go_home();
|
void on_cali_go_home();
|
||||||
|
|
|
@ -630,6 +630,7 @@ public:
|
||||||
// 3: save tray_id, filament_id, setting_id, and name, nozzle_dia
|
// 3: save tray_id, filament_id, setting_id, and name, nozzle_dia
|
||||||
std::vector<CaliPresetInfo> selected_cali_preset;
|
std::vector<CaliPresetInfo> selected_cali_preset;
|
||||||
float cache_flow_ratio { 0.0 };
|
float cache_flow_ratio { 0.0 };
|
||||||
|
bool cali_finished = true;
|
||||||
|
|
||||||
bool has_get_pa_calib_tab{ false };
|
bool has_get_pa_calib_tab{ false };
|
||||||
std::vector<PACalibResult> pa_calib_tab;
|
std::vector<PACalibResult> pa_calib_tab;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue