From c758c74d7f5549c44ca7ca2bd98de970ba1f6d7e Mon Sep 17 00:00:00 2001 From: David Kocik Date: Tue, 27 Aug 2024 16:17:10 +0200 Subject: [PATCH] Change in comparing nozzle diameter in right panel printer status --- src/slic3r/GUI/GUI_App.cpp | 9 ++-- src/slic3r/GUI/PresetComboBoxes.cpp | 75 +++++++++++++++++++++-------- 2 files changed, 59 insertions(+), 25 deletions(-) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 8a7ad88365..1ef8b24ffc 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -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("filament_abrasive")->get_at(0); // selected is ok if (!preset->is_default && preset->config.has("filament_type") - && (!avoid_abrasive || preset->config.option("filament_abrasive")->get_at(0) == false) + && (!avoid_abrasive || preset->config.option("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("filament_abrasive")->get_at(0) == false) + && (!avoid_abrasive || filament.preset->config.option("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("filament_abrasive")->get_at(0) == false) + && (!avoid_abrasive || filament.preset->config.option("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("filament_abrasive")->get_at(0) == false) + && (!avoid_abrasive || filament.preset->config.option("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)) diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index ff7815a18e..733a2c6907 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -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(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(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("%1%", states_cnt.available_cnt), _L("available"))); - connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("%1%", states_cnt.offline_cnt), _L("offline"))); - connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("%1%", states_cnt.busy_cnt), _L("printing"))); + connect_available_info->SetLabelMarkup(format_wxstr("%1% %2%", format("%1%", states_cnt.available_cnt), _L("available"))); + connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("%1%", states_cnt.offline_cnt), _L("offline"))); + connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("%1%", 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("%1%", states_cnt.available_cnt), _L("available"))); + connect_offline_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("%1%", states_cnt.offline_cnt), _L("offline"))); + connect_printing_info ->SetLabelMarkup(format_wxstr("%1% %2%", format("%1%", 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; + } } } }