PA Calib Values check (#11493)

* Add input validation for acceleration and speed values

Added a check to ensure that acceleration values are greater than speed values in the PA calibration dialog. Displays a warning message and prevents calibration if the inputs are invalid to guard against swapped or incorrect user entries.

* Add input validation for calibration parameters
This commit is contained in:
Ian Bassi 2025-12-18 09:36:10 -03:00 committed by GitHub
parent f9d5519294
commit c126aae902
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -284,6 +284,19 @@ void PA_Calibration_Dlg::on_start(wxCommandEvent& event) {
ParseStringValues(m_tiBMAccels->GetTextCtrl()->GetValue().ToStdString(), m_params.accelerations);
ParseStringValues(m_tiBMSpeeds->GetTextCtrl()->GetValue().ToStdString(), m_params.speeds);
if (!m_params.accelerations.empty() && !m_params.speeds.empty()) {
// Guard against swapped inputs by ensuring acceleration magnitudes exceed speeds.
const double min_accel = *std::min_element(m_params.accelerations.begin(), m_params.accelerations.end());
const double max_speed = *std::max_element(m_params.speeds.begin(), m_params.speeds.end());
if (min_accel <= max_speed) {
MessageDialog msg_dlg(nullptr,
_L("Acceleration values must be greater than speed values.\nPlease verify the inputs."),
wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
return;
}
}
m_plater->calib_pa(m_params);
EndModal(wxID_OK);