From a17aa8c701d05cee57fb9d422a5bcde9f434fd7b Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Thu, 6 Feb 2025 10:17:33 +0800 Subject: [PATCH] ENH: pva filament should use normal support type 1.Always pop up to switch support type for PVA filaments 2.Rename the old "on_filament_change" to "on_filament_count_change", add a new function as "on_filament_change" jira:NONE Signed-off-by: xun.zhang Change-Id: Ib5a96f2334bbe016db6661864d44e66c1fc5660f --- src/slic3r/GUI/ConfigManipulation.cpp | 2 +- src/slic3r/GUI/MainFrame.cpp | 4 +-- src/slic3r/GUI/Plater.cpp | 49 ++++++++++++++++++++++----- src/slic3r/GUI/Plater.hpp | 7 ++-- 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 662f4e675..c2340c579 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -827,7 +827,7 @@ int ConfigManipulation::show_spiral_mode_settings_dialog(bool is_object_config) "Yes - Change these settings and enable spiral mode automatically\n" "No - Give up using spiral mode this time")); - MessageDialog dialog(m_msg_dlg_parent, msg_text, "", + MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | (!is_object_config ? wxYES | wxNO : wxOK)); is_msg_dlg_already_exist = true; auto answer = dialog.ShowModal(); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index be07b32ac..6c14e9aa9 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -1196,7 +1196,7 @@ void MainFrame::init_tabpanel() // nozzle_diameter is undefined when SLA printer is selected // BBS if (full_config.has("filament_colour")) { - m_plater->on_filaments_change(full_config.option("filament_colour")->values.size()); + m_plater->on_filament_count_change(full_config.option("filament_colour")->values.size()); } } } @@ -3701,7 +3701,7 @@ void MainFrame::on_value_changed(wxCommandEvent& event) m_plater->on_config_change(*tab->get_config()); // propagate config change events to the plater if (opt_key == "extruders_count") { auto value = event.GetInt(); - m_plater->on_filaments_change(value); + m_plater->on_filament_count_change(value); } } } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f432b53c2..6f5344484 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1957,7 +1957,7 @@ void Sidebar::init_filament_combo(PlaterPresetComboBox **combo, const int filame int extruder_count = std::max(1, (int)p->combos_filament.size() - 1); update_objects_list_filament_column(std::max(1, extruder_count - 1)); - on_filaments_change(extruder_count); + on_filament_count_change(extruder_count); wxGetApp().preset_bundle->printers.get_edited_preset().set_num_extruders(extruder_count); wxGetApp().preset_bundle->update_multi_material_filament_presets(); }); @@ -2592,8 +2592,8 @@ void Sidebar::jump_to_option(size_t selected) // wxGetApp().mainframe->select_tab(); } -// BBS. Move logic from Plater::on_extruders_change() to Sidebar::on_filaments_change(). -void Sidebar::on_filaments_change(size_t num_filaments) +// BBS. Move logic from Plater::on_extruders_change() to Sidebar::on_filament_count_change(). +void Sidebar::on_filament_count_change(size_t num_filaments) { auto& choices = combos_filament(); @@ -2749,7 +2749,7 @@ void Sidebar::add_custom_filament(wxColour new_col) { std::string new_color = new_col.GetAsString(wxC2S_HTML_SYNTAX).ToStdString(); wxGetApp().preset_bundle->set_num_filaments(filament_count, new_color); wxGetApp().plater()->get_partplate_list().on_filament_added(filament_count); - wxGetApp().plater()->on_filaments_change(filament_count); + wxGetApp().plater()->on_filament_count_change(filament_count); wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config); auto_calc_flushing_volumes(filament_count - 1); @@ -3003,7 +3003,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn) _L("Sync filaments with AMS"), wxOK); dlg.ShowModal(); } - wxGetApp().plater()->on_filaments_change(n); + wxGetApp().plater()->on_filament_count_change(n); for (auto& c : p->combos_filament) c->update(); /*wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filament_presets[0]); @@ -5043,7 +5043,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ wxColour new_col = Plater::get_next_color_for_filament(); std::string new_color = new_col.GetAsString(wxC2S_HTML_SYNTAX).ToStdString(); wxGetApp().preset_bundle->set_num_filaments(filament_count, new_color); - wxGetApp().plater()->on_filaments_change(filament_count); + wxGetApp().plater()->on_filament_count_change(filament_count); ++filament_size; } wxGetApp().get_tab(Preset::TYPE_PRINT)->update(); @@ -5367,7 +5367,7 @@ std::vector Plater::priv::load_files(const std::vector& input_ // Update filament colors for the MM-printer profile in the full config // to avoid black (default) colors for Extruders in the ObjectList, // when for extruder colors are used filament colors - q->on_filaments_change(preset_bundle->filament_presets.size()); + q->on_filament_count_change(preset_bundle->filament_presets.size()); is_project_file = true; DynamicConfig& proj_cfg = preset_bundle->project_config; @@ -7980,6 +7980,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt) } auto select_flag = combo->GetFlag(selection); combo->ShowBadge(select_flag == (int)PresetComboBox::FilamentAMSType::FROM_AMS); + q->on_filament_change(idx); } bool select_preset = !combo->selection_is_changed_according_to_physical_printers(); // TODO: ? @@ -14673,12 +14674,42 @@ bool Plater::search_string_getter(int idx, const char** label, const char** tool return false; } +void Plater::on_filament_change(size_t filament_idx) +{ + auto& filament_presets = wxGetApp().preset_bundle->filament_presets; + if (filament_idx >= filament_presets.size()) + return; + Slic3r::Preset* filament = wxGetApp().preset_bundle->filaments.find_preset(filament_presets[filament_idx]); + if (filament == nullptr) + return; + std::string filament_type = filament->config.option("filament_type")->values[0]; + if (filament_type == "PVA") { + auto& process_preset = wxGetApp().preset_bundle->prints.get_edited_preset(); + auto support_type = process_preset.config.opt_enum("support_type"); + if (support_type == stNormalAuto || support_type == stNormal) + return; + + wxString msg_text = _(L("For PVA filaments, it is strongly recommended to use normal support to avoid print failures.")); + msg_text += "\n" + _(L("Change these settings automatically? \n")); + MessageDialog dialog(this, msg_text, "", + wxICON_WARNING | wxYES | wxNO); + if (dialog.ShowModal() == wxID_YES) { + SupportType target_type = support_type == SupportType::stTree ? SupportType::stNormal : SupportType::stNormalAuto; + process_preset.config.option("support_type")->set(new ConfigOptionEnum(target_type)); + auto print_tab = wxGetApp().get_tab(Preset::Type::TYPE_PRINT); + print_tab->on_value_change("support_type", target_type); + print_tab->reload_config(); + print_tab->update_dirty(); + } + } +} + // BBS. -void Plater::on_filaments_change(size_t num_filaments) +void Plater::on_filament_count_change(size_t num_filaments) { // only update elements in plater update_filament_colors_in_full_config(); - sidebar().on_filaments_change(num_filaments); + sidebar().on_filament_count_change(num_filaments); sidebar().obj_list()->update_objects_list_filament_column(num_filaments); Slic3r::GUI::PartPlateList &plate_list = get_partplate_list(); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 705b7b7cd..886c3f0d4 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -154,8 +154,8 @@ public: void search(); void jump_to_option(size_t selected); void jump_to_option(const std::string& opt_key, Preset::Type type, const std::wstring& category); - // BBS. Add on_filaments_change() method. - void on_filaments_change(size_t num_filaments); + // BBS. Add filament_added() method. + void on_filament_count_change(size_t num_filaments); void on_filaments_delete(size_t filament_id); void add_filament(); @@ -473,7 +473,8 @@ public: // BBS: return false if not changed bool leave_gizmos_stack(); - void on_filaments_change(size_t extruders_count); + void on_filament_change(size_t filament_idx); + void on_filament_count_change(size_t extruders_count); void on_filaments_delete(size_t extruders_count, size_t filament_id, int replace_filament_id = -1); std::vector> get_extruders_colors(); // BBS