ENH: enable to enter 0 as default cooling temperature

jira: [STUDIO-11360]
Change-Id: Iaede485340c1a88a1a42eceeadf772332fe369a0
This commit is contained in:
xin.zhang 2025-04-09 09:31:49 +08:00 committed by lane.wei
parent b9cb321f73
commit 1fd5340417
3 changed files with 17 additions and 12 deletions

View File

@ -1572,6 +1572,7 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), m_tempCtrl_nozzle = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"),
wxString("monitor_nozzle_temp_active"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER); wxString("monitor_nozzle_temp_active"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE_ALIGN_TWO_ICON); m_tempCtrl_nozzle->SetMinSize(TEMP_CTRL_MIN_SIZE_ALIGN_TWO_ICON);
m_tempCtrl_nozzle->AddTemp(0); // zero is default temp
m_tempCtrl_nozzle->SetMinTemp(20); m_tempCtrl_nozzle->SetMinTemp(20);
m_tempCtrl_nozzle->SetMaxTemp(300); m_tempCtrl_nozzle->SetMaxTemp(300);
m_tempCtrl_nozzle->SetBorderWidth(FromDIP(2)); m_tempCtrl_nozzle->SetBorderWidth(FromDIP(2));
@ -1586,6 +1587,7 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
m_tempCtrl_nozzle_deputy = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"), m_tempCtrl_nozzle_deputy = new TempInput(parent, nozzle_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_nozzle_temp"), wxString("monitor_nozzle_temp_active"),
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER); wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
m_tempCtrl_nozzle_deputy->SetMinSize(TEMP_CTRL_MIN_SIZE_ALIGN_TWO_ICON); m_tempCtrl_nozzle_deputy->SetMinSize(TEMP_CTRL_MIN_SIZE_ALIGN_TWO_ICON);
m_tempCtrl_nozzle_deputy->AddTemp(0); // zero is default temp
m_tempCtrl_nozzle_deputy->SetMinTemp(20); m_tempCtrl_nozzle_deputy->SetMinTemp(20);
m_tempCtrl_nozzle_deputy->SetMaxTemp(300); m_tempCtrl_nozzle_deputy->SetMaxTemp(300);
m_tempCtrl_nozzle_deputy->SetBorderWidth(FromDIP(2)); m_tempCtrl_nozzle_deputy->SetBorderWidth(FromDIP(2));
@ -1605,6 +1607,7 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
wxWindowID bed_id = wxWindow::NewControlId(); wxWindowID bed_id = wxWindow::NewControlId();
m_tempCtrl_bed = new TempInput(parent, bed_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_bed_temp"), m_tempCtrl_bed = new TempInput(parent, bed_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_bed_temp"),
wxString("monitor_bed_temp_active"), wxDefaultPosition,wxDefaultSize, wxALIGN_CENTER); wxString("monitor_bed_temp_active"), wxDefaultPosition,wxDefaultSize, wxALIGN_CENTER);
m_tempCtrl_bed->AddTemp(0); // zero is default temp
m_tempCtrl_bed->SetMinTemp(bed_temp_range[0]); m_tempCtrl_bed->SetMinTemp(bed_temp_range[0]);
m_tempCtrl_bed->SetMaxTemp(bed_temp_range[1]); m_tempCtrl_bed->SetMaxTemp(bed_temp_range[1]);
m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE_ALIGN_ONE_ICON); m_tempCtrl_bed->SetMinSize(TEMP_CTRL_MIN_SIZE_ALIGN_ONE_ICON);
@ -1620,6 +1623,7 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
wxWindowID frame_id = wxWindow::NewControlId(); wxWindowID frame_id = wxWindow::NewControlId();
m_tempCtrl_chamber = new TempInput(parent, frame_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_frame_temp"), m_tempCtrl_chamber = new TempInput(parent, frame_id, TEMP_BLANK_STR, TempInputType::TEMP_OF_NORMAL_TYPE, TEMP_BLANK_STR, wxString("monitor_frame_temp"),
wxString("monitor_frame_temp_active"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER); wxString("monitor_frame_temp_active"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER);
m_tempCtrl_chamber->AddTemp(0); // zero is default temp
m_tempCtrl_chamber->SetReadOnly(true); m_tempCtrl_chamber->SetReadOnly(true);
m_tempCtrl_chamber->SetMinTemp(default_champer_temp_min); m_tempCtrl_chamber->SetMinTemp(default_champer_temp_min);
m_tempCtrl_chamber->SetMaxTemp(default_champer_temp_max); m_tempCtrl_chamber->SetMaxTemp(default_champer_temp_max);
@ -2974,6 +2978,7 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj)
m_tempCtrl_chamber->Enable(); m_tempCtrl_chamber->Enable();
m_tempCtrl_chamber->SetMinTemp(obj->chamber_temp_edit_min); m_tempCtrl_chamber->SetMinTemp(obj->chamber_temp_edit_min);
m_tempCtrl_chamber->SetMaxTemp(obj->chamber_temp_edit_max); m_tempCtrl_chamber->SetMaxTemp(obj->chamber_temp_edit_max);
m_tempCtrl_chamber->AddTemp(0); // zero is default temp
wxCursor cursor(wxCURSOR_IBEAM); wxCursor cursor(wxCURSOR_IBEAM);
m_tempCtrl_chamber->GetTextCtrl()->SetCursor(cursor); m_tempCtrl_chamber->GetTextCtrl()->SetCursor(cursor);

View File

@ -61,24 +61,20 @@ bool TempInput::CheckIsValidVal(bool show_warning)
/*show temperature range warnings*/ /*show temperature range warnings*/
auto tempint = std::stoi(temp.ToStdString()); auto tempint = std::stoi(temp.ToStdString());
if (additional_temps.count(tempint) == 0)
{
if (tempint > max_temp) if (tempint > max_temp)
{ {
if (show_warning) if (show_warning) { Warning(true, WARNING_TOO_HIGH); }
{
Warning(true, WARNING_TOO_HIGH);
}
return false; return false;
} }
else if (tempint < min_temp) else if (tempint < min_temp)
{ {
if (show_warning) if (show_warning) { Warning(true, WARNING_TOO_LOW); }
{
Warning(true, WARNING_TOO_LOW);
}
return false; return false;
} }
}
return true; return true;
} }

View File

@ -6,6 +6,8 @@
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include "StaticBox.hpp" #include "StaticBox.hpp"
#include <unordered_set>
wxDECLARE_EVENT(wxCUSTOMEVT_SET_TEMP_FINISH, wxCommandEvent); wxDECLARE_EVENT(wxCUSTOMEVT_SET_TEMP_FINISH, wxCommandEvent);
enum TempInputType { enum TempInputType {
@ -34,6 +36,7 @@ class TempInput : public wxNavigationEnabled<StaticBox>
int max_temp = 0; int max_temp = 0;
int min_temp = 0; int min_temp = 0;
std::unordered_set<int> additional_temps;
bool warning_mode = false; bool warning_mode = false;
TempInputType m_input_type; TempInputType m_input_type;
@ -96,6 +99,7 @@ public:
void SetMaxTemp(int temp); void SetMaxTemp(int temp);
void SetMinTemp(int temp); void SetMinTemp(int temp);
void AddTemp(int temp) { additional_temps.insert(temp); };
int GetType() { return temp_type; } int GetType() { return temp_type; }