Change in comparing nozzle diameter in right panel printer status

This commit is contained in:
David Kocik 2024-08-27 16:17:10 +02:00 committed by Lukas Matena
parent 8edc0b796d
commit c758c74d7f
2 changed files with 59 additions and 25 deletions

View File

@ -3976,10 +3976,9 @@ bool GUI_App::select_filament_preset(const Preset* preset, size_t extruder_index
void GUI_App::search_and_select_filaments(const std::string& material, bool avoid_abrasive, size_t extruder_index, std::string& out_message)
{
const Preset* preset = preset_bundle->extruders_filaments[extruder_index].get_selected_preset();
bool b = preset->config.option<ConfigOptionBools>("filament_abrasive")->get_at(0);
// selected is ok
if (!preset->is_default && preset->config.has("filament_type")
&& (!avoid_abrasive || preset->config.option<ConfigOptionBools>("filament_abrasive")->get_at(0) == false)
&& (!avoid_abrasive || preset->config.option<ConfigOptionBools>("filament_abrasive")->values[0] == false)
&& preset->config.option("filament_type")->serialize() == material)
{
return;
@ -3991,7 +3990,7 @@ void GUI_App::search_and_select_filaments(const std::string& material, bool avoi
&& filament.preset->is_visible
&& (!filament.preset->vendor || !filament.preset->vendor->templates_profile)
&& filament.preset->config.has("filament_type")
&& (!avoid_abrasive || filament.preset->config.option<ConfigOptionBools>("filament_abrasive")->get_at(0) == false)
&& (!avoid_abrasive || filament.preset->config.option<ConfigOptionBools>("filament_abrasive")->values[0] == false)
&& filament.preset->config.option("filament_type")->serialize() == material
&& filament.preset->name.compare(0, 9, "Prusament") == 0
&& select_filament_preset(filament.preset, extruder_index)
@ -4010,7 +4009,7 @@ void GUI_App::search_and_select_filaments(const std::string& material, bool avoi
&& filament.preset->is_visible
&& (!filament.preset->vendor || !filament.preset->vendor->templates_profile)
&& filament.preset->config.has("filament_type")
&& (!avoid_abrasive || filament.preset->config.option<ConfigOptionBools>("filament_abrasive")->get_at(0) == false)
&& (!avoid_abrasive || filament.preset->config.option<ConfigOptionBools>("filament_abrasive")->values[0] == false)
&& filament.preset->config.option("filament_type")->serialize() == material
&& select_filament_preset(filament.preset, extruder_index)
)
@ -4028,7 +4027,7 @@ void GUI_App::search_and_select_filaments(const std::string& material, bool avoi
&& !filament.preset->is_default
&& (!filament.preset->vendor || !filament.preset->vendor->templates_profile)
&& filament.preset->config.has("filament_type")
&& (!avoid_abrasive || filament.preset->config.option<ConfigOptionBools>("filament_abrasive")->get_at(0) == false)
&& (!avoid_abrasive || filament.preset->config.option<ConfigOptionBools>("filament_abrasive")->values[0] == false)
&& filament.preset->config.option("filament_type")->serialize() == material
&& filament.preset->name.compare(0, 9, "Prusament") == 0
&& select_filament_preset(filament.preset, extruder_index))

View File

@ -985,16 +985,32 @@ static std::string get_connect_state_suffix_for_printer(const Preset& printer_pr
boost::trim_left(printer_model);
}
if (printer_model_nozzle_pair.first == printer_model
&& printer_model_nozzle_pair.second == printer_preset.config.opt_string("printer_variant"))
{
PrinterStatesCount states_cnt = get_printe_states_count(states);
if (printer_preset.config.has("nozzle_diameter")) {
double nozzle_diameter = static_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter"))->values[0];
wxString nozzle_diameter_serialized = double_to_string(nozzle_diameter);
nozzle_diameter_serialized.Replace(L",", L".");
if (states_cnt.available_cnt > 0)
return "_available";
if (states_cnt.busy_cnt > 0)
return "_busy";
return "_offline";
if (printer_model_nozzle_pair.first == printer_model
&& printer_model_nozzle_pair.second == GUI::into_u8(nozzle_diameter_serialized))
{
PrinterStatesCount states_cnt = get_printe_states_count(states);
if (states_cnt.available_cnt > 0)
return "_available";
if (states_cnt.busy_cnt > 0)
return "_busy";
return "_offline";
}
} else {
if (printer_model_nozzle_pair.first == printer_model) {
PrinterStatesCount states_cnt = get_printe_states_count(states);
if (states_cnt.available_cnt > 0)
return "_available";
if (states_cnt.busy_cnt > 0)
return "_busy";
return "_offline";
}
}
}
}
@ -1033,21 +1049,40 @@ static bool fill_data_to_connect_info_line( const Preset& printer_preset,
boost::trim_left(printer_model);
}
if (printer_model_nozzle_pair.first == printer_model
&& printer_model_nozzle_pair.second == printer_preset.config.opt_string("printer_variant"))
{
PrinterStatesCount states_cnt = get_printe_states_count(states);
if (printer_preset.config.has("nozzle_diameter")) {
double nozzle_diameter = static_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter"))->values[0];
wxString nozzle_diameter_serialized = double_to_string(nozzle_diameter);
nozzle_diameter_serialized.Replace(L",", L".");
if (printer_model_nozzle_pair.first == printer_model
&& printer_model_nozzle_pair.second == GUI::into_u8(nozzle_diameter_serialized))
{
PrinterStatesCount states_cnt = get_printe_states_count(states);
#ifdef _WIN32
connect_available_info->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.available_cnt), _L("available")));
connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.offline_cnt), _L("offline")));
connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.busy_cnt), _L("printing")));
connect_available_info->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.available_cnt), _L("available")));
connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.offline_cnt), _L("offline")));
connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.busy_cnt), _L("printing")));
#else
connect_available_info->SetLabel(format_wxstr("%1% ", states_cnt.available_cnt));
connect_offline_info ->SetLabel(format_wxstr("%1% ", states_cnt.offline_cnt));
connect_printing_info ->SetLabel(format_wxstr("%1% ", states_cnt.busy_cnt));
connect_available_info->SetLabel(format_wxstr("%1% ", states_cnt.available_cnt));
connect_offline_info ->SetLabel(format_wxstr("%1% ", states_cnt.offline_cnt));
connect_printing_info ->SetLabel(format_wxstr("%1% ", states_cnt.busy_cnt));
#endif
return true;
return true;
}
} else {
if (printer_model_nozzle_pair.first == printer_model) {
PrinterStatesCount states_cnt = get_printe_states_count(states);
#ifdef _WIN32
connect_available_info->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.available_cnt), _L("available")));
connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.offline_cnt), _L("offline")));
connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("<b>%1%</b>", states_cnt.busy_cnt), _L("printing")));
#else
connect_available_info->SetLabel(format_wxstr("%1% ", states_cnt.available_cnt));
connect_offline_info ->SetLabel(format_wxstr("%1% ", states_cnt.offline_cnt));
connect_printing_info ->SetLabel(format_wxstr("%1% ", states_cnt.busy_cnt));
#endif
return true;
}
}
}
}