From afac07c1663dbf26914a780a1820ca16bdd1b906 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Sun, 3 Aug 2025 20:35:54 +0800 Subject: [PATCH] Don't bother with extruder variants Fix compile error --- src/libslic3r/Preset.cpp | 44 ++++------------------------------ src/slic3r/GUI/GCodeViewer.cpp | 4 ++-- 2 files changed, 7 insertions(+), 41 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index e4bad2c723..d576583dab 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -1280,40 +1280,12 @@ Preset* PresetCollection::get_preset_differed_for_save(Preset& preset) DynamicPrintConfig temp_config; std::vector dirty_options = preset.config.diff(parent_preset->config); - std::string extruder_id_name, extruder_variant_name; - std::set *key_set1 = nullptr, *key_set2 = nullptr; - Preset::get_extruder_names_and_keysets(m_type, extruder_id_name, extruder_variant_name, &key_set1, &key_set2); - - if (!extruder_id_name.empty()) { - dirty_options.emplace_back(extruder_id_name); - } - if (!extruder_variant_name.empty()) { - dirty_options.emplace_back(extruder_variant_name); - } - for (auto option: dirty_options) { ConfigOption *opt_src = preset.config.option(option); ConfigOption *opt_dst = temp_config.option(option, true); - if (opt_dst->is_scalar() || !(opt_dst->nullable())) - opt_dst->set(opt_src); - else { - ConfigOptionVectorBase* opt_vec_src = static_cast(opt_src); - ConfigOptionVectorBase* opt_vec_dst = static_cast(opt_dst); - ConfigOptionVectorBase* opt_vec_inherit = static_cast(parent_preset->config.option(option)); - if (opt_vec_src->size() == 1) - opt_dst->set(opt_src); - else if (key_set1->find(option) != key_set1->end()) { - opt_vec_dst->set_with_nil(opt_vec_src, opt_vec_inherit, 1); - } - else if (key_set2->find(option) != key_set2->end()) { - opt_vec_dst->set_with_nil(opt_vec_src, opt_vec_inherit, 2); - } - else - opt_dst->set(opt_src); - } + opt_dst->set(opt_src); } - new_preset->config = temp_config; } @@ -1380,10 +1352,6 @@ void PresetCollection::load_project_embedded_presets(std::vector& proje std::vector::iterator it; BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" enter, type %1% , total preset counts %2%")%Preset::get_type_string(m_type) %project_presets.size(); - std::string extruder_id_name, extruder_variant_name; - std::set *key_set1 = nullptr, *key_set2 = nullptr; - Preset::get_extruder_names_and_keysets(m_type, extruder_id_name, extruder_variant_name, &key_set1, &key_set2); - lock(); for (it = project_presets.begin(); it != project_presets.end(); it++) { Preset* preset = *it; @@ -1421,13 +1389,11 @@ void PresetCollection::load_project_embedded_presets(std::vector& proje } else { // Find a default preset for the config. The PrintPresetCollection provides different default preset based on the "printer_technology" field. - //BBS 202407: don't load project embedded preset when can not find inherit - //preset->config = default_preset.config; - BOOST_LOG_TRIVIAL(error) << boost::format("can not find parent for config %1%!")%preset->file; - continue; + preset->config = default_preset.config; + BOOST_LOG_TRIVIAL(warning) << boost::format("can not find parent for config %1%!")%preset->file; + //continue; } - preset->config.update_diff_values_to_child_config(config, extruder_id_name, extruder_variant_name, *key_set1, *key_set2); - //preset->config.apply(std::move(config)); + preset->config.apply(std::move(config)); Preset::normalize(preset->config); // Report configuration fields, which are misplaced into a wrong group. std::string incorrect_keys = Preset::remove_invalid_keys(preset->config, default_preset.config); diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 1acf45be21..9e588217f8 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -4411,7 +4411,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) // BBS AMS containers float line_height = ImGui::GetFrameHeight(); int AMS_filament_max_num = std::max(m_left_extruder_filament.size(), m_right_extruder_filament.size()); - float three_words_width = imgui.calc_text_size("ABC").x; + float three_words_width = imgui.calc_text_size("ABC"sv).x; float AMS_container_height = (std::ceil(AMS_filament_max_num / 4.0f) * (three_words_width * 1.5f + line_height) + (line_height * 4)); ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(window_padding * 3, 0)); ImGui::BeginChild("#AMS", ImVec2(0, AMS_container_height), false, ImGuiWindowFlags_AlwaysUseWindowPadding); @@ -4768,7 +4768,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv std::string title = _u8L("Slicing Result"); imgui.bold_text(title); // BBS Set the width of the 8 "ABCD" words minus the "sliced result" to the spacing between the buttons and the title - float single_word_width = imgui.calc_text_size("ABCD").x; + float single_word_width = imgui.calc_text_size("ABCD"sv).x; float title_width = imgui.calc_text_size(title).x; float spacing = 18.0f * m_scale; ImGui::SameLine(0, (single_word_width + spacing) * 8.0f - title_width);