From 4084702057d90f87d04f2eeab026552aba3003a8 Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Wed, 30 Aug 2023 11:06:20 +0800 Subject: [PATCH] FIX: the default value of flow rate calibration is the last value set Jira: 4147 Change-Id: If587d92aea872e8cfadb556b2912db402e0a6a86 --- src/slic3r/GUI/CalibrationWizardSavePage.cpp | 49 ++++++++++++-------- src/slic3r/GUI/CalibrationWizardSavePage.hpp | 9 +++- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/slic3r/GUI/CalibrationWizardSavePage.cpp b/src/slic3r/GUI/CalibrationWizardSavePage.cpp index a3d2f397d..58fc0f6db 100644 --- a/src/slic3r/GUI/CalibrationWizardSavePage.cpp +++ b/src/slic3r/GUI/CalibrationWizardSavePage.cpp @@ -1194,10 +1194,10 @@ void CalibrationFlowCoarseSavePage::create_page(wxWindow* parent) coarse_block_items.Add(std::to_string(-20 + (i * 5))); } m_optimal_block_coarse->Set(coarse_block_items); - auto coarse_calc_result_text = new Label(parent, ""); + m_coarse_calc_result_text = new Label(parent, ""); coarse_value_sizer->Add(coarse_value_text, 0, 0); coarse_value_sizer->Add(m_optimal_block_coarse, 0, 0); - coarse_value_sizer->Add(coarse_calc_result_text, 0); + coarse_value_sizer->Add(m_coarse_calc_result_text, 0); m_top_sizer->Add(coarse_value_sizer, 0, 0, 0); m_top_sizer->AddSpacer(FromDIP(20)); @@ -1205,16 +1205,16 @@ void CalibrationFlowCoarseSavePage::create_page(wxWindow* parent) checkBox_panel->SetBackgroundColour(*wxWHITE); auto cb_sizer = new wxBoxSizer(wxHORIZONTAL); checkBox_panel->SetSizer(cb_sizer); - auto checkBox_skip_calibration = new CheckBox(checkBox_panel); - cb_sizer->Add(checkBox_skip_calibration); + m_checkBox_skip_calibration = new CheckBox(checkBox_panel); + cb_sizer->Add(m_checkBox_skip_calibration); auto cb_text = new Label(checkBox_panel, _L("Skip Calibration2")); cb_sizer->Add(cb_text); - cb_text->Bind(wxEVT_LEFT_DOWN, [this, checkBox_skip_calibration](auto&) { - checkBox_skip_calibration->SetValue(!checkBox_skip_calibration->GetValue()); + cb_text->Bind(wxEVT_LEFT_DOWN, [this](auto&) { + m_checkBox_skip_calibration->SetValue(!m_checkBox_skip_calibration->GetValue()); wxCommandEvent event(wxEVT_TOGGLEBUTTON); - event.SetEventObject(checkBox_skip_calibration); - checkBox_skip_calibration->GetEventHandler()->ProcessEvent(event); + event.SetEventObject(m_checkBox_skip_calibration); + m_checkBox_skip_calibration->GetEventHandler()->ProcessEvent(event); }); m_top_sizer->Add(checkBox_panel, 0, 0, 0); @@ -1237,8 +1237,8 @@ void CalibrationFlowCoarseSavePage::create_page(wxWindow* parent) m_top_sizer->AddSpacer(FromDIP(20)); - checkBox_skip_calibration->Bind(wxEVT_TOGGLEBUTTON, [this, save_panel, checkBox_skip_calibration](wxCommandEvent& e) { - if (checkBox_skip_calibration->GetValue()) { + m_checkBox_skip_calibration->Bind(wxEVT_TOGGLEBUTTON, [this, save_panel](wxCommandEvent &e) { + if (m_checkBox_skip_calibration->GetValue()) { m_skip_fine_calibration = true; save_panel->Show(); m_action_panel->show_button(CaliPageActionType::CALI_ACTION_FLOW_COARSE_SAVE); @@ -1255,9 +1255,9 @@ void CalibrationFlowCoarseSavePage::create_page(wxWindow* parent) e.Skip(); }); - m_optimal_block_coarse->Bind(wxEVT_COMBOBOX, [this, coarse_calc_result_text](auto& e) { + m_optimal_block_coarse->Bind(wxEVT_COMBOBOX, [this](auto& e) { m_coarse_flow_ratio = m_curr_flow_ratio * (100.0f + stof(m_optimal_block_coarse->GetValue().ToStdString())) / 100.0f; - coarse_calc_result_text->SetLabel(wxString::Format(_L("flow ratio : %s "), std::to_string(m_coarse_flow_ratio))); + m_coarse_calc_result_text->SetLabel(wxString::Format(_L("flow ratio : %s "), std::to_string(m_coarse_flow_ratio))); }); m_action_panel = new CaliPageActionPanel(parent, m_cali_mode, CaliPageType::CALI_PAGE_COARSE_SAVE); @@ -1273,8 +1273,15 @@ void CalibrationFlowCoarseSavePage::set_save_img() { } } -void CalibrationFlowCoarseSavePage::set_default_name(const wxString& name) { +void CalibrationFlowCoarseSavePage::set_default_options(const wxString& name) { + m_optimal_block_coarse->SetSelection(-1); + m_coarse_calc_result_text->SetLabelText(""); + m_checkBox_skip_calibration->SetValue(false); m_save_name_input->GetTextCtrl()->SetValue(name); + + wxCommandEvent event(wxEVT_TOGGLEBUTTON); + event.SetEventObject(m_checkBox_skip_calibration); + m_checkBox_skip_calibration->GetEventHandler()->ProcessEvent(event); } bool CalibrationFlowCoarseSavePage::is_skip_fine_calibration() { @@ -1308,7 +1315,7 @@ bool CalibrationFlowCoarseSavePage::Show(bool show) { assert(curr_obj->selected_cali_preset.size() <= 1); if (!curr_obj->selected_cali_preset.empty()) { wxString default_name = get_default_name(curr_obj->selected_cali_preset[0].name, CalibMode::Calib_Flow_Rate); - set_default_name(default_name); + set_default_options(default_name); set_curr_flow_ratio(curr_obj->cache_flow_ratio); } } @@ -1373,10 +1380,10 @@ void CalibrationFlowFineSavePage::create_page(wxWindow* parent) fine_block_items.Add(std::to_string(-9 + (i))); } m_optimal_block_fine->Set(fine_block_items); - auto fine_calc_result_text = new Label(parent, ""); + m_fine_calc_result_text = new Label(parent, ""); fine_value_sizer->Add(fine_value_text, 0, 0); fine_value_sizer->Add(m_optimal_block_fine, 0, 0); - fine_value_sizer->Add(fine_calc_result_text, 0); + fine_value_sizer->Add(m_fine_calc_result_text, 0); m_top_sizer->Add(fine_value_sizer, 0, 0, 0); m_top_sizer->AddSpacer(FromDIP(20)); @@ -1390,9 +1397,9 @@ void CalibrationFlowFineSavePage::create_page(wxWindow* parent) m_top_sizer->AddSpacer(FromDIP(20)); - m_optimal_block_fine->Bind(wxEVT_COMBOBOX, [this, fine_calc_result_text](auto& e) { + m_optimal_block_fine->Bind(wxEVT_COMBOBOX, [this](auto& e) { m_fine_flow_ratio = m_curr_flow_ratio * (100.0f + stof(m_optimal_block_fine->GetValue().ToStdString())) / 100.0f; - fine_calc_result_text->SetLabel(wxString::Format(_L("flow ratio : %s "), std::to_string(m_fine_flow_ratio))); + m_fine_calc_result_text->SetLabel(wxString::Format(_L("flow ratio : %s "), std::to_string(m_fine_flow_ratio))); }); m_action_panel = new CaliPageActionPanel(parent, m_cali_mode, CaliPageType::CALI_PAGE_FINE_SAVE); @@ -1407,7 +1414,9 @@ void CalibrationFlowFineSavePage::set_save_img() { } } -void CalibrationFlowFineSavePage::set_default_name(const wxString& name) { +void CalibrationFlowFineSavePage::set_default_options(const wxString &name) { + m_optimal_block_fine->SetSelection(-1); + m_fine_calc_result_text->SetLabelText(""); m_save_name_input->GetTextCtrl()->SetValue(name); } @@ -1438,7 +1447,7 @@ bool CalibrationFlowFineSavePage::Show(bool show) { assert(curr_obj->selected_cali_preset.size() <= 1); if (!curr_obj->selected_cali_preset.empty()) { wxString default_name = get_default_name(curr_obj->selected_cali_preset[0].name, CalibMode::Calib_Flow_Rate); - set_default_name(default_name); + set_default_options(default_name); set_curr_flow_ratio(curr_obj->cache_flow_ratio); } } diff --git a/src/slic3r/GUI/CalibrationWizardSavePage.hpp b/src/slic3r/GUI/CalibrationWizardSavePage.hpp index 9212ab291..6396d12e7 100644 --- a/src/slic3r/GUI/CalibrationWizardSavePage.hpp +++ b/src/slic3r/GUI/CalibrationWizardSavePage.hpp @@ -227,7 +227,7 @@ public: void create_page(wxWindow* parent); void set_save_img(); - void set_default_name(const wxString& name); + void set_default_options(const wxString &name); bool is_skip_fine_calibration(); @@ -243,6 +243,9 @@ protected: ComboBox* m_optimal_block_coarse; TextInput* m_save_name_input; + Label* m_coarse_calc_result_text; + CheckBox* m_checkBox_skip_calibration; + bool m_skip_fine_calibration = false; float m_curr_flow_ratio; float m_coarse_flow_ratio; @@ -256,7 +259,7 @@ public: void create_page(wxWindow* parent); void set_save_img(); - void set_default_name(const wxString& name); + void set_default_options(const wxString &name); void set_curr_flow_ratio(float value); @@ -270,6 +273,8 @@ protected: ComboBox* m_optimal_block_fine; TextInput* m_save_name_input; + Label* m_fine_calc_result_text; + float m_curr_flow_ratio; float m_fine_flow_ratio; };