diff --git a/src/libslic3r/Config.hpp b/src/libslic3r/Config.hpp index 218e8cd0cf..9c9b5d3486 100644 --- a/src/libslic3r/Config.hpp +++ b/src/libslic3r/Config.hpp @@ -1313,6 +1313,7 @@ public: ConfigOptionEnum& operator=(const ConfigOption *opt) { this->set(opt); return *this; } bool operator==(const ConfigOptionEnum &rhs) const { return this->value == rhs.value; } int getInt() const override { return (int)this->value; } + void setInt(int val) override { this->value = T(val); } bool operator==(const ConfigOption &rhs) const override { diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 6a656e6d8f..6c500b84a6 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -429,7 +429,7 @@ const std::vector& Preset::print_options() "raft_layers", "raft_first_layer_density", "raft_first_layer_expansion", "raft_contact_distance", "raft_expansion", "support_material_pattern", "support_material_with_sheath", "support_material_spacing", "support_material_synchronize_layers", "support_material_angle", "support_material_interface_layers", - "support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance", + "support_material_interface_pattern", "support_material_interface_spacing", "support_material_interface_contact_loops", "support_material_contact_distance", "support_material_buildplate_only", "dont_support_bridges", "notes", "complete_objects", "extruder_clearance_radius", "extruder_clearance_height", "gcode_comments", "gcode_label_objects", "output_filename_format", "post_process", "perimeter_extruder", "infill_extruder", "solid_infill_extruder", "support_material_extruder", "support_material_interface_extruder", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b272dbfba3..480ce45901 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2341,6 +2341,22 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionEnum(smpRectilinear)); + def = this->add("support_material_interface_pattern", coEnum); + def->label = L("Interface pattern"); + def->category = L("Support material"); + def->tooltip = L("Pattern used to generate support material interface. " + "Default pattern for non-soluble support interface is Rectilinear, " + "while default pattern for soluble support interface is Concentric."); + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values.push_back("auto"); + def->enum_values.push_back("rectilinear"); + def->enum_values.push_back("concentric"); + def->enum_labels.push_back(L("Default")); + def->enum_labels.push_back(L("Rectilinear")); + def->enum_labels.push_back(L("Concentric")); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionEnum(smpRectilinear)); + def = this->add("support_material_spacing", coFloat); def->label = L("Pattern spacing"); def->category = L("Support material"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index aa63e723a6..f563163564 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -65,6 +65,10 @@ enum SupportMaterialPattern { smpRectilinear, smpRectilinearGrid, smpHoneycomb, }; +enum SupportMaterialInterfacePattern { + smipAuto, smipRectilinear, smipConcentric, +}; + enum SeamPosition { spRandom, spNearest, spAligned, spRear }; @@ -207,6 +211,16 @@ template<> inline const t_config_enum_values& ConfigOptionEnum inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { + static t_config_enum_values keys_map; + if (keys_map.empty()) { + keys_map["auto"] = smipAuto; + keys_map["rectilinear"] = smipRectilinear; + keys_map["concentric"] = smipConcentric; + } + return keys_map; +} + template<> inline const t_config_enum_values& ConfigOptionEnum::get_enum_values() { static t_config_enum_values keys_map; if (keys_map.empty()) { @@ -499,6 +513,7 @@ public: ConfigOptionFloat support_material_interface_spacing; ConfigOptionFloatOrPercent support_material_interface_speed; ConfigOptionEnum support_material_pattern; + ConfigOptionEnum support_material_interface_pattern; // Spacing between support material lines (the hatching distance). ConfigOptionFloat support_material_spacing; ConfigOptionFloat support_material_speed; @@ -547,6 +562,7 @@ protected: OPT_PTR(support_material_interface_spacing); OPT_PTR(support_material_interface_speed); OPT_PTR(support_material_pattern); + OPT_PTR(support_material_interface_pattern); OPT_PTR(support_material_spacing); OPT_PTR(support_material_speed); OPT_PTR(support_material_synchronize_layers); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 53403024e4..84fdf3f629 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -568,6 +568,7 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "support_material_extruder" || opt_key == "support_material_extrusion_width" || opt_key == "support_material_interface_layers" + || opt_key == "support_material_interface_pattern" || opt_key == "support_material_interface_contact_loops" || opt_key == "support_material_interface_extruder" || opt_key == "support_material_interface_spacing" diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index ddd68238e0..cfc629e952 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -3573,9 +3573,15 @@ void PrintObjectSupportMaterial::generate_toolpaths( }; std::vector layer_caches(support_layers.size(), LayerCache()); + + const auto fill_type_interface = + (m_object_config->support_material_interface_pattern == smipAuto && m_slicing_params.soluble_interface) || + m_object_config->support_material_interface_pattern == smipConcentric ? + ipConcentric : ipRectilinear; + tbb::parallel_for(tbb::blocked_range(n_raft_layers, support_layers.size()), [this, &support_layers, &bottom_contacts, &top_contacts, &intermediate_layers, &interface_layers, &base_interface_layers, &layer_caches, &loop_interface_processor, - infill_pattern, &bbox_object, support_density, interface_density, interface_angle, &angles, link_max_length_factor, with_sheath] + infill_pattern, &bbox_object, support_density, fill_type_interface, interface_density, interface_angle, &angles, link_max_length_factor, with_sheath] (const tbb::blocked_range& range) { // Indices of the 1st layer in their respective container at the support layer height. size_t idx_layer_bottom_contact = size_t(-1); @@ -3583,7 +3589,6 @@ void PrintObjectSupportMaterial::generate_toolpaths( size_t idx_layer_intermediate = size_t(-1); size_t idx_layer_interface = size_t(-1); size_t idx_layer_base_interface = size_t(-1); - const auto fill_type_interface = m_slicing_params.soluble_interface ? ipConcentric : ipRectilinear; const auto fill_type_first_layer = ipRectilinear; auto filler_interface = std::unique_ptr(Fill::new_from_type(fill_type_interface)); // Filler for the 1st layer interface, if different from filler_interface. diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 309dc57288..b7cff7c7fc 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -279,7 +279,8 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) bool have_support_interface = config->opt_int("support_material_interface_layers") > 0; bool have_support_soluble = have_support_material && config->opt_float("support_material_contact_distance") == 0; for (auto el : { "support_material_pattern", "support_material_with_sheath", - "support_material_spacing", "support_material_angle", "support_material_interface_layers", + "support_material_spacing", "support_material_angle", + "support_material_interface_pattern", "support_material_interface_layers", "dont_support_bridges", "support_material_extrusion_width", "support_material_contact_distance", "support_material_xy_spacing" }) toggle_field(el, have_support_material); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 02847c40de..7303f4d72d 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -1210,6 +1210,8 @@ boost::any& Choice::get_value() m_value = static_cast(ret_enum); else if (m_opt_id.compare("support_material_pattern") == 0) m_value = static_cast(ret_enum); + else if (m_opt_id.compare("support_material_interface_pattern") == 0) + m_value = static_cast(ret_enum); else if (m_opt_id.compare("seam_position") == 0) m_value = static_cast(ret_enum); else if (m_opt_id.compare("host_type") == 0) diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index dc81fde216..61ec4d2331 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -104,7 +104,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt return; } - switch (config.def()->get(opt_key)->type) { + const ConfigOptionDef *opt_def = config.def()->get(opt_key); + switch (opt_def->type) { case coFloatOrPercent:{ std::string str = boost::any_cast(value); bool percent = false; @@ -176,6 +177,11 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt } break; case coEnum:{ +#if 0 + auto *opt = opt_def->default_value.get()->clone(); + opt->setInt(0); + config.set_key_value(opt_key, opt); +#else if (opt_key == "top_fill_pattern" || opt_key == "bottom_fill_pattern" || opt_key == "fill_pattern") @@ -190,6 +196,8 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("support_material_pattern") == 0) config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); + else if (opt_key.compare("support_material_interface_pattern") == 0) + config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("seam_position") == 0) config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("host_type") == 0) @@ -203,6 +211,7 @@ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt else if(opt_key == "brim_type") config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); } +#endif break; case coPoints:{ if (opt_key == "bed_shape" || opt_key == "thumbnails") { diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 5e4dd87890..5247558c77 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -35,7 +35,7 @@ static SettingsBundle FREQ_SETTINGS_BUNDLE_FFF = { L("Layers and Perimeters"), { "layer_height" , "perimeters", "top_solid_layers", "bottom_solid_layers" } }, { L("Infill") , { "fill_density", "fill_pattern" } }, { L("Support material") , { "support_material", "support_material_auto", "support_material_threshold", - "support_material_pattern", "support_material_buildplate_only", + "support_material_pattern", "support_material_interface_pattern", "support_material_buildplate_only", "support_material_spacing" } }, { L("Wipe options") , { "wipe_into_infill", "wipe_into_objects" } } }; diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 7509d40608..b87e2047d4 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -860,46 +860,8 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config case coInts: ret = config.opt_int(opt_key, idx); break; - case coEnum:{ - if (opt_key == "top_fill_pattern" || - opt_key == "bottom_fill_pattern" || - opt_key == "fill_pattern" ) { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "ironing_type") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "fuzzy_skin") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "gcode_flavor") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "machine_limits_usage") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "support_material_pattern") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "seam_position") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "host_type") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "display_orientation") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "support_pillar_connection_mode") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "printhost_authorization_type") { - ret = static_cast(config.option>(opt_key)->value); - } - else if (opt_key == "brim_type") { - ret = static_cast(config.option>(opt_key)->value); - } - } + case coEnum: + ret = config.option(opt_key)->getInt(); break; case coPoints: if (opt_key == "bed_shape") diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index fa1f31ab5d..374789815c 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1511,6 +1511,7 @@ void TabPrint::build() optgroup->append_single_option_line("support_material_spacing", category_path + "pattern-spacing-0-inf"); optgroup->append_single_option_line("support_material_angle", category_path + "pattern-angle"); optgroup->append_single_option_line("support_material_interface_layers", category_path + "interface-layers"); + optgroup->append_single_option_line("support_material_interface_pattern", category_path + "interface-pattern"); optgroup->append_single_option_line("support_material_interface_spacing", category_path + "interface-pattern-spacing"); optgroup->append_single_option_line("support_material_interface_contact_loops", category_path + "interface-loops"); optgroup->append_single_option_line("support_material_buildplate_only", category_path + "support-on-build-plate-only"); diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index 07a6fc7390..473f7e6e17 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -986,18 +986,17 @@ bool UnsavedChangesDialog::save(PresetCollection* dependent_presets) return true; } -template wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConfig& config, bool is_infill = false) { const ConfigOptionDef& def = config.def()->options.at(opt_key); const std::vector& names = def.enum_labels;//ConfigOptionEnum::get_enum_names(); - T val = config.option>(opt_key)->value; + int val = config.option(opt_key)->getInt(); // Each infill doesn't use all list of infill declared in PrintConfig.hpp. // So we should "convert" val to the correct one if (is_infill) { for (auto key_val : *def.enum_keys_map) - if ((int)key_val.second == (int)val) { + if (int(key_val.second) == val) { auto it = std::find(def.enum_values.begin(), def.enum_values.end(), key_val.first); if (it == def.enum_values.end()) return ""; @@ -1005,7 +1004,7 @@ wxString get_string_from_enum(const std::string& opt_key, const DynamicPrintConf } return _L("Undef"); } - return from_u8(_utf8(names[static_cast(val)])); + return from_u8(_utf8(names[val])); } static size_t get_id_from_opt_key(std::string opt_key) @@ -1128,27 +1127,10 @@ static wxString get_string_value(std::string opt_key, const DynamicPrintConfig& return out; } case coEnum: { - if (opt_key == "top_fill_pattern" || + return get_string_from_enum(opt_key, config, + opt_key == "top_fill_pattern" || opt_key == "bottom_fill_pattern" || - opt_key == "fill_pattern") - return get_string_from_enum(opt_key, config, true); - if (opt_key == "gcode_flavor") - return get_string_from_enum(opt_key, config); - if (opt_key == "machine_limits_usage") - return get_string_from_enum(opt_key, config); - if (opt_key == "ironing_type") - return get_string_from_enum(opt_key, config); - if (opt_key == "support_material_pattern") - return get_string_from_enum(opt_key, config); - if (opt_key == "seam_position") - return get_string_from_enum(opt_key, config); - if (opt_key == "display_orientation") - return get_string_from_enum(opt_key, config); - if (opt_key == "support_pillar_connection_mode") - return get_string_from_enum(opt_key, config); - if (opt_key == "brim_type") - return get_string_from_enum(opt_key, config); - break; + opt_key == "fill_pattern"); } case coPoints: { if (opt_key == "bed_shape") {