diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 7afc8b9dd5..41e0e478fd 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -7003,6 +7003,41 @@ void GUI_App::start_download(std::string url) } +bool is_soluble_filament(int extruder_id) +{ + auto &filament_presets = Slic3r::GUI::wxGetApp().preset_bundle->filament_presets; + auto &filaments = Slic3r::GUI::wxGetApp().preset_bundle->filaments; + + if (extruder_id >= filament_presets.size()) return false; + + Slic3r::Preset *filament = filaments.find_preset(filament_presets[extruder_id]); + if (filament == nullptr) return false; + + Slic3r::ConfigOptionBools *support_option = dynamic_cast(filament->config.option("filament_soluble")); + if (support_option == nullptr) return false; + + return support_option->get_at(0); +}; + +bool has_filaments(const std::vector& model_filaments) { + auto &filament_presets = Slic3r::GUI::wxGetApp().preset_bundle->filament_presets; + auto model_objects = Slic3r::GUI::wxGetApp().plater()->model().objects; + const Slic3r::DynamicPrintConfig &config = wxGetApp().preset_bundle->full_config(); + Model::setExtruderParams(config, filament_presets.size()); + + auto get_filament_name = [](int id) { return Model::extruderParamsMap.find(id) != Model::extruderParamsMap.end() ? Model::extruderParamsMap.at(id).materialName : "PLA"; }; + for (const ModelObject *mo : model_objects) { + for (auto vol : mo->volumes) { + auto ve = vol->get_extruders(); + for (auto id : ve) { + auto name = get_filament_name(id); + if (find(model_filaments.begin(), model_filaments.end(), name) != model_filaments.end()) return true; + } + } + } + return false; +} + bool is_support_filament(int extruder_id) { auto &filament_presets = Slic3r::GUI::wxGetApp().preset_bundle->filament_presets; @@ -7013,9 +7048,20 @@ bool is_support_filament(int extruder_id) Slic3r::Preset *filament = filaments.find_preset(filament_presets[extruder_id]); if (filament == nullptr) return false; - Slic3r::ConfigOptionBools *support_option = dynamic_cast(filament->config.option("filament_is_support")); - if (support_option == nullptr) return false; + std::string filament_type = filament->config.option("filament_type")->values[0]; + Slic3r::ConfigOptionBools *support_option = dynamic_cast(filament->config.option("filament_is_support")); + + if (filament_type == "PETG" || filament_type == "PLA") { + std::vector model_filaments; + if (filament_type == "PETG") + model_filaments.emplace_back("PLA"); + else { + model_filaments = {"PETG", "TPU", "TPU-AMS"}; + } + if (has_filaments(model_filaments)) return true; + } + if (support_option == nullptr) return false; return support_option->get_at(0); }; diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 9a7c9e04ef..2e871af7ec 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -734,6 +734,9 @@ DECLARE_APP(GUI_App) wxDECLARE_EVENT(EVT_CONNECT_LAN_MODE_PRINT, wxCommandEvent); bool is_support_filament(int extruder_id); +bool is_soluble_filament(int extruder_id); +// check if the filament for model is in the list +bool has_filaments(const std::vector& model_filaments); } // namespace GUI } // Slic3r diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 265fd8e045..01caed0817 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -15007,25 +15007,6 @@ void Plater::on_filament_change(size_t 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. diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index c2e773d674..bfa475e9ba 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1641,23 +1641,59 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) m_config_manipulation.apply(m_config, &new_conf); } + if (opt_key == "support_filament") { + int filament_id = m_config->opt_int("support_filament") - 1; // the displayed id is based from 1, while internal id is based from 0 + int interface_filament_id = m_config->opt_int("support_interface_filament") - 1; + if (is_support_filament(filament_id) && !is_soluble_filament(filament_id) && !has_filaments({"TPU", "TPU-AMS"})) { + wxString msg_text = _L("Non-soluble support materials are not recommended for support base. \n" + "Are you sure to use them for support base? \n"); + MessageDialog dialog(wxGetApp().plater(), msg_text, "", wxICON_WARNING | wxYES | wxNO); + DynamicPrintConfig new_conf = *m_config; + if (dialog.ShowModal() == wxID_NO) { + new_conf.set_key_value("support_filament", new ConfigOptionInt(0)); + m_config_manipulation.apply(m_config, &new_conf); + } + wxGetApp().plater()->update(); + } + } + // BBS popup a message to ask the user to set optimum parameters for support interface if support materials are used if (opt_key == "support_interface_filament") { + int filament_id = m_config->opt_int("support_filament") - 1; int interface_filament_id = m_config->opt_int("support_interface_filament") - 1; // the displayed id is based from 1, while internal id is based from 0 - if (is_support_filament(interface_filament_id) && !(m_config->opt_float("support_top_z_distance") == 0 && m_config->opt_float("support_interface_spacing") == 0 && - m_config->opt_enum("support_interface_pattern") == SupportMaterialInterfacePattern::smipRectilinearInterlaced)) { - wxString msg_text = _L("When using support material for the support interface, we recommend the following settings:\n" - "0 top Z distance, 0 interface spacing, interlaced rectilinear pattern and disable independent support layer height"); - msg_text += "\n\n" + _L("Change these settings automatically?\n" - "Yes - Change these settings automatically\n" - "No - Do not change these settings for me"); + if ((is_support_filament(interface_filament_id) && + !(m_config->opt_float("support_top_z_distance") == 0 && m_config->opt_float("support_interface_spacing") == 0 && + m_config->opt_enum("support_interface_pattern") == SupportMaterialInterfacePattern::smipRectilinearInterlaced)) || + (is_soluble_filament(interface_filament_id) && !is_soluble_filament(filament_id))) { + wxString msg_text; + if (!is_soluble_filament(interface_filament_id)) { + msg_text = _L("When using support material for the support interface, we recommend the following settings:\n" + "0 top Z distance, 0 interface spacing, interlaced rectilinear pattern and disable independent support layer height"); + msg_text += "\n\n" + _L("Change these settings automatically?\n" + "Yes - Change these settings automatically\n" + "No - Do not change these settings for me"); + } else { + msg_text = _L("When using soluble material for the support interface, We recommend the following settings:\n" + "0 top z distance, 0 interface spacing, interlaced rectilinear pattern, disable independent support layer height \n" + "and use soluble materials for both support interface and support base"); + msg_text += "\n\n" + _L("Change these settings automatically? \n" + "Yes - Change these settings automatically\n" + "No - Do not change these settings for me"); + } MessageDialog dialog(wxGetApp().plater(), msg_text, "Suggestion", wxICON_WARNING | wxYES | wxNO); DynamicPrintConfig new_conf = *m_config; if (dialog.ShowModal() == wxID_YES) { + auto &filament_presets = Slic3r::GUI::wxGetApp().preset_bundle->filament_presets; + auto &filaments = Slic3r::GUI::wxGetApp().preset_bundle->filaments; + Slic3r::Preset *filament = filaments.find_preset(filament_presets[interface_filament_id]); + std::string filament_type = filament->config.option("filament_type")->values[0]; + new_conf.set_key_value("support_top_z_distance", new ConfigOptionFloat(0)); new_conf.set_key_value("support_interface_spacing", new ConfigOptionFloat(0)); new_conf.set_key_value("support_interface_pattern", new ConfigOptionEnum(SupportMaterialInterfacePattern::smipRectilinearInterlaced)); new_conf.set_key_value("independent_support_layer_height", new ConfigOptionBool(false)); + if ((filament_type == "PLA" && has_filaments({"TPU", "TPU-AMS"})) || (is_soluble_filament(interface_filament_id) && !is_soluble_filament(filament_id))) + new_conf.set_key_value("support_filament", new ConfigOptionInt(interface_filament_id + 1)); m_config_manipulation.apply(m_config, &new_conf); } wxGetApp().plater()->update();