From f03dbdeb61b31f2b71230ba23e077ccbf894163e Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Tue, 21 May 2024 15:12:19 +0800 Subject: [PATCH] FIX: modify the max k value jira: none Change-Id: I739f58d4d80e557e1a320af38cc68d7d4e967577 --- src/slic3r/GUI/CaliHistoryDialog.cpp | 6 +++--- src/slic3r/GUI/CalibrationWizard.cpp | 3 +-- src/slic3r/GUI/CalibrationWizardSavePage.cpp | 9 +++++---- src/slic3r/Utils/CalibUtils.cpp | 5 ++++- src/slic3r/Utils/CalibUtils.hpp | 3 +++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/CaliHistoryDialog.cpp b/src/slic3r/GUI/CaliHistoryDialog.cpp index 3fbb415e2..17900552e 100644 --- a/src/slic3r/GUI/CaliHistoryDialog.cpp +++ b/src/slic3r/GUI/CaliHistoryDialog.cpp @@ -16,7 +16,7 @@ namespace GUI { #define EDIT_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(160), FromDIP(24)) #define NEW_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(250), FromDIP(24)) #define HISTORY_WINDOW_ITEMS_COUNT 5 -static const wxString k_tips = "Please input a valid value (K in 0~0.3)"; +static const wxString k_tips = wxString::Format(_L("Please input a valid value (K in %.1f~%.1f)"), MIN_PA_K_VALUE, MAX_PA_K_VALUE); static wxString get_preset_name_by_filament_id(std::string filament_id) { @@ -472,7 +472,7 @@ void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) { float k = 0.0f; if (!CalibUtils::validate_input_k_value(m_k_value->GetTextCtrl()->GetValue(), &k)) { - MessageDialog msg_dlg(nullptr, _L(k_tips), wxEmptyString, wxICON_WARNING | wxOK); + MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK); msg_dlg.ShowModal(); return; } @@ -678,7 +678,7 @@ void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event) float k = 0.0f; if (!CalibUtils::validate_input_k_value(m_k_value->GetTextCtrl()->GetValue(), &k)) { - MessageDialog msg_dlg(nullptr, _L(k_tips), wxEmptyString, wxICON_WARNING | wxOK); + MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK); msg_dlg.ShowModal(); return; } diff --git a/src/slic3r/GUI/CalibrationWizard.cpp b/src/slic3r/GUI/CalibrationWizard.cpp index f1e54a4ac..d16c09ad5 100644 --- a/src/slic3r/GUI/CalibrationWizard.cpp +++ b/src/slic3r/GUI/CalibrationWizard.cpp @@ -6,6 +6,7 @@ #include "../../libslic3r/Calib.hpp" #include "Tabbook.hpp" #include "CaliHistoryDialog.hpp" +#include "CalibUtils.hpp" namespace Slic3r { namespace GUI { @@ -15,8 +16,6 @@ wxDEFINE_EVENT(EVT_DEVICE_CHANGED, wxCommandEvent); wxDEFINE_EVENT(EVT_CALIBRATION_JOB_FINISHED, wxCommandEvent); static const wxString NA_STR = _L("N/A"); -static const float MIN_PA_K_VALUE = 0.0; -static const float MAX_PA_K_VALUE = 0.3; static const float MIN_PA_K_VALUE_STEP = 0.001; static const int MAX_PA_HISTORY_RESULTS_NUMS = 16; diff --git a/src/slic3r/GUI/CalibrationWizardSavePage.cpp b/src/slic3r/GUI/CalibrationWizardSavePage.cpp index b4415b010..c80be1759 100644 --- a/src/slic3r/GUI/CalibrationWizardSavePage.cpp +++ b/src/slic3r/GUI/CalibrationWizardSavePage.cpp @@ -8,7 +8,8 @@ namespace Slic3r { namespace GUI { #define CALIBRATION_SAVE_INPUT_SIZE wxSize(FromDIP(240), FromDIP(24)) #define FLOW_RATE_MAX_VALUE 1.15 -static const wxString k_tips = "Please input a valid value (K in 0~0.3)"; + +static const wxString k_tips = wxString::Format(_L("Please input a valid value (K in %.1f~%.1f)"), MIN_PA_K_VALUE, MAX_PA_K_VALUE); static wxString get_default_name(wxString filament_name, CalibMode mode){ PresetBundle* preset_bundle = wxGetApp().preset_bundle; @@ -362,7 +363,7 @@ void CaliPASaveAutoPanel::save_to_result_from_widgets(wxWindow* window, bool* ou if (input->get_type() == GridTextInputType::K) { float k = 0.0f; if (!CalibUtils::validate_input_k_value(input->GetTextCtrl()->GetValue(), &k)) { - *out_msg = _L("Please input a valid value (K in 0~0.3)"); + *out_msg = k_tips; *out_is_valid = false; } else @@ -546,7 +547,7 @@ bool CaliPASaveManualPanel::get_result(PACalibResult& out_result) { // Check if the value is valid float k; if (!CalibUtils::validate_input_k_value(m_k_val->GetTextCtrl()->GetValue(), &k)) { - MessageDialog msg_dlg(nullptr, _L(k_tips), wxEmptyString, wxICON_WARNING | wxOK); + MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK); msg_dlg.ShowModal(); return false; } @@ -694,7 +695,7 @@ void CaliPASaveP1PPanel::set_pa_cali_method(ManualPaCaliMethod method) bool CaliPASaveP1PPanel::get_result(float* out_k, float* out_n){ // Check if the value is valid if (!CalibUtils::validate_input_k_value(m_k_val->GetTextCtrl()->GetValue(), out_k)) { - MessageDialog msg_dlg(nullptr, _L(k_tips), wxEmptyString, wxICON_WARNING | wxOK); + MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK); msg_dlg.ShowModal(); return false; } diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index 2b80c3842..fc985368c 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -11,6 +11,9 @@ namespace Slic3r { namespace GUI { +const float MIN_PA_K_VALUE = 0.0; +const float MAX_PA_K_VALUE = 1.0; + std::shared_ptr CalibUtils::print_job; wxString wxstr_temp_dir = fs::path(fs::temp_directory_path() / "calib").wstring(); static const std::string temp_dir = wxstr_temp_dir.utf8_string(); @@ -226,7 +229,7 @@ bool CalibUtils::validate_input_k_value(wxString k_text, float* output_value) ; } - if (k_value < 0 || k_value > 0.3) { + if (k_value < MIN_PA_K_VALUE || k_value > MAX_PA_K_VALUE) { *output_value = default_k; return false; } diff --git a/src/slic3r/Utils/CalibUtils.hpp b/src/slic3r/Utils/CalibUtils.hpp index 3377bd760..980ba30c1 100644 --- a/src/slic3r/Utils/CalibUtils.hpp +++ b/src/slic3r/Utils/CalibUtils.hpp @@ -9,6 +9,9 @@ class ProgressIndicator; class Preset; namespace GUI { +extern const float MIN_PA_K_VALUE; +extern const float MAX_PA_K_VALUE; + class CalibInfo { public: