FIX: fix not popping up a prompt when the temperature is set to 0

Jira: 6497

Change-Id: I6498fc6962e7da376d4c652dab0a99a161932eef
Signed-off-by: maosheng.wei <maosheng.wei@bambulab.com>
This commit is contained in:
maosheng.wei 2024-03-26 16:03:04 +08:00 committed by Lane.Wei
parent 449cb0b27c
commit c62d9b6674
2 changed files with 41 additions and 48 deletions

View File

@ -54,31 +54,25 @@ void ConfigManipulation::check_nozzle_recommended_temperature_range(DynamicPrint
if (is_msg_dlg_already_exist)
return;
int temperature_range_low = config->has("nozzle_temperature_range_low") ?
config->opt_int("nozzle_temperature_range_low", (unsigned int)0) :
0;
int temperature_range_high = config->has("nozzle_temperature_range_high") ?
config->opt_int("nozzle_temperature_range_high", (unsigned int)0) :
0;
int temperature_range_low, temperature_range_high;
if (!get_temperature_range(config, temperature_range_low, temperature_range_high)) return;
if (temperature_range_low != 0 && temperature_range_high != 0) {
wxString msg_text;
bool need_check = false;
if (temperature_range_low < 190 || temperature_range_high > 300) {
msg_text += _L("The recommended minimum temperature is less than 190 degree or the recommended maximum temperature is greater than 300 degree.\n");
need_check = true;
}
if (temperature_range_low > temperature_range_high) {
msg_text += _L("The recommended minimum temperature cannot be higher than the recommended maximum temperature.\n");
need_check = true;
}
if (need_check) {
msg_text += _L("Please check.\n");
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
}
wxString msg_text;
bool need_check = false;
if (temperature_range_low < 190 || temperature_range_high > 300) {
msg_text += _L("The recommended minimum temperature is less than 190 degree or the recommended maximum temperature is greater than 300 degree.\n");
need_check = true;
}
if (temperature_range_low > temperature_range_high) {
msg_text += _L("The recommended minimum temperature cannot be higher than the recommended maximum temperature.\n");
need_check = true;
}
if (need_check) {
msg_text += _L("Please check.\n");
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
dialog.ShowModal();
is_msg_dlg_already_exist = false;
}
}
@ -87,21 +81,13 @@ void ConfigManipulation::check_nozzle_temperature_range(DynamicPrintConfig *conf
if (is_msg_dlg_already_exist)
return;
int temperature_range_low = config->has("nozzle_temperature_range_low") ?
config->opt_int("nozzle_temperature_range_low", (unsigned int)0) :
0;
int temperature_range_high = config->has("nozzle_temperature_range_high") ?
config->opt_int("nozzle_temperature_range_high", (unsigned int)0) :
0;
int temperature_range_low, temperature_range_high;
if (!get_temperature_range(config, temperature_range_low, temperature_range_high)) return;
if (temperature_range_low != 0 &&
temperature_range_high != 0 &&
config->has("nozzle_temperature")) {
if (config->opt_int("nozzle_temperature", 0) < temperature_range_low ||
config->opt_int("nozzle_temperature", 0) > temperature_range_high)
{
if (config->has("nozzle_temperature")) {
if (config->opt_int("nozzle_temperature", 0) < temperature_range_low || config->opt_int("nozzle_temperature", 0) > temperature_range_high) {
wxString msg_text = _(L("Nozzle may be blocked when the temperature is out of recommended range.\n"
"Please confirm whether to use the temperature for printing.\n\n"));
"Please confirm whether to use the temperature for printing.\n\n"));
msg_text += wxString::Format(_L("Recommended nozzle temperature of this filament type is [%d, %d] degree centigrade"), temperature_range_low, temperature_range_high);
MessageDialog dialog(m_msg_dlg_parent, msg_text, "", wxICON_WARNING | wxOK);
is_msg_dlg_already_exist = true;
@ -116,16 +102,10 @@ void ConfigManipulation::check_nozzle_temperature_initial_layer_range(DynamicPri
if (is_msg_dlg_already_exist)
return;
int temperature_range_low = config->has("nozzle_temperature_range_low") ?
config->opt_int("nozzle_temperature_range_low", (unsigned int)0) :
0;
int temperature_range_high = config->has("nozzle_temperature_range_high") ?
config->opt_int("nozzle_temperature_range_high", (unsigned int)0) :
0;
int temperature_range_low, temperature_range_high;
if (!get_temperature_range(config, temperature_range_low, temperature_range_high)) return;
if (temperature_range_low != 0 &&
temperature_range_high != 0 &&
config->has("nozzle_temperature_initial_layer")) {
if (config->has("nozzle_temperature_initial_layer")) {
if (config->opt_int("nozzle_temperature_initial_layer", 0) < temperature_range_low ||
config->opt_int("nozzle_temperature_initial_layer", 0) > temperature_range_high)
{
@ -869,6 +849,20 @@ int ConfigManipulation::show_spiral_mode_settings_dialog(bool is_object_config)
return answer;
}
bool ConfigManipulation::get_temperature_range(DynamicPrintConfig *config, int &range_low, int &range_high)
{
bool range_low_exist = false, range_high_exist = false;
if (config->has("nozzle_temperature_range_low")) {
range_low = config->opt_int("nozzle_temperature_range_low", (unsigned int) 0);
range_low_exist = true;
}
if (config->has("nozzle_temperature_range_high")) {
range_high = config->opt_int("nozzle_temperature_range_high", (unsigned int) 0);
range_high_exist = true;
}
return range_low_exist && range_high_exist;
}
} // GUI
} // Slic3r

View File

@ -93,8 +93,7 @@ public:
int show_spiral_mode_settings_dialog(bool is_object_config = false);
private:
std::vector<int> get_temperature_range_by_filament_type(const std::string &filament_type);
bool get_temperature_range(DynamicPrintConfig *config, int &range_low, int &range_high);
};
} // GUI