From 67ff6bd34bae10dfadaa83d3f641d05f1d65ae77 Mon Sep 17 00:00:00 2001 From: AveryanAlex Date: Wed, 26 Aug 2026 19:46:37 +0300 Subject: [PATCH 01/22] Fix Orca Cloud API URL scheme --- src/slic3r/Utils/OrcaCloudServiceAgent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp index 4419395b4d..a07f187c2d 100644 --- a/src/slic3r/Utils/OrcaCloudServiceAgent.cpp +++ b/src/slic3r/Utils/OrcaCloudServiceAgent.cpp @@ -60,7 +60,7 @@ using json = nlohmann::json; namespace Slic3r { namespace { -constexpr const char* ORCA_DEFAULT_API_URL = "api.orcaslicer.com"; +constexpr const char* ORCA_DEFAULT_API_URL = "https://api.orcaslicer.com"; constexpr const char* ORCA_DEFAULT_AUTH_URL = "https://auth.orcaslicer.com"; constexpr const char* ORCA_DEFAULT_CLOUD_URL = "https://cloud.orcaslicer.com"; // Orca: This is a public key with no secret, used to identify the client application to the backend. From 26be8252346c5988785283a6940b48b04ef4abda Mon Sep 17 00:00:00 2001 From: yw4z Date: Mon, 5 Oct 2026 17:37:52 +0300 Subject: [PATCH 02/22] init --- src/slic3r/GUI/PublishSettingsDialog.cpp | 118 ++++++--- src/slic3r/GUI/PublishSettingsDialog.hpp | 8 + src/slic3r/GUI/Tab.cpp | 314 +++++++++++++++++------ src/slic3r/GUI/Tab.hpp | 26 ++ 4 files changed, 353 insertions(+), 113 deletions(-) diff --git a/src/slic3r/GUI/PublishSettingsDialog.cpp b/src/slic3r/GUI/PublishSettingsDialog.cpp index 8d192cfcf0..e44501e604 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.cpp +++ b/src/slic3r/GUI/PublishSettingsDialog.cpp @@ -14,6 +14,7 @@ #include "Widgets/DialogButtons.hpp" #include "Widgets/StaticLine.hpp" #include "Widgets/StateColor.hpp" +#include "Widgets/SwitchButton.hpp" #include "libslic3r/PrintConfig.hpp" #include "libslic3r/Preset.hpp" @@ -873,45 +874,44 @@ void PublishSettingsDialog::build_option_model() for (Tab* tab : wxGetApp().tabs_list) { if (tab->m_type != Preset::TYPE_PRINTER) continue; + // Orca: the printer tab has a single "Extruder" page whose controls are re-targeted to the + // extruder chosen on its switch, so build one inner tab per extruder from that page's + // option list, keyed "#" as the former "Extruder N" pages were. + auto* printer_tab = dynamic_cast(tab); + const size_t extruders_count = printer_tab ? printer_tab->m_extruders_count : 1; for (const PageShp& page : tab->m_pages) { - if (!page->title().StartsWith("Extruder")) + if (page->title() != "Extruder") continue; - // The extruder index of this page: its options are appended with the same - // "#N" opt_index (opt.second.second), so derive the tab's index from the first - // allowlisted option; skip the page when none is found (defensive). - int extruder_idx = -1; - for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { - if (optgroup->title != "Retraction" && optgroup->title != "Z-Hop") - continue; - for (const auto& opt : optgroup->opt_map()) - if (extruder_idx < 0) - extruder_idx = opt.second.second; - if (extruder_idx >= 0) - break; - } - if (extruder_idx < 0) - continue; - const wxString page_title = Tab::translate_category(page->title(), tab->m_type); - for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { - // Allowlist on the untranslated optgroup title; the "Retraction when - // switching material" group is intentionally skipped. - if (optgroup->title != "Retraction" && optgroup->title != "Z-Hop") - continue; - const wxString subcategory = _(optgroup->title); - for (const auto& opt : optgroup->opt_map()) { - const std::string& opt_id = opt.first; - const std::string& pure_key = opt.second.first; - // Rows are keyed by the full per-extruder "#N" opt_id so each extruder - // tab publishes its own value; GetPublishedKeys() emits the checked rows - // as-is. - if (!printer_added.insert(opt_id).second) + // Name each extruder as the printer tab's variant switch does ("Left Extruder: SF", + // "T1: SF", ...), taking its first (standard) option for a hybrid extruder: values come + // from the full config, which holds one value per extruder. + const std::vector switch_options = printer_tab ? printer_tab->generate_extruder_options() : std::vector(); + for (size_t extruder_idx = 0; extruder_idx < extruders_count; ++extruder_idx) { + const int option = printer_tab ? printer_tab->calculate_selection_index_for_extruder(int(extruder_idx), NozzleVolumeType::nvtStandard) : -1; + const wxString page_title = extruders_count > 1 && option >= 0 && option < int(switch_options.size()) ? + switch_options[option] : + Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type); + for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { + // Allowlist on the untranslated optgroup title; the "Retraction when + // switching material" group is intentionally skipped. + if (optgroup->title != "Retraction" && optgroup->title != "Z-Hop") continue; - wxString label, value, unit; - if (!option_text(opt_id, pure_key, label, value, unit)) - continue; - size_t cat_index = category_index_for(page_title, Section::Printer, g, size_t(extruder_idx)); - size_t sub_index = subcategory_index_for(cat_index, subcategory, optgroup->icon); - add_row_ui(opt_id, label, value, unit, cat_index, sub_index); + const wxString subcategory = _(optgroup->title); + for (const auto& opt : optgroup->opt_map()) { + const std::string& pure_key = opt.second.first; + // Rows are keyed by the full per-extruder "#N" opt_id so each extruder + // tab publishes its own value; GetPublishedKeys() emits the checked rows + // as-is. + const std::string opt_id = pure_key + "#" + std::to_string(extruder_idx); + if (!printer_added.insert(opt_id).second) + continue; + wxString label, value, unit; + if (!option_text(opt_id, pure_key, label, value, unit)) + continue; + size_t cat_index = category_index_for(page_title, Section::Printer, g, extruder_idx); + size_t sub_index = subcategory_index_for(cat_index, subcategory, optgroup->icon); + add_row_ui(opt_id, label, value, unit, cat_index, sub_index); + } } } } @@ -1098,6 +1098,10 @@ void PublishSettingsDialog::build_option_model() for (SectionGroup& section : m_sections) if (!section.categories.empty()) section.tabs->SelectItem(0); + // Orca: the Printer section shows its extruders on the same switch as the printer tab's Extruder page. + for (size_t s = 0; s < m_sections.size(); ++s) + if (m_sections[s].kind == Section::Printer && m_sections[s].categories.size() > 1) + setup_variant_switch(s); if (!m_sections.empty()) { m_outer_tabs->SelectItem(0); show_outer_page(0); @@ -1630,6 +1634,8 @@ void PublishSettingsDialog::show_inner_page(size_t section_index, int inner_inde section.selected_mixed = -1; } section.selected_inner = inner_index; + if (section.variant_switch != nullptr && section.variant_switch->GetSelection() != inner_index) + section.variant_switch->SetSelection(inner_index); // fires its event, which ignores the shown page Category& category = m_categories[section.categories[inner_index]]; category.page->Show(); category.scroll->FitInside(); @@ -1639,6 +1645,38 @@ void PublishSettingsDialog::show_inner_page(size_t section_index, int inner_inde section.page_host_sizer->Layout(); } +void PublishSettingsDialog::setup_variant_switch(size_t section_index) +{ + SectionGroup& section = m_sections[section_index]; + if (section.variant_switch != nullptr || section.categories.size() < 2) + return; + + section.variant_titles.clear(); + for (size_t category : section.categories) + section.variant_titles.push_back(m_categories[category].title); + + section.variant_switch = new MultiSwitchButton(section.page); + section.variant_switch->SetFitToOptions(); + section.variant_switch->SetOptions(section.variant_titles); + section.variant_switch->SetSelection(std::max(section.selected_inner, 0)); + section.variant_switch->Bind(wxCUSTOMEVT_MULTISWITCH_SELECTION, [this, section_index](wxCommandEvent& evt) { + evt.Skip(); + const int selection = evt.GetInt(); + SectionGroup& sec = m_sections[section_index]; + if (selection >= 0 && selection < static_cast(sec.categories.size()) && selection != sec.selected_inner) { + sec.tabs->SelectItem(selection); // keep the hidden tab strip in step; its event shows the page + if (sec.selected_inner != selection) + show_inner_page(section_index, selection); + } + }); + + // The switch takes the place of the tab strip, centered like on the printer tab. + wxSizer* page_sizer = section.page->GetSizer(); + page_sizer->Insert(1, section.variant_switch, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, FromDIP(4)); + section.tabs->Hide(); + section.page->Layout(); +} + void PublishSettingsDialog::show_mixed_page(size_t section_index, int mixed_index) { if (section_index >= m_sections.size()) @@ -2184,6 +2222,12 @@ void PublishSettingsDialog::refresh_tab_indicators() for (size_t i = 0; i < section.categories.size(); ++i) { const bool on = category_has_selection(m_categories[section.categories[i]]); section.tabs->SetItemIndicator(static_cast(i), on); + // The switch has no indicator dot; mark its option text instead. + if (section.variant_switch != nullptr && i < section.variant_titles.size()) { + const wxString text = on ? section.variant_titles[i] + wxString(" ") + wxString(wxUniChar(0x2022)) : section.variant_titles[i]; + if (section.variant_switch->GetOptionText(static_cast(i)) != text) + section.variant_switch->SetOptionText(static_cast(i), text); + } any = any || on; } if (section.mixed_tabs != nullptr) @@ -2248,6 +2292,8 @@ void PublishSettingsDialog::on_dpi_changed(const wxRect& suggested_rect) section.tabs->Rescale(); if (section.mixed_tabs != nullptr) section.mixed_tabs->Rescale(); + if (section.variant_switch != nullptr) + section.variant_switch->Rescale(); } // Refresh the per-row Color chips at the new DPI (they carry the slot number too). diff --git a/src/slic3r/GUI/PublishSettingsDialog.hpp b/src/slic3r/GUI/PublishSettingsDialog.hpp index b7f537b4a5..ab680c3c53 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.hpp +++ b/src/slic3r/GUI/PublishSettingsDialog.hpp @@ -37,6 +37,7 @@ namespace Slic3r { class DynamicPrintConfig; } class TextInput; class StaticLine; class CheckBox; +class MultiSwitchButton; namespace Slic3r { namespace GUI { @@ -195,6 +196,11 @@ private: ScalableBitmap icon_bmp; // tab icon next to the title; rescaled on DPI change wxPanel* page{nullptr}; TabCtrl* tabs{nullptr}; + // Printer section with several extruders: the extruder switch shown instead of `tabs`, the + // same MultiSwitchButton (and option names) as the printer tab's Extruder page. One option + // per entry of `categories`; `tabs` stays as the hidden selection model. + MultiSwitchButton* variant_switch{nullptr}; + std::vector variant_titles; // Second tab strip, below the main one, listing only the mixed-color filament slots. // Present on the Material section only (null elsewhere). TabCtrl* mixed_tabs{nullptr}; @@ -277,6 +283,8 @@ private: bool row_is_visible(const Row& row) const; void apply_visibility(); void bind_tab_events(); + // Replaces a section's inner tab strip with a variant switch (see SectionGroup::variant_switch). + void setup_variant_switch(size_t section_index); TabCtrl* m_outer_tabs{nullptr}; wxPanel* m_outer_host{nullptr}; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 770e14de9f..0ba52df694 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -810,6 +810,12 @@ wxString Tab::translate_category(const wxString& title, Preset::Type preset_type } return _("Extruder") + title.SubString(8, title.Last()); } + // Orca: one "Extruder" page serves all extruders; name it "Extruders" when there are several. + if (preset_type == Preset::TYPE_PRINTER && title == "Extruder") { + auto preset = wxGetApp().preset_bundle; + if (preset && preset->get_printer_extruder_count() > 1) + return _("Extruders"); + } return _(title); } @@ -1152,6 +1158,29 @@ std::string Tab::options_list_storage_key(const std::string& opt_key) const return (serialized || is_plugin_field) ? opt_key : opt_key + "#0"; } +// Orca: deep_diff() flags every vector entry at or past the reference vector's length as changed, +// whatever its value (e.g. the values of an extruder added by raising the extruder count). A vector +// grows by copying its first entry (ConfigOptionVector::resize), so such an entry only counts as +// changed when it differs from the reference's first entry, as before Orca's deep_diff() change. +// The change of the count itself shows on "extruders_count". +static void drop_unchanged_added_entries(std::vector &options, const DynamicPrintConfig ¤t, const Preset *reference) +{ + if (reference == nullptr) + return; + options.erase(std::remove_if(options.begin(), options.end(), [&](const std::string &opt) { + const auto pos = opt.find('#'); + if (pos == std::string::npos) + return false; + const std::string key = opt.substr(0, pos); + const size_t idx = size_t(std::atoi(opt.c_str() + pos + 1)); + auto ref = dynamic_cast(reference->config.option(key)); + auto cur = dynamic_cast(current.option(key)); + if (ref == nullptr || cur == nullptr || idx < ref->size() || ref->size() == 0 || idx >= cur->size()) + return false; + return cur->vserialize()[idx] == ref->vserialize().front(); + }), options.end()); +} + void Tab::update_all_extruder_options_status() { if (!m_extruder_switch && !m_variant_combo) { @@ -1182,6 +1211,10 @@ void Tab::update_all_extruder_options_status() auto dirty_options = m_presets->current_dirty_options(true); auto nonsys_options = m_presets->current_different_from_parent_options(true); + if (m_type == Preset::TYPE_PRINTER) { + drop_unchanged_added_entries(dirty_options, *m_config, &m_presets->get_selected_preset()); + drop_unchanged_added_entries(nonsys_options, *m_config, m_presets->get_selected_preset_parent()); + } auto filter_extruder_options = [](const std::vector& options) { std::vector filtered_options; for (const auto& opt : options) { @@ -1230,7 +1263,8 @@ void Tab::update_extruder_switch_colors() if (m_active_page) { if (m_active_page->title() == "Speed" || m_active_page->title() == "Motion ability" || m_active_page->title() == "Filament" || - m_active_page->title() == "Setting Overrides" || m_active_page->title() == "Multimaterial") { + m_active_page->title() == "Setting Overrides" || m_active_page->title() == "Multimaterial" || + (m_type == Preset::TYPE_PRINTER && m_active_page->title() == "Extruder")) { for (auto page_ptr : m_pages) { if (page_ptr.get() == m_active_page) { pages_to_check.push_back(page_ptr); @@ -1261,8 +1295,8 @@ void Tab::update_extruder_switch_colors() void Tab::check_extruder_options_status(int index, bool &sys_extruder, bool &modified_extruder, const std::vector& pages_to_check) { int config_index = index; + int extruder_id = index; if (m_type == Preset::TYPE_PRINT || m_type == Preset::TYPE_PRINTER || m_type == Preset::TYPE_MODEL) { - int extruder_id; NozzleVolumeType nozzle_type; parse_extruder_selection(index, extruder_id, nozzle_type); @@ -1295,6 +1329,10 @@ void Tab::check_extruder_options_status(int index, bool &sys_extruder, bool &mod } std::string target_opt_key = base_opt_key + "#" + std::to_string(config_index * stride); + // Orca: on the printer's Extruder page only per-variant options use the variant column, + // the others (nozzle_diameter, extruder_offset, ...) are indexed by the extruder. + if (m_type == Preset::TYPE_PRINTER && page->title() == "Extruder" && printer_options_with_variant_1.count(base_opt_key) == 0) + target_opt_key = base_opt_key + "#" + std::to_string(extruder_id); auto status_iter = m_all_extruder_options_status.find(target_opt_key); if (status_iter != m_all_extruder_options_status.end()) { @@ -1335,18 +1373,7 @@ void TabPrinter::init_options_list() Tab::init_options_list(); if (m_printer_technology == ptFFF) m_options_list.emplace("extruders_count", m_opt_status_value); - for (size_t i = 1; i < m_extruders_count; ++i) { - wxString target_title = wxString::Format("Extruder %d", int(i + 1)); - for (auto &page : m_pages) { - if (page->title() == target_title) { - for (auto group : page->m_optgroups) { - for (auto &opt : group->opt_map()) - m_options_list.emplace(opt.first, m_opt_status_value); - } - break; - } - } - } + // Orca: the single "Extruder" page only has the "#0" fields, which Tab::init_options_list() already lists. } void TabPrinter::msw_rescale() @@ -1436,7 +1463,8 @@ void Tab::update_changed_tree_ui() get_sys_and_mod_flags("compatible_printers", sys_page, modified_page); } } - if (page->title() == "Speed" || page->title() == "Motion ability" || page->title() == "Filament" || page->title() == "Setting Overrides" || page->title() == "Multimaterial") { + if (page->title() == "Speed" || page->title() == "Motion ability" || page->title() == "Filament" || page->title() == "Setting Overrides" || page->title() == "Multimaterial" || + (m_type == Preset::TYPE_PRINTER && page->title() == "Extruder")) { auto options = generate_extruder_options(); for (size_t switch_index = 0; switch_index < options.size(); ++switch_index) { std::vector pages_to_check = { page }; @@ -1539,6 +1567,10 @@ void Tab::on_roll_back_value(const bool to_sys /*= true*/) m_postpone_update_ui = false; + // Orca: the restored config may have another extruder count than the tab shows. + if (auto printer_tab = dynamic_cast(this)) + printer_tab->sync_extruders_count(); + // When all values are rolled, then we have to update whole tab in respect to the reverted values update(); if (m_active_page) @@ -2422,8 +2454,14 @@ void Tab::update_wiping_button_visibility() { } -void Tab::activate_option(const std::string& opt_key, const wxString& category) +void Tab::activate_option(const std::string& opt_key_in, const wxString& category_in) { + std::string opt_key = opt_key_in; + wxString category = category_in; + // Orca: "Extruder N" options live on the single Extruder page, select extruder N there first. + if (auto printer_tab = dynamic_cast(this)) + printer_tab->prepare_extruder_option_jump(opt_key, category); + wxString page_title = translate_category(category, m_type); auto cur_item = m_tabctrl->GetFirstVisibleItem(); @@ -5682,9 +5720,13 @@ if (is_marlin_flavor) size_t extruders_count = size_t(boost::any_cast(v)); wxTheApp->CallAfter([this, opt_key, value, extruders_count]() { if (opt_key == "extruders_count" || opt_key == "single_extruder_multi_material") { + const size_t old_extruders_count = m_extruders_count; extruders_count_changed(extruders_count); init_options_list(); // m_options_list should be updated before UI updating update_dirty(); + // Orca: the variant switches (here, Process in the sidebar, ...) list one option per extruder. + if (m_extruders_count != old_extruders_count) + refresh_extruder_switches(); if (opt_key == "single_extruder_multi_material") { // the single_extruder_multimaterial was added to force pages on_value_change(opt_key, value); // rebuild - let's make sure the on_value_change is not skipped @@ -5694,6 +5736,7 @@ if (is_marlin_flavor) // Orca: we use a different logic here. If SEMM is enabled, we set extruder count to 1. #if 1 extruders_count_changed(1); + refresh_extruder_switches(); #else std::vector nozzle_diameters = @@ -5765,14 +5808,13 @@ if (is_marlin_flavor) m_pages.insert(m_pages.end() - n_after_single_extruder_MM, page); } - // Orca: build missed extruder pages - for (auto extruder_idx = m_extruders_count_old; extruder_idx < m_extruders_count; ++extruder_idx) { - const wxString& page_name = (m_extruders_count > 1) ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString::Format("Extruder"); - - //# build page - //const wxString& page_name = wxString::Format("Extruder %d", int(extruder_idx + 1)); - auto page = add_options_page(page_name, "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders - m_pages.insert(m_pages.begin() + n_before_extruders + extruder_idx, page); + // Orca: a single "Extruder" page serves all extruders. Its controls are created once for extruder 0; + // switch_excluder() re-targets them to the extruder selected on the variant switch (m_extruder_switch), + // which the printer tab shows on this page too. + if (extruder_page() == nullptr && m_extruders_count > 0) { + const size_t extruder_idx = 0; + auto page = add_options_page(L("Extruder"), "custom-gcode_extruder", true); // ORCA: icon only visible on placeholders + m_pages.insert(m_pages.begin() + n_before_extruders, page); auto optgroup = page->new_optgroup(L("Basic information"), L"param_information", -1, true); optgroup->append_single_option_line("nozzle_diameter", "printer_extruder_basic_information#nozzle-diameter", extruder_idx); @@ -5785,8 +5827,10 @@ if (is_marlin_flavor) option.opt.full_width = true; optgroup->append_single_option_line(option, "printer_extruder_basic_information#extruder-offset-position"); - optgroup->m_on_change = [this, extruder_idx](const t_config_option_key& opt_key, boost::any value) + optgroup->m_on_change = [this](const t_config_option_key& opt_key, boost::any value) { + // The page edits the extruder selected on the variant switch. + const size_t extruder_idx = size_t(std::max(0, get_current_active_extruder())); bool is_SEMM = m_config->opt_bool("single_extruder_multi_material"); if (is_SEMM && m_extruders_count > 1 && boost::starts_with(opt_key, "nozzle_diameter")) { @@ -5881,22 +5925,22 @@ if (is_marlin_flavor) //optgroup->append_line(line); #endif } - // BBS. No extra extruder page for single physical extruder machine - // # remove extra pages - auto &first_extruder_title = const_cast(m_pages[n_before_extruders]->title()); - if (m_extruders_count < m_extruders_count_old) { - m_pages.erase( m_pages.begin() + n_before_extruders + m_extruders_count, - m_pages.begin() + n_before_extruders + m_extruders_count_old); - if (m_extruders_count == 1) - first_extruder_title = wxString::Format("Extruder"); - } else if (m_extruders_count_old == 1) { - first_extruder_title = wxString::Format("Extruder %d", 1); - } - auto & index = wxGetApp().sidebar().settings_index(); - for (auto &group : m_pages[n_before_extruders]->m_optgroups) { - group->set_config_category_and_type(first_extruder_title, m_type); - for (auto &opt : group->opt_map()) - index.add_key(opt.first + "#0", m_type, group->title, first_extruder_title, group->icon); + + // The page holds only the "#0" controls, so register every extruder's options with the search + // index under "Extruder N"; a search hit selects that extruder (prepare_extruder_option_jump()). + if (Page *page = extruder_page()) { + auto &index = wxGetApp().sidebar().settings_index(); + for (auto &group : page->m_optgroups) { + group->set_config_category_and_type(page->title(), m_type); + for (auto &opt : group->opt_map()) { + if (opt.second.second < 0) + continue; + for (size_t i = 0; i < m_extruders_count; ++i) { + const wxString category = m_extruders_count > 1 ? wxString::Format("Extruder %d", int(i + 1)) : wxString("Extruder"); + index.add_key(opt.second.first + "#" + std::to_string(i), m_type, group->title, category, group->icon); + } + } + } } Thaw(); @@ -6257,14 +6301,15 @@ void TabPrinter::toggle_options() toggle_option("tool_change_on_wipe_tower", !bSEMM && supports_wipe_tower_2 && extruders_count > 1); toggle_option("wait_for_temp_on_wipe_tower", !bSEMM && supports_wipe_tower_2 && extruders_count > 1); } - wxString extruder_number; - long val = 1; - if ( m_active_page->title().IsSameAs(L("Extruder")) || - (m_active_page->title().StartsWith("Extruder ", &extruder_number) && extruder_number.ToLong(&val) && - val > 0 && (size_t)val <= m_extruders_count)) + if (m_active_page->title() == L("Extruder") && m_extruders_count > 0) { - size_t i = size_t(val - 1); - int variant_index = get_index_for_extruder(i); + // Orca: the single Extruder page edits the extruder selected on the variant switch; its + // controls carry field index 0 (i), the values are read for `extruder`. + const size_t i = 0; + const size_t extruder = std::min(size_t(std::max(0, get_current_active_extruder())), m_extruders_count - 1); + int variant_index = get_index_for_extruder(extruder); + if (variant_index < 0) + variant_index = int(extruder); bool have_retract_length = m_config->opt_float("retraction_length", variant_index) > 0; toggle_option("extruder_printable_area", false, i); // disable @@ -6291,7 +6336,7 @@ void TabPrinter::toggle_options() vec.resize(0); vec = {"retract_lift_above", "retract_lift_below", "retract_lift_enforce"}; for (auto el : vec) - toggle_option(el, retraction && (m_config->opt_float("z_hop", i) > 0), i); + toggle_option(el, retraction && (m_config->opt_float("z_hop", variant_index) > 0), i); // some options only apply when not using firmware retraction vec.resize(0); @@ -6344,7 +6389,7 @@ void TabPrinter::toggle_options() toggle_option("long_retractions_when_cut", !use_firmware_retraction && m_config->opt_int("enable_long_retraction_when_cut"), i); toggle_line("retraction_distances_when_cut", m_config->opt_bool("long_retractions_when_cut", variant_index), i); - toggle_option("travel_slope", m_config->opt_enum("z_hop_types", i) != ZHopType::zhtNormal, i); + toggle_option("travel_slope", m_config->opt_enum("z_hop_types", variant_index) != ZHopType::zhtNormal, i); } if (m_active_page->title() == L("Motion ability")) { @@ -6424,6 +6469,9 @@ void TabPrinter::on_value_change(const std::string& opt_key, const boost::any& v boost::erase_head(temp_str, pos + 1); int orig_opt_idx = static_cast(atoi(temp_str.c_str())); int opt_idx = orig_opt_idx >= 0 ? orig_opt_idx : 0; + // Orca: fields of the single Extruder page keep index 0 but edit the selected extruder. + if (const int data_idx = extruder_page_data_index(opt_key); data_idx >= 0) + opt_idx = data_idx; std::string opt_key_pure = opt_key; boost::erase_tail(opt_key_pure, opt_key_pure.size() - pos); @@ -6458,7 +6506,12 @@ void TabPrinter::on_value_change(const std::string& opt_key, const boost::any& v } } - Tab::on_value_change(opt_key, value); + // Orca: report Extruder page changes as "key#", as the former "Extruder N" pages did, + // so per-extruder handling in Tab::on_value_change() sees the extruder that was edited. + if (pos > 0 && extruder_page_data_index(opt_key) >= 0) + Tab::on_value_change(opt_key.substr(0, pos) + "#" + std::to_string(std::max(0, get_current_active_extruder())), value); + else + Tab::on_value_change(opt_key, value); } void TabPrinter::update() @@ -7391,9 +7444,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event) this->OnActivate(); m_parent->set_active_tab(this); if (m_variant_sizer) { - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; - m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder ")); - if (m_extruder_sync) m_extruder_sync->Show(variant_ctrl->IsShown()); + update_variant_sizer_visibility(); GetParent()->Layout(); } @@ -7407,9 +7458,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event) m_active_page = page; if (m_variant_sizer) { - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; - m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder")); - if (m_extruder_sync) m_extruder_sync->Show(variant_ctrl->IsShown()); + update_variant_sizer_visibility(); GetParent()->Layout(); } @@ -8238,8 +8287,10 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) for (int i = 0; i < extruder_nums; i++) m_actual_nozzle_volumes[i] = (NozzleVolumeType)nozzle_volumes->values[i]; // Orca: a non-Bambu dual-nozzle printer has two extruders but a single variant column, so - // the nozzle switch and sync button have nothing to act on. Only enable with real variants. - if (extruder_nums >= 2 && m_preset_bundle->support_different_extruders()) { + // the nozzle switch and sync button have nothing to act on on the variant pages. The printer + // tab still enables the switch to choose the extruder its single "Extruder" page edits. + m_extruder_switch_variants = extruder_nums >= 2 && m_preset_bundle->support_different_extruders(); + if (m_extruder_switch_variants || (m_type == Preset::TYPE_PRINTER && extruder_nums >= 2)) { auto options = generate_extruder_options(); m_extruder_switch->SetOptions(options); @@ -8256,7 +8307,7 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) m_extruder_switch->SetSelection(selection_index); m_extruder_switch->Enable(true); - m_extruder_sync->Enable(true); + m_extruder_sync->Enable(m_extruder_switch_variants); } else { m_extruder_switch->Enable(false); m_extruder_sync->Enable(false); @@ -8278,10 +8329,9 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) if (m_type == Preset::TYPE_PRINT) { update_pages_with_multi_variant(); } + update_extruder_switch_colors(); if (m_variant_sizer) { - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; - m_main_sizer->Show(m_variant_sizer, variant_ctrl->IsThisEnabled() && m_active_page && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder ")); - if (m_extruder_sync) m_extruder_sync->Show(variant_ctrl->IsShown()); + update_variant_sizer_visibility(); GetParent()->Layout(); } } @@ -8362,8 +8412,10 @@ std::vector Tab::generate_extruder_options() // Orca: the main/deputy toolhead names describe a dual-nozzle printer, where extruder 0 is the // left (deputy) and extruder 1 the right (main) nozzle. From three extruders on the tools are // interchangeable, so name them by index instead of repeating one side. + // Orca: Left/Right only names a Bambu dual-nozzle printer; other printers number their tools. + const bool toolhead_names = extruder_nums == 2 && m_preset_bundle->is_bbl_vendor(); for (int i = 0; i < extruder_nums; ++i) { - wxString extruder_name = extruder_nums > 2 ? wxString::Format("T%d", i + 1) : + wxString extruder_name = !toolhead_names ? wxString::Format("T%d", i + 1) : _L(DevPrinterConfigUtil::get_toolhead_display_name( pt, (i == 0) ? DEPUTY_EXTRUDER_ID : MAIN_EXTRUDER_ID, ToolHeadComponent::Nozzle, ToolHeadNameCase::TitleCase, true)); @@ -8380,6 +8432,75 @@ std::vector Tab::generate_extruder_options() return options; } +Page *TabPrinter::extruder_page() const +{ + for (const PageShp &page : m_pages) + if (page->title() == "Extruder") + return page.get(); + return nullptr; +} + +int TabPrinter::extruder_page_data_index(const std::string &field_id) const +{ + if (Page *page = extruder_page()) + for (const auto &group : page->m_optgroups) + if (auto it = group->opt_map().find(field_id); it != group->opt_map().end()) + return it->second.second; + return -1; +} + +void TabPrinter::update_custom_dirty(std::vector &dirty_options, std::vector &nonsys_options) +{ + drop_unchanged_added_entries(dirty_options, *m_config, &m_presets->get_selected_preset()); + drop_unchanged_added_entries(nonsys_options, *m_config, m_presets->get_selected_preset_parent()); +} + +void TabPrinter::sync_extruders_count() +{ + if (m_printer_technology != ptFFF) + return; + const auto *nozzle_diameter = m_config->option("nozzle_diameter"); + if (nozzle_diameter == nullptr || nozzle_diameter->size() == m_extruders_count) + return; + extruders_count_changed(nozzle_diameter->size()); + init_options_list(); + refresh_extruder_switches(); +} + +void TabPrinter::refresh_extruder_switches() +{ + // The same tabs a nozzle_volume_type change refreshes in Tab::on_value_change(). + for (auto tab : wxGetApp().tabs_list) + tab->update_extruder_variants(); + if (auto tab = wxGetApp().plate_tab) + tab->update_extruder_variants(); + for (auto tab : wxGetApp().model_tabs_list) + tab->update_extruder_variants(); +} + +void TabPrinter::prepare_extruder_option_jump(std::string &opt_key, wxString &category) +{ + if (extruder_page() == nullptr) + return; + + int extruder_idx = 0; + wxString number; + long n = 0; + if (category.StartsWith("Extruder ", &number) && number.ToLong(&n)) { + if (n >= 1 && n <= long(m_extruders_count)) + extruder_idx = int(n - 1); + } else if (category != "Extruder") + return; + + category = "Extruder"; + if (auto pos = opt_key.find('#'); pos != std::string::npos) + opt_key = opt_key.substr(0, pos) + "#0"; // the page's controls are created for index 0 + + // Selecting fires the switch's event, which re-targets the page (switch_excluder()). + if (m_extruder_switch && m_extruder_switch->IsThisEnabled() && extruder_idx != get_current_active_extruder()) + m_extruder_switch->SetSelection(calculate_selection_index_for_extruder(extruder_idx, get_actual_nozzle_volume_type(extruder_idx))); +} + NozzleVolumeType Tab::get_actual_nozzle_volume_type(int extruder_id) { int extruder_count = m_preset_bundle->get_printer_extruder_count(); @@ -8456,6 +8577,32 @@ bool Tab::get_extruder_sync_enable_state(int extruder_id) return false; } +bool Tab::variant_switch_active() const +{ + if (m_extruder_switch) + return m_extruder_switch->IsThisEnabled() && m_extruder_switch_variants; + return m_variant_combo && m_variant_combo->IsThisEnabled(); +} + +void Tab::update_variant_sizer_visibility() +{ + if (!m_variant_sizer) + return; + bool show = false; + if (m_type == Preset::TYPE_PRINTER && m_active_page && m_active_page->title() == "Extruder") + // Orca: the single Extruder page edits the extruder selected on the switch. + show = m_extruder_switch && m_extruder_switch->IsThisEnabled() && m_extruder_switch->GetCount() > 1; + else + show = variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder"); + m_main_sizer->Show(m_variant_sizer, show); + if (m_extruder_sync && m_extruder_switch) { + m_extruder_sync->Show(show); + // Copying between extruders is offered on the variant pages only. + const bool on_extruder_page = m_type == Preset::TYPE_PRINTER && m_active_page && m_active_page->title() == "Extruder"; + m_extruder_sync->Enable(!on_extruder_page && variant_switch_active() && get_extruder_sync_enable_state(get_current_active_extruder())); + } +} + void Tab::switch_excluder(int extruder_id, bool reload) { Preset & printer_preset = m_preset_bundle->printers.get_edited_preset(); @@ -8464,10 +8611,13 @@ void Tab::switch_excluder(int extruder_id, bool reload) if (!m_variant_combo && (extruder_id >= (int)nozzle_volumes->size() || extruder_id >= (int)extruders->size())) extruder_id = 0; + // Orca: the printer's single Extruder page follows the switch for any multi-extruder printer; + // the other pages only when the switch selects nozzle variants. + const bool on_extruder_page = m_type == Preset::TYPE_PRINTER && m_active_page && m_active_page->title() == "Extruder"; if (m_extruder_switch) { int current_extruder = get_current_active_extruder(); bool sync_enable = get_extruder_sync_enable_state(current_extruder); - m_extruder_sync->Enable(m_extruder_switch->IsThisEnabled() && sync_enable); + m_extruder_sync->Enable(variant_switch_active() && sync_enable && !on_extruder_page); m_extruder_sync->Show(); if (m_type != Preset::TYPE_PRINTER) { if (extruder_id == -1) @@ -8489,29 +8639,39 @@ void Tab::switch_excluder(int extruder_id, bool reload) return m_config->get_index_for_extruder(extruder_id + 1, variant_keys.first, ExtruderType(extruders->values[extruder_id]), get_actual_nozzle_volume_type(extruder_id), variant_keys.second, stride); }; - auto index = m_variant_combo ? extruder_id : get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id); + // Extruder of the printer's Extruder page, and of the other pages (the first one when the switch + // does not select variants). + const int page_extruder = m_type == Preset::TYPE_PRINTER ? std::max(0, extruder_id == -1 ? get_current_active_extruder() : extruder_id) : extruder_id; + const int common_extruder = (m_type == Preset::TYPE_PRINTER && !m_extruder_switch_variants) ? 0 : extruder_id; + auto index = m_variant_combo ? extruder_id : get_index_for_extruder(common_extruder == -1 ? 0 : common_extruder); if (index < 0) return; if (m_extruder_switch) m_extruder_switch->SetClientData(reinterpret_cast(static_cast(index))); if (m_variant_combo) m_variant_combo->SetClientData(reinterpret_cast(static_cast(index))); - wxWindow *variant_ctrl = m_extruder_switch ? (wxWindow *) m_extruder_switch : m_variant_combo; for (auto page : m_pages) { bool is_extruder = false; + int page_index = index; if (m_type == Preset::TYPE_PRINTER) { - if (page->title().StartsWith("Extruder")) { - int extruder_id2 = std::atoi(page->title().Mid(9).ToUTF8()) - 1; - if (extruder_id >= 0 && extruder_id2 != extruder_id) - continue; - if (extruder_id2 > 0) - index = get_index_for_extruder(extruder_id2); + if (page->title() == "Extruder") { is_extruder = true; + page_index = page_extruder < int(extruders->size()) ? get_index_for_extruder(page_extruder) : -1; + if (page_index < 0) + page_index = page_extruder; } else if (page->title().StartsWith("Motion ability")) { - index = get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id, 2); + page_index = get_index_for_extruder(common_extruder == -1 ? 0 : common_extruder, 2); } } page->m_opt_id_map.clear(); for (auto group : page->m_optgroups) { for (auto &opt : group->opt_map()) { + if (is_extruder && opt.second.second >= 0) { + // Per-variant options use the variant column, the others (nozzle_diameter, + // extruder_offset, ...) are sized by the extruder count and use the extruder. + const int idx = printer_options_with_variant_1.count(opt.second.first) > 0 ? page_index : page_extruder; + const_cast(opt.second.second) = idx; + page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(idx), opt.first}); + continue; + } auto iter = std::find(printer_extruder_options.begin(), printer_extruder_options.end(), opt.second.first); if (iter != printer_extruder_options.end()) { page->m_opt_id_map.insert({opt.first, opt.first}); @@ -8519,9 +8679,9 @@ void Tab::switch_excluder(int extruder_id, bool reload) } if (opt.second.second >= 0) { - const_cast(opt.second.second) = index; - page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(index), opt.first}); - group->draw_multi_extruder = !is_extruder && variant_ctrl->IsThisEnabled(); + const_cast(opt.second.second) = page_index; + page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(page_index), opt.first}); + group->draw_multi_extruder = !is_extruder && variant_switch_active(); } } } diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 0ace0d7b9f..7c8b3f5fc9 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -331,6 +331,10 @@ public: MultiSwitchButton * m_variant_combo = nullptr; ScalableButton *m_extruder_sync = nullptr; wxPanel * m_extruder_sync_box = nullptr; + // Orca: whether m_extruder_switch switches nozzle variants (it is then shown on the variant pages). + // The printer tab also enables the switch for printers without variants, to choose the extruder + // its single "Extruder" page edits. + bool m_extruder_switch_variants = false; std::vector m_actual_nozzle_volumes; public: @@ -387,6 +391,10 @@ public: void update_changed_tree_ui(); void update_undo_buttons(); void update_extruder_switch_colors(); + // Whether the variant switch (m_extruder_switch / m_variant_combo) switches nozzle variants. + bool variant_switch_active() const; + // Shows the variant switch row on variant pages, and on the printer tab's "Extruder" page. + void update_variant_sizer_visibility(); void update_all_extruder_options_status(); void check_extruder_options_status(int index, bool &sys_extruder, bool &modified_extruder, const std::vector& pages_to_check); @@ -710,6 +718,24 @@ public: void cache_extruder_cnt(const DynamicPrintConfig* config = nullptr); bool apply_extruder_cnt_from_cache(); void refresh_printer_agent_dropdown() const; + + // Orca: a single "Extruder" page for all extruders. Its controls are created once (index 0) and + // switch_excluder() re-targets them to the extruder selected on m_extruder_switch. + Page* extruder_page() const; + // Config index an "Extruder" page field (e.g. "retraction_length#0") currently edits, -1 if not on that page. + int extruder_page_data_index(const std::string& field_id) const; + // After the user changed the extruder count: rebuild every tab's variant switch. + void refresh_extruder_switches(); + // After the config was restored (roll back): follow its extruder count, if it differs. + void sync_extruders_count(); + // Search jump to "Extruder N" / "key#N": selects extruder N on the switch, and rewrites the + // option to the page's own field id and the category to the page title. + void prepare_extruder_option_jump(std::string& opt_key, wxString& category); + +protected: + // Orca: values of extruders added by raising the extruder count have no saved / system value to + // revert to; the change is shown on "extruders_count", not on each of their parameters. + void update_custom_dirty(std::vector &dirty_options, std::vector &nonsys_options) override; }; class TabSLAMaterial : public Tab From 26329e714702ccd2b1494e25ef70f245a45b417a Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 6 Oct 2026 20:03:07 +0800 Subject: [PATCH 03/22] Show Left/Right Extruder or Extruder N on the extruder switch --- src/slic3r/GUI/PublishSettingsDialog.cpp | 10 ++-------- src/slic3r/GUI/Tab.cpp | 7 +++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/PublishSettingsDialog.cpp b/src/slic3r/GUI/PublishSettingsDialog.cpp index e44501e604..e4aeff0e0c 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.cpp +++ b/src/slic3r/GUI/PublishSettingsDialog.cpp @@ -882,15 +882,9 @@ void PublishSettingsDialog::build_option_model() for (const PageShp& page : tab->m_pages) { if (page->title() != "Extruder") continue; - // Name each extruder as the printer tab's variant switch does ("Left Extruder: SF", - // "T1: SF", ...), taking its first (standard) option for a hybrid extruder: values come - // from the full config, which holds one value per extruder. - const std::vector switch_options = printer_tab ? printer_tab->generate_extruder_options() : std::vector(); + // One tab per extruder, named as on the printer tab's switch. for (size_t extruder_idx = 0; extruder_idx < extruders_count; ++extruder_idx) { - const int option = printer_tab ? printer_tab->calculate_selection_index_for_extruder(int(extruder_idx), NozzleVolumeType::nvtStandard) : -1; - const wxString page_title = extruders_count > 1 && option >= 0 && option < int(switch_options.size()) ? - switch_options[option] : - Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type); + const wxString page_title = Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type); for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { // Allowlist on the untranslated optgroup title; the "Retraction when // switching material" group is intentionally skipped. diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index dc6b6d6945..25c17b56b2 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -8418,6 +8418,13 @@ std::vector Tab::generate_extruder_options() // Orca: Left/Right only names a Bambu dual-nozzle printer; other printers number their tools. const bool toolhead_names = extruder_nums == 2 && m_preset_bundle->is_bbl_vendor(); for (int i = 0; i < extruder_nums; ++i) { + // Orca: the printer tab has one tag per extruder, named as its former "Extruder N" pages were. + // parse_extruder_selection() counts a hybrid extruder as two tags; that still lines up because + // only the last extruder can be hybrid. + if (m_type == Preset::TYPE_PRINTER) { + options.push_back(translate_category(wxString::Format("Extruder %d", i + 1), m_type)); + continue; + } wxString extruder_name = !toolhead_names ? wxString::Format("T%d", i + 1) : _L(DevPrinterConfigUtil::get_toolhead_display_name( pt, (i == 0) ? DEPUTY_EXTRUDER_ID : MAIN_EXTRUDER_ID, From d068468bbb3097d2aad5f1a87940424d5a2b8445 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 6 Oct 2026 20:31:17 +0800 Subject: [PATCH 04/22] Simplify the unified Extruder page and its Publish dialog switch --- src/slic3r/GUI/PublishSettingsDialog.cpp | 95 ++++++------ src/slic3r/GUI/PublishSettingsDialog.hpp | 3 +- src/slic3r/GUI/Tab.cpp | 175 ++++++++++------------- src/slic3r/GUI/Tab.hpp | 12 +- 4 files changed, 126 insertions(+), 159 deletions(-) diff --git a/src/slic3r/GUI/PublishSettingsDialog.cpp b/src/slic3r/GUI/PublishSettingsDialog.cpp index e4aeff0e0c..70cdfe51c9 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.cpp +++ b/src/slic3r/GUI/PublishSettingsDialog.cpp @@ -865,47 +865,43 @@ void PublishSettingsDialog::build_option_model() }; // --- Phase 1: printer per-extruder retraction settings (first, mirroring the sidebar's - // Printer group), from the printer tab's "Extruder"/"Extruder N" pages. One inner tab per - // extruder (e.g. "Left Extruder"/"Right Extruder" via Tab::translate_category), each holding - // that extruder's Retraction and Z-Hop rows with per-extruder "#N" values. + // Printer group), from the printer tab's "Extruder" page. One inner tab per extruder (named + // as on the printer tab's switch, e.g. "Left Extruder"/"Right Extruder" via + // Tab::translate_category), each holding that extruder's Retraction and Z-Hop rows with + // per-extruder "#N" values. { size_t g = section_group_for(Section::Printer); std::set printer_added; for (Tab* tab : wxGetApp().tabs_list) { - if (tab->m_type != Preset::TYPE_PRINTER) + // The page's controls edit the extruder chosen on the printer tab's switch, so its + // option list is read once per extruder. + auto* printer_tab = dynamic_cast(tab); + const Page* page = printer_tab ? printer_tab->extruder_page() : nullptr; + if (page == nullptr) continue; - // Orca: the printer tab has a single "Extruder" page whose controls are re-targeted to the - // extruder chosen on its switch, so build one inner tab per extruder from that page's - // option list, keyed "#" as the former "Extruder N" pages were. - auto* printer_tab = dynamic_cast(tab); - const size_t extruders_count = printer_tab ? printer_tab->m_extruders_count : 1; - for (const PageShp& page : tab->m_pages) { - if (page->title() != "Extruder") - continue; - // One tab per extruder, named as on the printer tab's switch. - for (size_t extruder_idx = 0; extruder_idx < extruders_count; ++extruder_idx) { - const wxString page_title = Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type); - for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { - // Allowlist on the untranslated optgroup title; the "Retraction when - // switching material" group is intentionally skipped. - if (optgroup->title != "Retraction" && optgroup->title != "Z-Hop") + const size_t extruders_count = printer_tab->m_extruders_count; + for (size_t extruder_idx = 0; extruder_idx < extruders_count; ++extruder_idx) { + const wxString page_title = Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type); + for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { + // Allowlist on the untranslated optgroup title; the "Retraction when + // switching material" group is intentionally skipped. + if (optgroup->title != "Retraction" && optgroup->title != "Z-Hop") + continue; + const wxString subcategory = _(optgroup->title); + for (const auto& opt : optgroup->opt_map()) { + const std::string& pure_key = opt.second.first; + // Rows are keyed by the full per-extruder "#N" opt_id so each extruder + // tab publishes its own value; GetPublishedKeys() emits the checked rows + // as-is. + const std::string opt_id = pure_key + "#" + std::to_string(extruder_idx); + if (!printer_added.insert(opt_id).second) continue; - const wxString subcategory = _(optgroup->title); - for (const auto& opt : optgroup->opt_map()) { - const std::string& pure_key = opt.second.first; - // Rows are keyed by the full per-extruder "#N" opt_id so each extruder - // tab publishes its own value; GetPublishedKeys() emits the checked rows - // as-is. - const std::string opt_id = pure_key + "#" + std::to_string(extruder_idx); - if (!printer_added.insert(opt_id).second) - continue; - wxString label, value, unit; - if (!option_text(opt_id, pure_key, label, value, unit)) - continue; - size_t cat_index = category_index_for(page_title, Section::Printer, g, extruder_idx); - size_t sub_index = subcategory_index_for(cat_index, subcategory, optgroup->icon); - add_row_ui(opt_id, label, value, unit, cat_index, sub_index); - } + wxString label, value, unit; + if (!option_text(opt_id, pure_key, label, value, unit)) + continue; + size_t cat_index = category_index_for(page_title, Section::Printer, g, extruder_idx); + size_t sub_index = subcategory_index_for(cat_index, subcategory, optgroup->icon); + add_row_ui(opt_id, label, value, unit, cat_index, sub_index); } } } @@ -1628,7 +1624,7 @@ void PublishSettingsDialog::show_inner_page(size_t section_index, int inner_inde section.selected_mixed = -1; } section.selected_inner = inner_index; - if (section.variant_switch != nullptr && section.variant_switch->GetSelection() != inner_index) + if (section.variant_switch != nullptr) section.variant_switch->SetSelection(inner_index); // fires its event, which ignores the shown page Category& category = m_categories[section.categories[inner_index]]; category.page->Show(); @@ -1642,26 +1638,20 @@ void PublishSettingsDialog::show_inner_page(size_t section_index, int inner_inde void PublishSettingsDialog::setup_variant_switch(size_t section_index) { SectionGroup& section = m_sections[section_index]; - if (section.variant_switch != nullptr || section.categories.size() < 2) - return; - - section.variant_titles.clear(); + std::vector titles; for (size_t category : section.categories) - section.variant_titles.push_back(m_categories[category].title); + titles.push_back(m_categories[category].title); section.variant_switch = new MultiSwitchButton(section.page); section.variant_switch->SetFitToOptions(); - section.variant_switch->SetOptions(section.variant_titles); - section.variant_switch->SetSelection(std::max(section.selected_inner, 0)); + section.variant_switch->SetOptions(titles); + section.variant_switch->SetSelection(section.selected_inner); section.variant_switch->Bind(wxCUSTOMEVT_MULTISWITCH_SELECTION, [this, section_index](wxCommandEvent& evt) { evt.Skip(); - const int selection = evt.GetInt(); - SectionGroup& sec = m_sections[section_index]; - if (selection >= 0 && selection < static_cast(sec.categories.size()) && selection != sec.selected_inner) { - sec.tabs->SelectItem(selection); // keep the hidden tab strip in step; its event shows the page - if (sec.selected_inner != selection) - show_inner_page(section_index, selection); - } + // The hidden tab strip stays the selection model; its event shows the page. + SectionGroup& sec = m_sections[section_index]; + if (evt.GetInt() != sec.selected_inner) + sec.tabs->SelectItem(evt.GetInt()); }); // The switch takes the place of the tab strip, centered like on the printer tab. @@ -2217,8 +2207,9 @@ void PublishSettingsDialog::refresh_tab_indicators() const bool on = category_has_selection(m_categories[section.categories[i]]); section.tabs->SetItemIndicator(static_cast(i), on); // The switch has no indicator dot; mark its option text instead. - if (section.variant_switch != nullptr && i < section.variant_titles.size()) { - const wxString text = on ? section.variant_titles[i] + wxString(" ") + wxString(wxUniChar(0x2022)) : section.variant_titles[i]; + if (section.variant_switch != nullptr) { + const wxString& title = m_categories[section.categories[i]].title; + const wxString text = on ? title + wxString(" ") + wxString(wxUniChar(0x2022)) : title; if (section.variant_switch->GetOptionText(static_cast(i)) != text) section.variant_switch->SetOptionText(static_cast(i), text); } diff --git a/src/slic3r/GUI/PublishSettingsDialog.hpp b/src/slic3r/GUI/PublishSettingsDialog.hpp index ab680c3c53..5e3ef48617 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.hpp +++ b/src/slic3r/GUI/PublishSettingsDialog.hpp @@ -198,9 +198,8 @@ private: TabCtrl* tabs{nullptr}; // Printer section with several extruders: the extruder switch shown instead of `tabs`, the // same MultiSwitchButton (and option names) as the printer tab's Extruder page. One option - // per entry of `categories`; `tabs` stays as the hidden selection model. + // per entry of `categories`, named by its title; `tabs` stays as the hidden selection model. MultiSwitchButton* variant_switch{nullptr}; - std::vector variant_titles; // Second tab strip, below the main one, listing only the mixed-color filament slots. // Present on the Material section only (null elsewhere). TabCtrl* mixed_tabs{nullptr}; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 3f1986e529..2c6fbff835 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1168,6 +1168,10 @@ static void drop_unchanged_added_entries(std::vector &options, cons { if (reference == nullptr) return; + // deep_diff() lists a key's entries one after another, so serialize each key's vectors once. + std::string serialized_key; + std::vector cur_values; + std::string ref_first; options.erase(std::remove_if(options.begin(), options.end(), [&](const std::string &opt) { const auto pos = opt.find('#'); if (pos == std::string::npos) @@ -1178,7 +1182,12 @@ static void drop_unchanged_added_entries(std::vector &options, cons auto cur = dynamic_cast(current.option(key)); if (ref == nullptr || cur == nullptr || idx < ref->size() || ref->size() == 0 || idx >= cur->size()) return false; - return cur->vserialize()[idx] == ref->vserialize().front(); + if (key != serialized_key) { + serialized_key = key; + cur_values = cur->vserialize(); + ref_first = ref->vserialize().front(); + } + return cur_values[idx] == ref_first; }), options.end()); } @@ -1212,10 +1221,8 @@ void Tab::update_all_extruder_options_status() auto dirty_options = m_presets->current_dirty_options(true); auto nonsys_options = m_presets->current_different_from_parent_options(true); - if (m_type == Preset::TYPE_PRINTER) { - drop_unchanged_added_entries(dirty_options, *m_config, &m_presets->get_selected_preset()); - drop_unchanged_added_entries(nonsys_options, *m_config, m_presets->get_selected_preset_parent()); - } + if (m_type == Preset::TYPE_PRINTER) + update_custom_dirty(dirty_options, nonsys_options); auto filter_extruder_options = [](const std::vector& options) { std::vector filtered_options; for (const auto& opt : options) { @@ -1264,8 +1271,7 @@ void Tab::update_extruder_switch_colors() if (m_active_page) { if (m_active_page->title() == "Speed" || m_active_page->title() == "Motion ability" || m_active_page->title() == "Filament" || - m_active_page->title() == "Setting Overrides" || m_active_page->title() == "Multimaterial" || - (m_type == Preset::TYPE_PRINTER && m_active_page->title() == "Extruder")) { + m_active_page->title() == "Setting Overrides" || m_active_page->title() == "Multimaterial" || is_printer_extruder_page(m_active_page)) { for (auto page_ptr : m_pages) { if (page_ptr.get() == m_active_page) { pages_to_check.push_back(page_ptr); @@ -1332,7 +1338,7 @@ void Tab::check_extruder_options_status(int index, bool &sys_extruder, bool &mod std::string target_opt_key = base_opt_key + "#" + std::to_string(config_index * stride); // Orca: on the printer's Extruder page only per-variant options use the variant column, // the others (nozzle_diameter, extruder_offset, ...) are indexed by the extruder. - if (m_type == Preset::TYPE_PRINTER && page->title() == "Extruder" && printer_options_with_variant_1.count(base_opt_key) == 0) + if (is_printer_extruder_page(page.get()) && printer_options_with_variant_1.count(base_opt_key) == 0) target_opt_key = base_opt_key + "#" + std::to_string(extruder_id); auto status_iter = m_all_extruder_options_status.find(target_opt_key); @@ -1374,7 +1380,6 @@ void TabPrinter::init_options_list() Tab::init_options_list(); if (m_printer_technology == ptFFF) m_options_list.emplace("extruders_count", m_opt_status_value); - // Orca: the single "Extruder" page only has the "#0" fields, which Tab::init_options_list() already lists. } void TabPrinter::msw_rescale() @@ -1464,8 +1469,7 @@ void Tab::update_changed_tree_ui() get_sys_and_mod_flags("compatible_printers", sys_page, modified_page); } } - if (page->title() == "Speed" || page->title() == "Motion ability" || page->title() == "Filament" || page->title() == "Setting Overrides" || page->title() == "Multimaterial" || - (m_type == Preset::TYPE_PRINTER && page->title() == "Extruder")) { + if (page->title() == "Speed" || page->title() == "Motion ability" || page->title() == "Filament" || page->title() == "Setting Overrides" || page->title() == "Multimaterial" || is_printer_extruder_page(page.get())) { auto options = generate_extruder_options(); for (size_t switch_index = 0; switch_index < options.size(); ++switch_index) { std::vector pages_to_check = { page }; @@ -1909,6 +1913,17 @@ static wxString pad_combo_value_for_config(const DynamicPrintConfig &config) return config.opt_bool("pad_enable") ? (config.opt_bool("pad_around_object") ? _("Around object") : _("Below object")) : _("None"); } +// Rebuilds the variant switch of every tab that has one, e.g. after the extruder count or a nozzle volume type changed. +static void update_all_extruder_variants(int extruder_idx = -1) +{ + for (auto tab : wxGetApp().tabs_list) + tab->update_extruder_variants(extruder_idx); + if (auto tab = wxGetApp().plate_tab) + tab->update_extruder_variants(extruder_idx); + for (auto tab : wxGetApp().model_tabs_list) + tab->update_extruder_variants(extruder_idx); +} + void Tab::on_value_change(const std::string& opt_key, const boost::any& value) { // Orca: @@ -2351,15 +2366,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) if (opt_key.find("nozzle_volume_type") != std::string::npos) { int extruder_idx = std::atoi(opt_key.substr(opt_key.find_last_of('#') + 1).c_str()); - for (auto tab : wxGetApp().tabs_list) { - tab->update_extruder_variants(extruder_idx); - } - if (auto tab = wxGetApp().plate_tab) { - tab->update_extruder_variants(extruder_idx); - } - for (auto tab : wxGetApp().model_tabs_list) { - tab->update_extruder_variants(extruder_idx); - } + update_all_extruder_variants(extruder_idx); if (wxGetApp().app_config->get("auto_calculate_flush") == "all") { wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(-1,extruder_idx); } @@ -2455,14 +2462,8 @@ void Tab::update_wiping_button_visibility() { } -void Tab::activate_option(const std::string& opt_key_in, const wxString& category_in) +void Tab::activate_option(const std::string& opt_key, const wxString& category) { - std::string opt_key = opt_key_in; - wxString category = category_in; - // Orca: "Extruder N" options live on the single Extruder page, select extruder N there first. - if (auto printer_tab = dynamic_cast(this)) - printer_tab->prepare_extruder_option_jump(opt_key, category); - wxString page_title = translate_category(category, m_type); auto cur_item = m_tabctrl->GetFirstVisibleItem(); @@ -5729,7 +5730,7 @@ if (is_marlin_flavor) update_dirty(); // Orca: the variant switches (here, Process in the sidebar, ...) list one option per extruder. if (m_extruders_count != old_extruders_count) - refresh_extruder_switches(); + update_all_extruder_variants(); if (opt_key == "single_extruder_multi_material") { // the single_extruder_multimaterial was added to force pages on_value_change(opt_key, value); // rebuild - let's make sure the on_value_change is not skipped @@ -5739,7 +5740,7 @@ if (is_marlin_flavor) // Orca: we use a different logic here. If SEMM is enabled, we set extruder count to 1. #if 1 extruders_count_changed(1); - refresh_extruder_switches(); + update_all_extruder_variants(); #else std::vector nozzle_diameters = @@ -5833,7 +5834,7 @@ if (is_marlin_flavor) optgroup->m_on_change = [this](const t_config_option_key& opt_key, boost::any value) { // The page edits the extruder selected on the variant switch. - const size_t extruder_idx = size_t(std::max(0, get_current_active_extruder())); + const size_t extruder_idx = size_t(get_current_active_extruder()); bool is_SEMM = m_config->opt_bool("single_extruder_multi_material"); if (is_SEMM && m_extruders_count > 1 && boost::starts_with(opt_key, "nozzle_diameter")) { @@ -5930,7 +5931,7 @@ if (is_marlin_flavor) } // The page holds only the "#0" controls, so register every extruder's options with the search - // index under "Extruder N"; a search hit selects that extruder (prepare_extruder_option_jump()). + // index under "Extruder N"; a search hit selects that extruder (TabPrinter::activate_option()). if (Page *page = extruder_page()) { auto &index = wxGetApp().sidebar().settings_index(); for (auto &group : page->m_optgroups) { @@ -6309,7 +6310,7 @@ void TabPrinter::toggle_options() // Orca: the single Extruder page edits the extruder selected on the variant switch; its // controls carry field index 0 (i), the values are read for `extruder`. const size_t i = 0; - const size_t extruder = std::min(size_t(std::max(0, get_current_active_extruder())), m_extruders_count - 1); + const size_t extruder = std::min(size_t(get_current_active_extruder()), m_extruders_count - 1); int variant_index = get_index_for_extruder(extruder); if (variant_index < 0) variant_index = int(extruder); @@ -6466,14 +6467,15 @@ void TabPrinter::on_value_change(const std::string& opt_key, const boost::any& v return; const int pos = opt_key.find("#"); + // Orca: fields of the single Extruder page keep index 0 but edit the selected extruder. + const int data_idx = pos > 0 ? extruder_page_data_index(opt_key) : -1; if (pos > 0) { std::string temp_str = opt_key; boost::erase_head(temp_str, pos + 1); int orig_opt_idx = static_cast(atoi(temp_str.c_str())); int opt_idx = orig_opt_idx >= 0 ? orig_opt_idx : 0; - // Orca: fields of the single Extruder page keep index 0 but edit the selected extruder. - if (const int data_idx = extruder_page_data_index(opt_key); data_idx >= 0) + if (data_idx >= 0) opt_idx = data_idx; std::string opt_key_pure = opt_key; @@ -6511,8 +6513,8 @@ void TabPrinter::on_value_change(const std::string& opt_key, const boost::any& v // Orca: report Extruder page changes as "key#", as the former "Extruder N" pages did, // so per-extruder handling in Tab::on_value_change() sees the extruder that was edited. - if (pos > 0 && extruder_page_data_index(opt_key) >= 0) - Tab::on_value_change(opt_key.substr(0, pos) + "#" + std::to_string(std::max(0, get_current_active_extruder())), value); + if (data_idx >= 0) + Tab::on_value_change(opt_key.substr(0, pos) + "#" + std::to_string(get_current_active_extruder()), value); else Tab::on_value_change(opt_key, value); } @@ -7446,10 +7448,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event) // update_undo_buttons(); this->OnActivate(); m_parent->set_active_tab(this); - if (m_variant_sizer) { - update_variant_sizer_visibility(); - GetParent()->Layout(); - } + update_variant_sizer_visibility(); m_page_view->Thaw(); return false; @@ -7460,10 +7459,7 @@ bool Tab::tree_sel_change_delayed(wxCommandEvent& event) return false; m_active_page = page; - if (m_variant_sizer) { - update_variant_sizer_visibility(); - GetParent()->Layout(); - } + update_variant_sizer_visibility(); auto throw_if_canceled = std::function([this](){ #ifdef WIN32 @@ -8310,7 +8306,7 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) m_extruder_switch->SetSelection(selection_index); m_extruder_switch->Enable(true); - m_extruder_sync->Enable(m_extruder_switch_variants); + m_extruder_sync->Enable(true); } else { m_extruder_switch->Enable(false); m_extruder_sync->Enable(false); @@ -8333,10 +8329,7 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) update_pages_with_multi_variant(); } update_extruder_switch_colors(); - if (m_variant_sizer) { - update_variant_sizer_visibility(); - GetParent()->Layout(); - } + update_variant_sizer_visibility(); } // The variant switch tags are the narrowest place a volume type is named, so they abbreviate it; @@ -8411,20 +8404,20 @@ std::vector Tab::generate_extruder_options() return options; } + // Orca: the printer tab has one tag per extruder, named as its former "Extruder N" pages were. + // parse_extruder_selection() counts a hybrid extruder as two tags; that still lines up because + // only the last extruder can be hybrid. + if (m_type == Preset::TYPE_PRINTER) { + for (int i = 0; i < extruder_nums; ++i) + options.push_back(translate_category(wxString::Format("Extruder %d", i + 1), m_type)); + return options; + } + std::string pt = m_preset_bundle->printers.get_edited_preset().get_printer_type(m_preset_bundle); - // Orca: the main/deputy toolhead names describe a dual-nozzle printer, where extruder 0 is the - // left (deputy) and extruder 1 the right (main) nozzle. From three extruders on the tools are - // interchangeable, so name them by index instead of repeating one side. - // Orca: Left/Right only names a Bambu dual-nozzle printer; other printers number their tools. + // Orca: the main/deputy toolhead names describe a Bambu dual-nozzle printer, where extruder 0 is + // the left (deputy) and extruder 1 the right (main) nozzle. Other printers number their tools. const bool toolhead_names = extruder_nums == 2 && m_preset_bundle->is_bbl_vendor(); for (int i = 0; i < extruder_nums; ++i) { - // Orca: the printer tab has one tag per extruder, named as its former "Extruder N" pages were. - // parse_extruder_selection() counts a hybrid extruder as two tags; that still lines up because - // only the last extruder can be hybrid. - if (m_type == Preset::TYPE_PRINTER) { - options.push_back(translate_category(wxString::Format("Extruder %d", i + 1), m_type)); - continue; - } wxString extruder_name = !toolhead_names ? wxString::Format("T%d", i + 1) : _L(DevPrinterConfigUtil::get_toolhead_display_name( pt, (i == 0) ? DEPUTY_EXTRUDER_ID : MAIN_EXTRUDER_ID, @@ -8474,41 +8467,27 @@ void TabPrinter::sync_extruders_count() return; extruders_count_changed(nozzle_diameter->size()); init_options_list(); - refresh_extruder_switches(); + update_all_extruder_variants(); } -void TabPrinter::refresh_extruder_switches() +void TabPrinter::activate_option(const std::string &opt_key, const wxString &category) { - // The same tabs a nozzle_volume_type change refreshes in Tab::on_value_change(). - for (auto tab : wxGetApp().tabs_list) - tab->update_extruder_variants(); - if (auto tab = wxGetApp().plate_tab) - tab->update_extruder_variants(); - for (auto tab : wxGetApp().model_tabs_list) - tab->update_extruder_variants(); -} - -void TabPrinter::prepare_extruder_option_jump(std::string &opt_key, wxString &category) -{ - if (extruder_page() == nullptr) - return; - - int extruder_idx = 0; wxString number; long n = 0; - if (category.StartsWith("Extruder ", &number) && number.ToLong(&n)) { - if (n >= 1 && n <= long(m_extruders_count)) - extruder_idx = int(n - 1); - } else if (category != "Extruder") + const bool numbered = category.StartsWith("Extruder ", &number) && number.ToLong(&n); + if (extruder_page() == nullptr || (!numbered && category != "Extruder")) { + Tab::activate_option(opt_key, category); return; - - category = "Extruder"; - if (auto pos = opt_key.find('#'); pos != std::string::npos) - opt_key = opt_key.substr(0, pos) + "#0"; // the page's controls are created for index 0 + } // Selecting fires the switch's event, which re-targets the page (switch_excluder()). + const int extruder_idx = (n >= 1 && n <= long(m_extruders_count)) ? int(n - 1) : 0; if (m_extruder_switch && m_extruder_switch->IsThisEnabled() && extruder_idx != get_current_active_extruder()) m_extruder_switch->SetSelection(calculate_selection_index_for_extruder(extruder_idx, get_actual_nozzle_volume_type(extruder_idx))); + + // The page's controls are created for index 0. + const auto pos = opt_key.find('#'); + Tab::activate_option(pos == std::string::npos ? opt_key : opt_key.substr(0, pos) + "#0", "Extruder"); } NozzleVolumeType Tab::get_actual_nozzle_volume_type(int extruder_id) @@ -8598,19 +8577,17 @@ void Tab::update_variant_sizer_visibility() { if (!m_variant_sizer) return; - bool show = false; - if (m_type == Preset::TYPE_PRINTER && m_active_page && m_active_page->title() == "Extruder") - // Orca: the single Extruder page edits the extruder selected on the switch. - show = m_extruder_switch && m_extruder_switch->IsThisEnabled() && m_extruder_switch->GetCount() > 1; - else - show = variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty() && !m_active_page->title().StartsWith("Extruder"); + // Orca: the single Extruder page edits the extruder selected on the switch. + const bool on_extruder_page = is_printer_extruder_page(m_active_page); + const bool show = on_extruder_page ? m_extruder_switch && m_extruder_switch->IsThisEnabled() && m_extruder_switch->GetCount() > 1 : + variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty(); m_main_sizer->Show(m_variant_sizer, show); - if (m_extruder_sync && m_extruder_switch) { + if (m_extruder_sync) { m_extruder_sync->Show(show); // Copying between extruders is offered on the variant pages only. - const bool on_extruder_page = m_type == Preset::TYPE_PRINTER && m_active_page && m_active_page->title() == "Extruder"; m_extruder_sync->Enable(!on_extruder_page && variant_switch_active() && get_extruder_sync_enable_state(get_current_active_extruder())); } + GetParent()->Layout(); } void Tab::switch_excluder(int extruder_id, bool reload) @@ -8623,7 +8600,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) extruder_id = 0; // Orca: the printer's single Extruder page follows the switch for any multi-extruder printer; // the other pages only when the switch selects nozzle variants. - const bool on_extruder_page = m_type == Preset::TYPE_PRINTER && m_active_page && m_active_page->title() == "Extruder"; + const bool on_extruder_page = is_printer_extruder_page(m_active_page); if (m_extruder_switch) { int current_extruder = get_current_active_extruder(); bool sync_enable = get_extruder_sync_enable_state(current_extruder); @@ -8651,9 +8628,9 @@ void Tab::switch_excluder(int extruder_id, bool reload) }; // Extruder of the printer's Extruder page, and of the other pages (the first one when the switch // does not select variants). - const int page_extruder = m_type == Preset::TYPE_PRINTER ? std::max(0, extruder_id == -1 ? get_current_active_extruder() : extruder_id) : extruder_id; - const int common_extruder = (m_type == Preset::TYPE_PRINTER && !m_extruder_switch_variants) ? 0 : extruder_id; - auto index = m_variant_combo ? extruder_id : get_index_for_extruder(common_extruder == -1 ? 0 : common_extruder); + const int page_extruder = extruder_id == -1 ? get_current_active_extruder() : extruder_id; + const int common_extruder = (m_type == Preset::TYPE_PRINTER && !m_extruder_switch_variants) || extruder_id == -1 ? 0 : extruder_id; + auto index = m_variant_combo ? extruder_id : get_index_for_extruder(common_extruder); if (index < 0) return; if (m_extruder_switch) m_extruder_switch->SetClientData(reinterpret_cast(static_cast(index))); @@ -8668,7 +8645,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) if (page_index < 0) page_index = page_extruder; } else if (page->title().StartsWith("Motion ability")) { - page_index = get_index_for_extruder(common_extruder == -1 ? 0 : common_extruder, 2); + page_index = get_index_for_extruder(common_extruder, 2); } } page->m_opt_id_map.clear(); @@ -8691,7 +8668,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) if (opt.second.second >= 0) { const_cast(opt.second.second) = page_index; page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(page_index), opt.first}); - group->draw_multi_extruder = !is_extruder && variant_switch_active(); + group->draw_multi_extruder = variant_switch_active(); } } } diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index 7c8b3f5fc9..c02ef74823 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -393,6 +393,8 @@ public: void update_extruder_switch_colors(); // Whether the variant switch (m_extruder_switch / m_variant_combo) switches nozzle variants. bool variant_switch_active() const; + // Orca: whether `page` is the printer tab's single "Extruder" page, which edits the extruder selected on the switch. + bool is_printer_extruder_page(const Page* page) const { return m_type == Preset::TYPE_PRINTER && page && page->title() == "Extruder"; } // Shows the variant switch row on variant pages, and on the printer tab's "Extruder" page. void update_variant_sizer_visibility(); void update_all_extruder_options_status(); @@ -452,7 +454,7 @@ public: virtual void on_value_change(const std::string& opt_key, const boost::any& value); void update_wiping_button_visibility(); - void activate_option(const std::string& opt_key, const wxString& category); + virtual void activate_option(const std::string& opt_key, const wxString& category); void apply_searcher(); void cache_config_diff(const std::vector& selected_options, const DynamicPrintConfig* config = nullptr); void apply_config_from_cache(); @@ -724,13 +726,11 @@ public: Page* extruder_page() const; // Config index an "Extruder" page field (e.g. "retraction_length#0") currently edits, -1 if not on that page. int extruder_page_data_index(const std::string& field_id) const; - // After the user changed the extruder count: rebuild every tab's variant switch. - void refresh_extruder_switches(); // After the config was restored (roll back): follow its extruder count, if it differs. void sync_extruders_count(); - // Search jump to "Extruder N" / "key#N": selects extruder N on the switch, and rewrites the - // option to the page's own field id and the category to the page title. - void prepare_extruder_option_jump(std::string& opt_key, wxString& category); + // Search jump to "Extruder N" / "key#N": selects extruder N on the switch, then activates the + // page's own field on the "Extruder" page. + void activate_option(const std::string& opt_key, const wxString& category) override; protected: // Orca: values of extruders added by raising the extruder count have no saved / system value to From c740ddf0a62e0f5dc21f9e1d6af128fcb2c5b8a2 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 7 Oct 2026 01:45:24 +0800 Subject: [PATCH 05/22] Publish each extruder's own retraction and Z-hop values --- src/slic3r/GUI/PublishSettingsDialog.cpp | 4 +++- src/slic3r/GUI/Tab.cpp | 24 ++++++++++++------------ src/slic3r/GUI/Tab.hpp | 3 +++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/PublishSettingsDialog.cpp b/src/slic3r/GUI/PublishSettingsDialog.cpp index 70cdfe51c9..7beb3bd9dd 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.cpp +++ b/src/slic3r/GUI/PublishSettingsDialog.cpp @@ -882,6 +882,8 @@ void PublishSettingsDialog::build_option_model() const size_t extruders_count = printer_tab->m_extruders_count; for (size_t extruder_idx = 0; extruder_idx < extruders_count; ++extruder_idx) { const wxString page_title = Tab::translate_category(extruders_count > 1 ? wxString::Format("Extruder %d", int(extruder_idx + 1)) : wxString("Extruder"), tab->m_type); + // Retraction and Z-Hop values are stored per variant column, not per extruder. + const int variant_index = printer_tab->extruder_variant_index(int(extruder_idx)); for (const ConfigOptionsGroupShp& optgroup : page->m_optgroups) { // Allowlist on the untranslated optgroup title; the "Retraction when // switching material" group is intentionally skipped. @@ -893,7 +895,7 @@ void PublishSettingsDialog::build_option_model() // Rows are keyed by the full per-extruder "#N" opt_id so each extruder // tab publishes its own value; GetPublishedKeys() emits the checked rows // as-is. - const std::string opt_id = pure_key + "#" + std::to_string(extruder_idx); + const std::string opt_id = pure_key + "#" + std::to_string(variant_index); if (!printer_added.insert(opt_id).second) continue; wxString label, value, unit; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 2c6fbff835..80b930c35e 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -6225,12 +6225,6 @@ void TabPrinter::toggle_options() return; auto nozzle_volumes = m_preset_bundle->project_config.option("nozzle_volume_type"); - auto extruders = m_config->option("extruder_type"); - auto get_index_for_extruder = - [this, &extruders](int extruder_id, int stride = 1) { - return m_config->get_index_for_extruder(extruder_id + 1, "printer_extruder_id", - ExtruderType(extruders->values[extruder_id]), get_actual_nozzle_volume_type(extruder_id), "printer_extruder_variant", stride); - }; //BBS: whether the preset is Bambu Lab printer bool is_BBL_printer = false; @@ -6311,9 +6305,7 @@ void TabPrinter::toggle_options() // controls carry field index 0 (i), the values are read for `extruder`. const size_t i = 0; const size_t extruder = std::min(size_t(get_current_active_extruder()), m_extruders_count - 1); - int variant_index = get_index_for_extruder(extruder); - if (variant_index < 0) - variant_index = int(extruder); + const int variant_index = extruder_variant_index(int(extruder)); bool have_retract_length = m_config->opt_float("retraction_length", variant_index) > 0; toggle_option("extruder_printable_area", false, i); // disable @@ -8452,6 +8444,16 @@ int TabPrinter::extruder_page_data_index(const std::string &field_id) const return -1; } +int TabPrinter::extruder_variant_index(int extruder) +{ + const auto *extruders = m_config->option("extruder_type"); + const int index = extruder < int(extruders->size()) ? + m_config->get_index_for_extruder(extruder + 1, "printer_extruder_id", ExtruderType(extruders->values[extruder]), + get_actual_nozzle_volume_type(extruder), "printer_extruder_variant") : + -1; + return index < 0 ? extruder : index; +} + void TabPrinter::update_custom_dirty(std::vector &dirty_options, std::vector &nonsys_options) { drop_unchanged_added_entries(dirty_options, *m_config, &m_presets->get_selected_preset()); @@ -8641,9 +8643,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) if (m_type == Preset::TYPE_PRINTER) { if (page->title() == "Extruder") { is_extruder = true; - page_index = page_extruder < int(extruders->size()) ? get_index_for_extruder(page_extruder) : -1; - if (page_index < 0) - page_index = page_extruder; + page_index = static_cast(this)->extruder_variant_index(page_extruder); } else if (page->title().StartsWith("Motion ability")) { page_index = get_index_for_extruder(common_extruder, 2); } diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index c02ef74823..f7ebafcbe3 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -726,6 +726,9 @@ public: Page* extruder_page() const; // Config index an "Extruder" page field (e.g. "retraction_length#0") currently edits, -1 if not on that page. int extruder_page_data_index(const std::string& field_id) const; + // Config index of an extruder's per-variant options (Retraction, Z-Hop, ...): its variant column + // for the nozzle selected on the switch, or the extruder index on a printer without variants. + int extruder_variant_index(int extruder); // After the config was restored (roll back): follow its extruder count, if it differs. void sync_extruders_count(); // Search jump to "Extruder N" / "key#N": selects extruder N on the switch, then activates the From 82349e1ba4ede0bfa92320bb471ce516417d77e7 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 7 Oct 2026 13:41:42 +0800 Subject: [PATCH 06/22] Give each extruder its own machine limits --- src/libslic3r/PrintConfig.cpp | 89 ++++++++++--------- src/slic3r/GUI/Tab.cpp | 12 +-- .../test_config_variant_expansion.cpp | 37 ++++++++ 3 files changed, 91 insertions(+), 47 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 832ff9b3b4..6c3caafdc4 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -10032,6 +10032,48 @@ static void extend_extruder_variant(DynamicPrintConfig& config, const unsigned i } } +// Options in printer_options_with_variant_2 are stored as (normal,silent) pairs per printer variant. +// Some legacy presets/projects carry a variant list but still store only one pair; normalize to avoid crashes. +static void normalize_stride2_floats(ConfigOptionFloats &opt, size_t expected_size) +{ + auto &v = opt.values; + if (expected_size == 0) { + v.clear(); + return; + } + if (v.empty()) { + // Fallback: keep behavior predictable instead of crashing. This should be rare. + v.resize(expected_size, 0.0); + return; + } + + const double first = v[0]; + const double second = (v.size() >= 2) ? v[1] : first; + + // Ensure we have at least one (normal,silent) pair to replicate. + if (v.size() < 2) { + v.resize(2, first); + v[1] = second; + } + // Keep pair alignment if some legacy preset produced odd length. + if (v.size() % 2 != 0) + v.push_back(second); + + if (v.size() > expected_size) { + v.resize(expected_size); + return; + } + + const size_t have_variants = v.size() / 2; + const size_t want_variants = expected_size / 2; + v.resize(expected_size); + for (size_t vi = have_variants; vi < want_variants; ++vi) { + v[vi * 2] = first; + if (vi * 2 + 1 < v.size()) + v[vi * 2 + 1] = second; + } +} + void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders) { extend_extruder_variant(*this, num_extruders); @@ -10049,6 +10091,11 @@ void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders) static_cast(opt)->resize(get_parameter_size(key, num_extruders), defaults.option(key)); } } + // Orca: machine limits are not extruder option keys and need a pair-aware resize, so that every + // printer variant has its own (normal, silent) pair to edit. + for (const std::string &key : printer_options_with_variant_2) + if (auto *opt = this->option(key)) + normalize_stride2_floats(*opt, get_parameter_size(key, num_extruders)); } // BBS @@ -11446,48 +11493,6 @@ void DynamicPrintConfig::update_filament_config_values_for_multiple_extruders(Dy } namespace { -// Options in printer_options_with_variant_2 are stored as (normal,silent) pairs per printer variant. -// Some legacy presets/projects carry a variant list but still store only one pair; normalize to avoid crashes. -static void normalize_stride2_floats(ConfigOptionFloats &opt, size_t expected_size) -{ - auto &v = opt.values; - if (expected_size == 0) { - v.clear(); - return; - } - if (v.empty()) { - // Fallback: keep behavior predictable instead of crashing. This should be rare. - v.resize(expected_size, 0.0); - return; - } - - const double first = v[0]; - const double second = (v.size() >= 2) ? v[1] : first; - - // Ensure we have at least one (normal,silent) pair to replicate. - if (v.size() < 2) { - v.resize(2, first); - v[1] = second; - } - // Keep pair alignment if some legacy preset produced odd length. - if (v.size() % 2 != 0) - v.push_back(second); - - if (v.size() > expected_size) { - v.resize(expected_size); - return; - } - - const size_t have_variants = v.size() / 2; - const size_t want_variants = expected_size / 2; - v.resize(expected_size); - for (size_t vi = have_variants; vi < want_variants; ++vi) { - v[vi * 2] = first; - if (vi * 2 + 1 < v.size()) - v[vi * 2 + 1] = second; - } -} - static void log_normalize_legacy_vector_size(const char *fn, const std::string &key, int stride, size_t src_size, size_t dest_size, size_t expected_size, size_t restore_n, int cur_variant_count, int target_variant_count, size_t cur_ids, size_t target_ids, const ConfigOption *opt_src, const ConfigOption *opt_target) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 80b930c35e..e064043eba 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1161,8 +1161,9 @@ std::string Tab::options_list_storage_key(const std::string& opt_key) const // Orca: deep_diff() flags every vector entry at or past the reference vector's length as changed, // whatever its value (e.g. the values of an extruder added by raising the extruder count). A vector -// grows by copying its first entry (ConfigOptionVector::resize), so such an entry only counts as -// changed when it differs from the reference's first entry, as before Orca's deep_diff() change. +// grows by copying its first entry (ConfigOptionVector::resize), and machine limits by copying their +// first (normal, silent) pair (set_num_extruders), so such an entry only counts as changed when it +// differs from the reference entry it was copied from, as before Orca's deep_diff() change. // The change of the count itself shows on "extruders_count". static void drop_unchanged_added_entries(std::vector &options, const DynamicPrintConfig ¤t, const Preset *reference) { @@ -1171,7 +1172,7 @@ static void drop_unchanged_added_entries(std::vector &options, cons // deep_diff() lists a key's entries one after another, so serialize each key's vectors once. std::string serialized_key; std::vector cur_values; - std::string ref_first; + std::vector ref_values; options.erase(std::remove_if(options.begin(), options.end(), [&](const std::string &opt) { const auto pos = opt.find('#'); if (pos == std::string::npos) @@ -1185,9 +1186,10 @@ static void drop_unchanged_added_entries(std::vector &options, cons if (key != serialized_key) { serialized_key = key; cur_values = cur->vserialize(); - ref_first = ref->vserialize().front(); + ref_values = ref->vserialize(); } - return cur_values[idx] == ref_first; + const size_t copied_from = printer_options_with_variant_2.count(key) > 0 && idx % 2 < ref_values.size() ? idx % 2 : 0; + return cur_values[idx] == ref_values[copied_from]; }), options.end()); } diff --git a/tests/libslic3r/test_config_variant_expansion.cpp b/tests/libslic3r/test_config_variant_expansion.cpp index 240a6e25fa..5880e21645 100644 --- a/tests/libslic3r/test_config_variant_expansion.cpp +++ b/tests/libslic3r/test_config_variant_expansion.cpp @@ -799,3 +799,40 @@ TEST_CASE("A per-variant filament option read with a single value gives it to ev config.load_from_ini_string("pressure_advance = 0.021", ForwardCompatibilitySubstitutionRule::Disable); REQUIRE(config.option("pressure_advance")->values == std::vector({0.021, 0.021, 0.021})); } + +// Machine limits (printer_options_with_variant_2) hold a (normal, silent) pair per printer variant, so the +// printer Tab's Motion ability page can edit each extruder's own limits. +TEST_CASE("set_num_extruders gives every printer variant its own pair of machine limits", "[Config]") +{ + DynamicPrintConfig config = DynamicPrintConfig::full_print_config(); + auto speed_x = [&config]() { return config.option("machine_max_speed_x")->values; }; + + SECTION("a single pair is copied to every extruder") { + config.option("machine_max_speed_x")->values = {500., 200.}; + config.set_num_extruders(3); + REQUIRE(config.option("printer_extruder_variant")->size() == 3); + REQUIRE(speed_x() == std::vector({500., 200., 500., 200., 500., 200.})); + } + + SECTION("per-extruder pairs are kept, and removing an extruder removes its pair") { + config.option("machine_max_speed_x")->values = {500., 200., 400., 150., 300., 100.}; + config.set_num_extruders(3); + REQUIRE(speed_x() == std::vector({500., 200., 400., 150., 300., 100.})); + config.set_num_extruders(2); + REQUIRE(speed_x() == std::vector({500., 200., 400., 150.})); + } + + SECTION("a printer with nozzle variants gets a pair per variant column") { + // 2 extruders x 2 variants = 4 columns + config.option("extruder_variant_list", true)->values = {"Direct Drive Standard,Direct Drive High Flow", + "Direct Drive Standard,Direct Drive High Flow"}; + const std::vector per_variant = {500., 200., 510., 210., 520., 220., 530., 230.}; + config.option("machine_max_speed_x")->values = per_variant; + config.set_num_extruders(2); + REQUIRE(speed_x() == per_variant); + + config.option("machine_max_speed_x")->values = {500., 200.}; + config.set_num_extruders(2); + REQUIRE(speed_x() == std::vector({500., 200., 500., 200., 500., 200., 500., 200.})); + } +} From ba5ecc5470e369a0399ca44ee499d04c5ddbf199 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 7 Oct 2026 13:41:42 +0800 Subject: [PATCH 07/22] Edit the selected extruder's machine limits on the Motion ability page --- src/slic3r/GUI/Tab.cpp | 43 ++++++++++++++++++------------------------ src/slic3r/GUI/Tab.hpp | 9 +++++---- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e064043eba..55067f14ca 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -8279,9 +8279,9 @@ void Tab::update_extruder_variants(int extruder_id, bool reload) m_actual_nozzle_volumes.resize(extruder_nums, NozzleVolumeType::nvtStandard); for (int i = 0; i < extruder_nums; i++) m_actual_nozzle_volumes[i] = (NozzleVolumeType)nozzle_volumes->values[i]; - // Orca: a non-Bambu dual-nozzle printer has two extruders but a single variant column, so - // the nozzle switch and sync button have nothing to act on on the variant pages. The printer - // tab still enables the switch to choose the extruder its single "Extruder" page edits. + // Orca: when every extruder uses the same variant (e.g. a non-Bambu dual-nozzle printer), the + // switch has no nozzle variants to select and nothing to sync. The printer tab still enables it + // to choose the extruder its Extruder and Motion ability pages edit. m_extruder_switch_variants = extruder_nums >= 2 && m_preset_bundle->support_different_extruders(); if (m_extruder_switch_variants || (m_type == Preset::TYPE_PRINTER && extruder_nums >= 2)) { auto options = generate_extruder_options(); @@ -8573,7 +8573,7 @@ bool Tab::get_extruder_sync_enable_state(int extruder_id) bool Tab::variant_switch_active() const { if (m_extruder_switch) - return m_extruder_switch->IsThisEnabled() && m_extruder_switch_variants; + return m_extruder_switch->IsThisEnabled(); return m_variant_combo && m_variant_combo->IsThisEnabled(); } @@ -8581,15 +8581,13 @@ void Tab::update_variant_sizer_visibility() { if (!m_variant_sizer) return; - // Orca: the single Extruder page edits the extruder selected on the switch. - const bool on_extruder_page = is_printer_extruder_page(m_active_page); - const bool show = on_extruder_page ? m_extruder_switch && m_extruder_switch->IsThisEnabled() && m_extruder_switch->GetCount() > 1 : - variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty(); + const bool show = variant_switch_active() && m_active_page && !m_active_page->m_opt_id_map.empty(); m_main_sizer->Show(m_variant_sizer, show); if (m_extruder_sync) { m_extruder_sync->Show(show); - // Copying between extruders is offered on the variant pages only. - m_extruder_sync->Enable(!on_extruder_page && variant_switch_active() && get_extruder_sync_enable_state(get_current_active_extruder())); + // Orca: copying between extruders is offered only between nozzle variants, and not on the Extruder page. + m_extruder_sync->Enable(m_extruder_switch_variants && !is_printer_extruder_page(m_active_page) && + get_extruder_sync_enable_state(get_current_active_extruder())); } GetParent()->Layout(); } @@ -8600,15 +8598,16 @@ void Tab::switch_excluder(int extruder_id, bool reload) auto nozzle_volumes = m_preset_bundle->project_config.option("nozzle_volume_type"); auto extruders = printer_preset.config.option("extruder_type"); + // Orca: the printer tab re-targets its pages to the extruder selected on the switch. Resolved before + // the range check below, which keeps the extruder_type read in get_index_for_extruder in range. + if (m_type == Preset::TYPE_PRINTER && extruder_id == -1) + extruder_id = get_current_active_extruder(); if (!m_variant_combo && (extruder_id >= (int)nozzle_volumes->size() || extruder_id >= (int)extruders->size())) extruder_id = 0; - // Orca: the printer's single Extruder page follows the switch for any multi-extruder printer; - // the other pages only when the switch selects nozzle variants. - const bool on_extruder_page = is_printer_extruder_page(m_active_page); if (m_extruder_switch) { int current_extruder = get_current_active_extruder(); bool sync_enable = get_extruder_sync_enable_state(current_extruder); - m_extruder_sync->Enable(variant_switch_active() && sync_enable && !on_extruder_page); + m_extruder_sync->Enable(m_extruder_switch_variants && sync_enable && !is_printer_extruder_page(m_active_page)); m_extruder_sync->Show(); if (m_type != Preset::TYPE_PRINTER) { if (extruder_id == -1) @@ -8630,11 +8629,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) return m_config->get_index_for_extruder(extruder_id + 1, variant_keys.first, ExtruderType(extruders->values[extruder_id]), get_actual_nozzle_volume_type(extruder_id), variant_keys.second, stride); }; - // Extruder of the printer's Extruder page, and of the other pages (the first one when the switch - // does not select variants). - const int page_extruder = extruder_id == -1 ? get_current_active_extruder() : extruder_id; - const int common_extruder = (m_type == Preset::TYPE_PRINTER && !m_extruder_switch_variants) || extruder_id == -1 ? 0 : extruder_id; - auto index = m_variant_combo ? extruder_id : get_index_for_extruder(common_extruder); + auto index = m_variant_combo ? extruder_id : get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id); if (index < 0) return; if (m_extruder_switch) m_extruder_switch->SetClientData(reinterpret_cast(static_cast(index))); @@ -8643,12 +8638,10 @@ void Tab::switch_excluder(int extruder_id, bool reload) bool is_extruder = false; int page_index = index; if (m_type == Preset::TYPE_PRINTER) { - if (page->title() == "Extruder") { + if (page->title() == "Extruder") is_extruder = true; - page_index = static_cast(this)->extruder_variant_index(page_extruder); - } else if (page->title().StartsWith("Motion ability")) { - page_index = get_index_for_extruder(common_extruder, 2); - } + else if (page->title().StartsWith("Motion ability")) + page_index = get_index_for_extruder(extruder_id == -1 ? 0 : extruder_id, 2); } page->m_opt_id_map.clear(); for (auto group : page->m_optgroups) { @@ -8656,7 +8649,7 @@ void Tab::switch_excluder(int extruder_id, bool reload) if (is_extruder && opt.second.second >= 0) { // Per-variant options use the variant column, the others (nozzle_diameter, // extruder_offset, ...) are sized by the extruder count and use the extruder. - const int idx = printer_options_with_variant_1.count(opt.second.first) > 0 ? page_index : page_extruder; + const int idx = printer_options_with_variant_1.count(opt.second.first) > 0 ? page_index : extruder_id; const_cast(opt.second.second) = idx; page->m_opt_id_map.insert({opt.second.first + "#" + std::to_string(idx), opt.first}); continue; diff --git a/src/slic3r/GUI/Tab.hpp b/src/slic3r/GUI/Tab.hpp index f7ebafcbe3..e916dd6f7d 100644 --- a/src/slic3r/GUI/Tab.hpp +++ b/src/slic3r/GUI/Tab.hpp @@ -331,9 +331,9 @@ public: MultiSwitchButton * m_variant_combo = nullptr; ScalableButton *m_extruder_sync = nullptr; wxPanel * m_extruder_sync_box = nullptr; - // Orca: whether m_extruder_switch switches nozzle variants (it is then shown on the variant pages). + // Orca: whether m_extruder_switch switches nozzle variants (it then offers sync between them). // The printer tab also enables the switch for printers without variants, to choose the extruder - // its single "Extruder" page edits. + // its Extruder and Motion ability pages edit. bool m_extruder_switch_variants = false; std::vector m_actual_nozzle_volumes; @@ -391,11 +391,12 @@ public: void update_changed_tree_ui(); void update_undo_buttons(); void update_extruder_switch_colors(); - // Whether the variant switch (m_extruder_switch / m_variant_combo) switches nozzle variants. + // Whether the variant switch (m_extruder_switch / m_variant_combo) is enabled: on the printer tab for + // any multi-extruder printer, on the other tabs when it switches nozzle variants. bool variant_switch_active() const; // Orca: whether `page` is the printer tab's single "Extruder" page, which edits the extruder selected on the switch. bool is_printer_extruder_page(const Page* page) const { return m_type == Preset::TYPE_PRINTER && page && page->title() == "Extruder"; } - // Shows the variant switch row on variant pages, and on the printer tab's "Extruder" page. + // Shows the variant switch row on pages with options that follow it. void update_variant_sizer_visibility(); void update_all_extruder_options_status(); void check_extruder_options_status(int index, bool &sys_extruder, bool &modified_extruder, const std::vector& pages_to_check); From 73d32d47916c45b609710bcc4728ee890ac02335 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:22:16 +0800 Subject: [PATCH 08/22] Stop Leaking json Through Headers and Drop Includes Kept Only for the Name (#16221) * Stop Leaking json Through Headers and Drop Includes Kept Only for the Name AppConfig.hpp, DeviceManager.hpp and UserManager.hpp carried a global "using namespace nlohmann;", json_diff.hpp a global "using json = nlohmann::json;" and PrinterFileSystem.h a global "using nlohmann::json;". Every file that included one of them, directly or not, could write a bare json, and 63 did without declaring it. The last two also made the include checker treat json_diff.hpp and PrinterFileSystem.h as the headers that provide json, so they were included from files that use nothing else from them: 57 of the 59 includers of json_diff.hpp never name json_diff. The five statements are removed. Headers that use the type now spell nlohmann::json, source files declare their own "using json = nlohmann::json;", and the includes that only supplied the name are dropped or replaced by . Eight files reached json_diff.hpp only through an include that is now gone and with it lost that header's "using namespace std;". The std names they used unqualified are qualified. * Declare json in OrcaSlicer.cpp on Every Platform OrcaSlicer.cpp had its "using namespace nlohmann;" and the json include inside the Linux-only include block, so on Windows and macOS it took json from AppConfig.hpp's global directive, which is gone. The include and a "using json = nlohmann::json;" now sit outside the block. --- src/OrcaSlicer.cpp | 12 ++++----- src/libslic3r/AppConfig.hpp | 2 -- src/libslic3r/Preset.cpp | 1 + src/libslic3r/PresetBundle.cpp | 2 ++ src/slic3r/GUI/3DScene.cpp | 2 +- src/slic3r/GUI/Auxiliary.cpp | 1 + src/slic3r/GUI/Auxiliary.hpp | 4 +-- src/slic3r/GUI/BindDialog.cpp | 4 ++- src/slic3r/GUI/CreatePresetsDialog.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevAxis.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevAxis.h | 3 +-- src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevBed.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevBed.h | 5 ++-- src/slic3r/GUI/DeviceCore/DevCalib.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevCalib.h | 15 +++++------ src/slic3r/GUI/DeviceCore/DevChamber.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevChamber.h | 7 +++-- src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevConfig.cpp | 1 - src/slic3r/GUI/DeviceCore/DevConfig.h | 10 +++---- src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp | 2 +- src/slic3r/GUI/DeviceCore/DevCtrl.cpp | 1 - src/slic3r/GUI/DeviceCore/DevCtrl.h | 6 ++--- src/slic3r/GUI/DeviceCore/DevExtensionTool.h | 2 +- .../GUI/DeviceCore/DevExtruderSystem.cpp | 1 - src/slic3r/GUI/DeviceCore/DevExtruderSystem.h | 2 +- src/slic3r/GUI/DeviceCore/DevFan.cpp | 1 - src/slic3r/GUI/DeviceCore/DevFan.h | 11 ++++---- .../GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp | 4 ++- .../GUI/DeviceCore/DevFilaBlackList.cpp | 1 - src/slic3r/GUI/DeviceCore/DevFilaBlackList.h | 4 +-- src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp | 1 - src/slic3r/GUI/DeviceCore/DevFilaSystem.h | 6 ++--- .../GUI/DeviceCore/DevFilaSystemCtrl.cpp | 1 - src/slic3r/GUI/DeviceCore/DevFirmware.h | 8 +++--- src/slic3r/GUI/DeviceCore/DevHMS.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevHMS.h | 6 ++--- src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp | 1 - src/slic3r/GUI/DeviceCore/DevManager.cpp | 1 - src/slic3r/GUI/DeviceCore/DevManager.h | 1 - .../GUI/DeviceCore/DevMappingNozzle.cpp | 1 - src/slic3r/GUI/DeviceCore/DevNozzleRack.h | 2 +- .../GUI/DeviceCore/DevNozzleRackCtrl.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevNozzleSystem.h | 4 +-- src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevStorage.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevStorage.h | 3 +-- src/slic3r/GUI/DeviceCore/DevUpgrade.cpp | 4 ++- src/slic3r/GUI/DeviceCore/DevUpgrade.h | 7 +++-- src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp | 4 ++- src/slic3r/GUI/DeviceManager.cpp | 4 ++- src/slic3r/GUI/DeviceManager.hpp | 19 +++++++------ src/slic3r/GUI/ExportPresetBundleDialog.hpp | 2 +- src/slic3r/GUI/GCodeViewer.cpp | 14 +++++----- src/slic3r/GUI/GUI_App.cpp | 1 + src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 2 +- src/slic3r/GUI/HMS.cpp | 3 ++- src/slic3r/GUI/IMSlider.cpp | 2 +- src/slic3r/GUI/Jobs/PrintJob.cpp | 3 ++- src/slic3r/GUI/Jobs/SendJob.cpp | 3 ++- src/slic3r/GUI/MainFrame.cpp | 4 ++- src/slic3r/GUI/MediaFilePanel.cpp | 2 ++ src/slic3r/GUI/ModelMall.cpp | 4 ++- src/slic3r/GUI/Monitor.cpp | 4 ++- src/slic3r/GUI/NotificationManager.hpp | 4 +-- src/slic3r/GUI/PresetBundleDialog.cpp | 5 +++- src/slic3r/GUI/Printer/PrinterFileSystem.cpp | 2 ++ src/slic3r/GUI/Printer/PrinterFileSystem.h | 15 +++++------ src/slic3r/GUI/PrinterCloudAuthDialog.cpp | 4 ++- src/slic3r/GUI/Project.cpp | 5 ++-- src/slic3r/GUI/Project.hpp | 3 +-- src/slic3r/GUI/ReleaseNote.cpp | 2 ++ src/slic3r/GUI/SelectMachine.cpp | 4 ++- src/slic3r/GUI/SendMultiMachinePage.cpp | 3 ++- src/slic3r/GUI/StatusPanel.hpp | 4 +-- src/slic3r/GUI/SyncAmsInfoDialog.cpp | 3 ++- src/slic3r/GUI/TaskManager.cpp | 1 - src/slic3r/GUI/UserManager.cpp | 4 ++- src/slic3r/GUI/UserManager.hpp | 3 --- src/slic3r/GUI/WebDownPluginDlg.cpp | 2 +- src/slic3r/GUI/WebGuideDialog.cpp | 3 +-- src/slic3r/GUI/WebUserLoginDialog.cpp | 1 - src/slic3r/GUI/WebViewDialog.cpp | 3 ++- src/slic3r/GUI/Widgets/FanControl.cpp | 4 ++- src/slic3r/GUI/Widgets/MultiNozzleSync.cpp | 3 ++- src/slic3r/GUI/WipeTowerDialog.cpp | 5 ++-- src/slic3r/GUI/wxExtensions.cpp | 4 +-- src/slic3r/Utils/CalibUtils.cpp | 3 ++- src/slic3r/Utils/PresetUpdater.cpp | 4 ++- src/slic3r/Utils/json_diff.hpp | 27 +++++++++---------- 92 files changed, 215 insertions(+), 175 deletions(-) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index ed6b0c1714..a2e4e20374 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -23,7 +23,6 @@ #include #include #include "libslic3r/PrintBase.hpp" -#include "slic3r/Utils/json_diff.hpp" #include #include #include @@ -78,12 +77,10 @@ #include #include #include -//add json logic -#include "nlohmann/json.hpp" - -using namespace nlohmann; #endif +#include "nlohmann/json.hpp" + #include #include #include @@ -157,6 +154,7 @@ using namespace nlohmann; #include namespace fs = boost::filesystem; +using json = nlohmann::json; #ifdef __WXGTK__ #if __has_include() @@ -3524,7 +3522,7 @@ int CLI::run(int argc, char **argv) ConfigOptionStrings *curr_variant_opt = m_print_config.option("filament_extruder_variant"); if (!curr_variant_opt) { curr_variant_opt = m_print_config.option("filament_extruder_variant", true); - std::vector& filament_variants = curr_variant_opt->values; + std::vector& filament_variants = curr_variant_opt->values; filament_variants.resize(filament_count, get_extruder_variant_string(etDirectDrive, nvtStandard)); } const ConfigOptionStrings *new_variant_opt = dynamic_cast(config.option("filament_extruder_variant", true)); @@ -6554,7 +6552,7 @@ int CLI::run(int argc, char **argv) std::vector result_filaments; //result_filaments.reserve(conflict_filaments.size()); std::set_intersection(conflict_filament_vector.begin(), conflict_filament_vector.end(), unprintable_filament_vec[index].begin(), - unprintable_filament_vec[index].end(), insert_iterator>(result_filaments, result_filaments.begin())); + unprintable_filament_vec[index].end(), std::insert_iterator>(result_filaments, result_filaments.begin())); conflict_filament_vector = result_filaments; } } diff --git a/src/libslic3r/AppConfig.hpp b/src/libslic3r/AppConfig.hpp index 122ca83d11..3afb2bb138 100644 --- a/src/libslic3r/AppConfig.hpp +++ b/src/libslic3r/AppConfig.hpp @@ -15,8 +15,6 @@ #include "libslic3r/Semver.hpp" #include "calib.hpp" -using namespace nlohmann; - #define ENV_DEV_HOST "0" #define ENV_QAT_HOST "1" #define ENV_PRE_HOST "2" diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index a6936d70a9..dc4056dda1 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -87,6 +87,7 @@ #include "libslic3r/GCode/Thumbnails.hpp" namespace fs = boost::filesystem; +using json = nlohmann::json; using boost::property_tree::ptree; diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index eb8321e4bd..4edcc70656 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -87,6 +87,8 @@ // This breaks compatibility with the upstream Slic3r if the --datadir is used to switch between the two versions. //#define SLIC3R_PROFILE_USE_PRESETS_SUBDIR +using json = nlohmann::json; + namespace Slic3r { // Project-level options imported from a loaded 3MF into project_config. s_project_options_published diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 77010cbf9d..339e545842 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -1587,7 +1587,7 @@ bool GLVolumeCollection::check_outside_state(const BuildVolume &build_volume, Mo { std::vector result_filaments; //result_filaments.reserve(conflict_filaments.size()); - std::set_intersection (conflict_filament_vector.begin(), conflict_filament_vector.end(), unprintable_filament_vec[index].begin(), unprintable_filament_vec[index].end(), insert_iterator>(result_filaments, result_filaments.begin())); + std::set_intersection (conflict_filament_vector.begin(), conflict_filament_vector.end(), unprintable_filament_vec[index].begin(), unprintable_filament_vec[index].end(), std::insert_iterator>(result_filaments, result_filaments.begin())); conflict_filament_vector = result_filaments; } } diff --git a/src/slic3r/GUI/Auxiliary.cpp b/src/slic3r/GUI/Auxiliary.cpp index bb952e8ae0..1827032b29 100644 --- a/src/slic3r/GUI/Auxiliary.cpp +++ b/src/slic3r/GUI/Auxiliary.cpp @@ -69,6 +69,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Auxiliary.hpp b/src/slic3r/GUI/Auxiliary.hpp index c7fb89f920..4f25aab439 100644 --- a/src/slic3r/GUI/Auxiliary.hpp +++ b/src/slic3r/GUI/Auxiliary.hpp @@ -11,7 +11,7 @@ #include "slic3r/GUI/Widgets/Button.hpp" #include "slic3r/GUI/Widgets/ComboBox.hpp" #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -246,7 +246,7 @@ public: void create_folder(wxString name = wxEmptyString); std::string replaceSpace(std::string s, std::string ts, std::string ns); void on_import_file(wxCommandEvent &event); - void Reload(wxString aux_path, std::map> paths); + void Reload(wxString aux_path, std::map> paths); void update_all_panel(); void update_all_cover(); diff --git a/src/slic3r/GUI/BindDialog.cpp b/src/slic3r/GUI/BindDialog.cpp index c16bcf016d..2f1283b790 100644 --- a/src/slic3r/GUI/BindDialog.cpp +++ b/src/slic3r/GUI/BindDialog.cpp @@ -26,7 +26,7 @@ #include #include "slic3r/GUI/BBLStatusBarBind.hpp" #include "slic3r/GUI/Jobs/BindJob.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "slic3r/GUI/DeviceCore/DevDefs.h" #include "slic3r/GUI/Jobs/Worker.hpp" #include @@ -54,6 +54,8 @@ #include "DeviceCore/DevManager.h" +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index 24591ae0f8..efe7bc16ba 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -25,7 +25,7 @@ #include "slic3r/GUI/Widgets/RadioBox.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include "slic3r/GUI/GUI_Utils.hpp" #include "slic3r/GUI/Widgets/Label.hpp" @@ -91,6 +91,8 @@ #define SELECT_ALL_OPTION_COLOUR wxColour("#009688") #define DEFAULT_PROMPT_TEXT_COLOUR wxColour("#ACACAC") +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/DeviceCore/DevAxis.cpp b/src/slic3r/GUI/DeviceCore/DevAxis.cpp index 1274054507..5dc0245a3a 100644 --- a/src/slic3r/GUI/DeviceCore/DevAxis.cpp +++ b/src/slic3r/GUI/DeviceCore/DevAxis.cpp @@ -1,10 +1,12 @@ #include "DevAxis.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/DeviceCore/DevDefs.h" +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevAxis.h b/src/slic3r/GUI/DeviceCore/DevAxis.h index d543132e49..6e8b3ef20d 100644 --- a/src/slic3r/GUI/DeviceCore/DevAxis.h +++ b/src/slic3r/GUI/DeviceCore/DevAxis.h @@ -2,7 +2,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -22,7 +21,7 @@ public: bool IsArchCoreXY() const; public: - void ParseAxis(const json &print_json); + void ParseAxis(const nlohmann::json &print_json); int Ctrl_GoHome(); int Ctrl_Axis(std::string axis, double unit = 1.0f, double input_val = 1.0f, int speed = 3000); // xyz e diff --git a/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp index ee9c8f00e8..6178a0e1ce 100644 --- a/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevAxisCtrl.cpp @@ -1,11 +1,13 @@ #include "DevAxis.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include #include #include +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevBed.cpp b/src/slic3r/GUI/DeviceCore/DevBed.cpp index 134de17e30..48ab32f947 100644 --- a/src/slic3r/GUI/DeviceCore/DevBed.cpp +++ b/src/slic3r/GUI/DeviceCore/DevBed.cpp @@ -1,7 +1,9 @@ #include "DevBed.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" +using json = nlohmann::json; + namespace Slic3r { void DevBed::ParseV1_0(const json &print_json, DevBed *system) diff --git a/src/slic3r/GUI/DeviceCore/DevBed.h b/src/slic3r/GUI/DeviceCore/DevBed.h index dcdb698449..ddfd1e8902 100644 --- a/src/slic3r/GUI/DeviceCore/DevBed.h +++ b/src/slic3r/GUI/DeviceCore/DevBed.h @@ -1,6 +1,5 @@ #pragma once #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -16,8 +15,8 @@ public: public: - static void ParseV1_0(const json &print_json, DevBed *system); - static void ParseV2_0(const json &print_json, DevBed *system); + static void ParseV1_0(const nlohmann::json &print_json, DevBed *system); + static void ParseV2_0(const nlohmann::json &print_json, DevBed *system); private: diff --git a/src/slic3r/GUI/DeviceCore/DevCalib.cpp b/src/slic3r/GUI/DeviceCore/DevCalib.cpp index 61566c83ed..ec1e55a247 100644 --- a/src/slic3r/GUI/DeviceCore/DevCalib.cpp +++ b/src/slic3r/GUI/DeviceCore/DevCalib.cpp @@ -1,6 +1,6 @@ #include #include -#include "json_diff.hpp" +#include #include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/DeviceManager.hpp" @@ -22,6 +22,8 @@ #include "DevFilaSystem.h" #include "DevConfig.h" +using json = nlohmann::json; + namespace Slic3r { static float string_to_float(const std::string &str_value) diff --git a/src/slic3r/GUI/DeviceCore/DevCalib.h b/src/slic3r/GUI/DeviceCore/DevCalib.h index 54f5f4b053..f0600424e2 100644 --- a/src/slic3r/GUI/DeviceCore/DevCalib.h +++ b/src/slic3r/GUI/DeviceCore/DevCalib.h @@ -2,7 +2,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" #include "DevDefs.h" @@ -86,11 +85,11 @@ public: std::vector GetFlowRatioResult() const {return m_flow_ratio_results; } protected: - void ExtrusionCalibSetParse(const json &jj); - void ExtrusionCalibSelectParse(const json &jj); - void ExtrusionCalibGetTableParse(const json &jj); - void ExtrusionCalibGetResultParse(const json &jj); - void FlowrateGetResultParse(const json &jj); + void ExtrusionCalibSetParse(const nlohmann::json &jj); + void ExtrusionCalibSelectParse(const nlohmann::json &jj); + void ExtrusionCalibGetTableParse(const nlohmann::json &jj); + void ExtrusionCalibGetResultParse(const nlohmann::json &jj); + void FlowrateGetResultParse(const nlohmann::json &jj); private: MachineObject* m_owner{nullptr}; @@ -119,11 +118,11 @@ private: bool m_calib_finished{false}; public: - static void ParseCalibVersion(const json& j, DevCalib* system); + static void ParseCalibVersion(const nlohmann::json& j, DevCalib* system); static void ParseSupportNewAutoCalib(int flag, DevCalib* system); - static void ParseV1_0(const json& print_json, DevCalib* system, bool key_field_only); + static void ParseV1_0(const nlohmann::json& print_json, DevCalib* system, bool key_field_only); }; } // namespace Slic3r \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceCore/DevChamber.cpp b/src/slic3r/GUI/DeviceCore/DevChamber.cpp index 8cd47481f2..3c1a0c8e8b 100644 --- a/src/slic3r/GUI/DeviceCore/DevChamber.cpp +++ b/src/slic3r/GUI/DeviceCore/DevChamber.cpp @@ -3,9 +3,11 @@ #include "DevConfig.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" +using json = nlohmann::json; + namespace Slic3r { bool DevChamber::HasChamber() const { return m_owner->GetConfig()->HasChamber(); } diff --git a/src/slic3r/GUI/DeviceCore/DevChamber.h b/src/slic3r/GUI/DeviceCore/DevChamber.h index 6fcafabcf2..0e6464a839 100644 --- a/src/slic3r/GUI/DeviceCore/DevChamber.h +++ b/src/slic3r/GUI/DeviceCore/DevChamber.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -25,10 +24,10 @@ public: // getter public: // setter - void ParseChamber(const json &print_json); + void ParseChamber(const nlohmann::json &print_json); - void ParseChamberV1_0(const json& print_json); - void ParseChamberV2_0(const json& print_json); + void ParseChamberV1_0(const nlohmann::json& print_json); + void ParseChamberV2_0(const nlohmann::json& print_json); // control int CtrlSetChamberTemp(int temp); diff --git a/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp index 01201998ce..13ab7bccc9 100644 --- a/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevChamberCtrl.cpp @@ -1,8 +1,10 @@ #include "DevChamber.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include +using json = nlohmann::json; + namespace Slic3r { int DevChamber::CtrlSetChamberTemp(int temp) diff --git a/src/slic3r/GUI/DeviceCore/DevConfig.cpp b/src/slic3r/GUI/DeviceCore/DevConfig.cpp index cce5257527..9833731040 100644 --- a/src/slic3r/GUI/DeviceCore/DevConfig.cpp +++ b/src/slic3r/GUI/DeviceCore/DevConfig.cpp @@ -2,7 +2,6 @@ #include "DevConfig.h" #include "DevUtil.h" -#include "json_diff.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevConfig.h b/src/slic3r/GUI/DeviceCore/DevConfig.h index b0cdcb936e..9fa26d9238 100644 --- a/src/slic3r/GUI/DeviceCore/DevConfig.h +++ b/src/slic3r/GUI/DeviceCore/DevConfig.h @@ -1,7 +1,7 @@ #pragma once #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include #include @@ -47,11 +47,11 @@ public: public: /*Setters*/ - void ParseConfig(const json& print_json); + void ParseConfig(const nlohmann::json& print_json); - void ParseChamberConfig(const json& print_json); // chamber - void ParsePrintOptionsConfig(const json& print_json); // print options - void ParseCalibrationConfig(const json& print_json); //cali + void ParseChamberConfig(const nlohmann::json& print_json); // chamber + void ParsePrintOptionsConfig(const nlohmann::json& print_json); // print options + void ParseCalibrationConfig(const nlohmann::json& print_json); //cali private: [[maybe_unused]] MachineObject* m_obj; diff --git a/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp b/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp index e6679f4463..b0a6f2678c 100644 --- a/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp +++ b/src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp @@ -1,6 +1,6 @@ #include "DevConfigUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include diff --git a/src/slic3r/GUI/DeviceCore/DevCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevCtrl.cpp index 56547e2a03..011d9228a0 100644 --- a/src/slic3r/GUI/DeviceCore/DevCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevCtrl.cpp @@ -4,7 +4,6 @@ #include "DevCtrl.h" // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevCtrl.h b/src/slic3r/GUI/DeviceCore/DevCtrl.h index 55d0dc4c3e..6b38cc1569 100644 --- a/src/slic3r/GUI/DeviceCore/DevCtrl.h +++ b/src/slic3r/GUI/DeviceCore/DevCtrl.h @@ -1,6 +1,6 @@ #pragma once -#include "slic3r/Utils/json_diff.hpp" +#include #include #include #include @@ -15,7 +15,7 @@ class DevCtrlInfo { public: DevCtrlInfo() {}; - DevCtrlInfo(MachineObject* obj, int sequence_id, const json& req_json, int interval_max = 3, int interval_min = 0); + DevCtrlInfo(MachineObject* obj, int sequence_id, const nlohmann::json& req_json, int interval_max = 3, int interval_min = 0); public: bool CheckCanUpdateData(const nlohmann::json& jj); @@ -32,7 +32,7 @@ private: time_t m_request_time = 0; int m_request_seq = 0; - json m_request_json = json(); + nlohmann::json m_request_json = nlohmann::json(); // check int m_request_interval_max = 3; diff --git a/src/slic3r/GUI/DeviceCore/DevExtensionTool.h b/src/slic3r/GUI/DeviceCore/DevExtensionTool.h index 8ce33b6e43..0b16c95a90 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtensionTool.h +++ b/src/slic3r/GUI/DeviceCore/DevExtensionTool.h @@ -3,7 +3,7 @@ #include #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include #include "DevDefs.h" diff --git a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp index 20975a7ca3..5013d85228 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp @@ -15,7 +15,6 @@ #include "DevFilaSystem.h" // complete type for GetFilaSystem()->GetTrayIndexMap() in GetBackupAmsSlotInGroup // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/I18N.hpp" diff --git a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h index 4d9f7c9abf..e7e083050f 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevExtruderSystem.h @@ -5,7 +5,7 @@ #include #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include #include diff --git a/src/slic3r/GUI/DeviceCore/DevFan.cpp b/src/slic3r/GUI/DeviceCore/DevFan.cpp index 52ac9f1d76..c4fc80116b 100644 --- a/src/slic3r/GUI/DeviceCore/DevFan.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFan.cpp @@ -6,7 +6,6 @@ #include #include #include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevFan.h b/src/slic3r/GUI/DeviceCore/DevFan.h index 393c8a477c..b36705a19b 100644 --- a/src/slic3r/GUI/DeviceCore/DevFan.h +++ b/src/slic3r/GUI/DeviceCore/DevFan.h @@ -2,7 +2,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" #include #include @@ -13,7 +12,7 @@ namespace Slic3r { class MachineObject; enum AirDuctType { AIR_FAN_TYPE, AIR_DOOR_TYPE }; -typedef std::function CommandCallBack; +typedef std::function CommandCallBack; enum AIR_FUN : int { FAN_HEAT_BREAK_0_IDX = 0, @@ -123,14 +122,14 @@ public: AirDuctData GetAirDuctData() { return m_air_duct_data; }; void converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun); // Convert the data to duct type to make the newand old protocols consistent - int command_handle_response(const json &response); + int command_handle_response(const nlohmann::json &response); int command_control_fan(int fan_type, int val); // Old protocol int command_control_fan_new(int fan_id, int val); // New protocol int command_control_air_duct(int mode_id, int submode, const CommandCallBack& cb); - void ParseV1_0(const json &print_json); - void ParseV2_0(const json &print_json); - void ParseV3_0(const json &print_json); + void ParseV1_0(const nlohmann::json &print_json); + void ParseV2_0(const nlohmann::json &print_json); + void ParseV3_0(const nlohmann::json &print_json); public: bool GetSupportAirduct() { return is_support_airduct; }; diff --git a/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp index cc8312ce9a..f86838729c 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaAmsSettingCtrl.cpp @@ -1,11 +1,13 @@ #include "DevFilaAmsSetting.h" #include "DevFilaSystem.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include #include "slic3r/GUI/DeviceCore/DevCtrl.h" +using json = nlohmann::json; + namespace Slic3r { int DevAmsSystemFirmwareSwitch::CrtlSwitchFirmware(int firmware_idx) { diff --git a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp index c499b89622..ef921c5620 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp @@ -14,7 +14,6 @@ #include "slic3r/GUI/DeviceCore/DevDefs.h" #include "DevFilaBlackList.h" -#include "json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" #include "slic3r/GUI/DeviceManager.hpp" #include "DevFilaSystem.h" diff --git a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h index 1f727396a8..43e50360b9 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h +++ b/src/slic3r/GUI/DeviceCore/DevFilaBlackList.h @@ -5,7 +5,7 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" +#include namespace Slic3r { @@ -67,7 +67,7 @@ public: static CheckResult check_filaments_in_blacklist(const CheckFilamentInfo& info); public: - static json filaments_blacklist; + static nlohmann::json filaments_blacklist; };// class DevFilaBlacklist }// namespace Slic3r diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp index 14880a6ef3..8644047e64 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp @@ -18,7 +18,6 @@ #include #include #include "DevFilaSystem.h" -#include "json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" #include "DevNozzleSystem.h" // DevNozzle / DevNozzleSystem for GetNozzleFlowStringByAmsId diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystem.h b/src/slic3r/GUI/DeviceCore/DevFilaSystem.h index 32edc06a32..27dc238e9e 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystem.h @@ -1,6 +1,6 @@ #pragma once #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include "DevDefs.h" #include "DevFilaAmsSetting.h" @@ -415,9 +415,9 @@ private: class DevFilaSystemParser { public: - static void ParseV1_0(const json& print_json, MachineObject* obj, DevFilaSystem* system, bool key_field_only); + static void ParseV1_0(const nlohmann::json& print_json, MachineObject* obj, DevFilaSystem* system, bool key_field_only); - static void ParseAgentFilament(const json& data, MachineObject* obj, DevFilaSystem* system); + static void ParseAgentFilament(const nlohmann::json& data, MachineObject* obj, DevFilaSystem* system); }; struct DevFilamentDryingPreset diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp index 16121f00d2..e7181580cd 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystemCtrl.cpp @@ -2,7 +2,6 @@ #include #include "DevFilaSystem.h" -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp"// TODO: remove this include using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevFirmware.h b/src/slic3r/GUI/DeviceCore/DevFirmware.h index 1b251144e5..bc0a0f0168 100644 --- a/src/slic3r/GUI/DeviceCore/DevFirmware.h +++ b/src/slic3r/GUI/DeviceCore/DevFirmware.h @@ -1,11 +1,9 @@ #pragma once #include "DevFirmware.h" -#include "slic3r/Utils/json_diff.hpp" #include #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -51,10 +49,10 @@ public: bool isCuttingModule() const { return product_name.Contains("Cutting Module"); } bool isRotary() const { return product_name.Contains("Rotary"); }// Rotary Attachment bool isExtinguishSystem() const { return product_name.Contains("Extinguishing System"); }// Auto Fire Extinguishing System - bool isWTM() const { return name.find("wtm") != string::npos; } // nozzle + bool isWTM() const { return name.find("wtm") != std::string::npos; } // nozzle bool isExhaustFan() const { return product_name.Contains("Exhaust Fan"); } - bool isHmshub() const { return product_name.find("Filament Buffer") != string::npos; } - bool isFilaTrackSwitch() const { return product_name.find("Filament Track") != string::npos; } + bool isHmshub() const { return product_name.find("Filament Buffer") != std::string::npos; } + bool isFilaTrackSwitch() const { return product_name.find("Filament Track") != std::string::npos; } }; diff --git a/src/slic3r/GUI/DeviceCore/DevHMS.cpp b/src/slic3r/GUI/DeviceCore/DevHMS.cpp index 456e806170..b696542658 100644 --- a/src/slic3r/GUI/DeviceCore/DevHMS.cpp +++ b/src/slic3r/GUI/DeviceCore/DevHMS.cpp @@ -2,10 +2,12 @@ #include "DevHMS.h" #include #include -#include "json_diff.hpp" +#include #include #include +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevHMS.h b/src/slic3r/GUI/DeviceCore/DevHMS.h index 82022833cf..1e499f3aea 100644 --- a/src/slic3r/GUI/DeviceCore/DevHMS.h +++ b/src/slic3r/GUI/DeviceCore/DevHMS.h @@ -1,6 +1,6 @@ #pragma once -#include "slic3r/Utils/json_diff.hpp" +#include #include #include #include @@ -18,7 +18,7 @@ public: DevHMS(MachineObject* obj) : m_object(obj) {} public: - void ParseHMSItems(const json& hms_json); + void ParseHMSItems(const nlohmann::json& hms_json); const std::vector& GetHMSItems() const { return m_hms_list; }; private: @@ -69,7 +69,7 @@ public: bool has_read() const { return m_already_read; }; protected: - friend void DevHMS::ParseHMSItems(const json& hms_json); + friend void DevHMS::ParseHMSItems(const nlohmann::json& hms_json); bool parse_hms_info(unsigned attr, unsigned code); private: diff --git a/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp index 5190632b5b..fefad1479f 100644 --- a/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp @@ -3,7 +3,6 @@ #include "DevLamp.h" // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" using namespace nlohmann; diff --git a/src/slic3r/GUI/DeviceCore/DevManager.cpp b/src/slic3r/GUI/DeviceCore/DevManager.cpp index 0fd5ed2cc0..c04321e71f 100644 --- a/src/slic3r/GUI/DeviceCore/DevManager.cpp +++ b/src/slic3r/GUI/DeviceCore/DevManager.cpp @@ -23,7 +23,6 @@ #include "DevUtil.h" // TODO: remove this include -#include "json_diff.hpp" #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/GUI_App.hpp" diff --git a/src/slic3r/GUI/DeviceCore/DevManager.h b/src/slic3r/GUI/DeviceCore/DevManager.h index 5ab3eed01b..1a669d0aee 100644 --- a/src/slic3r/GUI/DeviceCore/DevManager.h +++ b/src/slic3r/GUI/DeviceCore/DevManager.h @@ -3,7 +3,6 @@ #include #include "libslic3r/CommonDefs.hpp" -#include "slic3r/Utils/json_diff.hpp" #include #include #include diff --git a/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp b/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp index ee935a58a0..5eb0defa93 100644 --- a/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp +++ b/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp @@ -6,7 +6,6 @@ #include "DevUtil.h" #include "DevUtilBackend.h" -#include "json_diff.hpp" #include "libslic3r/MultiNozzleUtils.hpp" #include "slic3r/GUI/DeviceManager.hpp" diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleRack.h b/src/slic3r/GUI/DeviceCore/DevNozzleRack.h index 28c7990b78..a5388eb2f2 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleRack.h +++ b/src/slic3r/GUI/DeviceCore/DevNozzleRack.h @@ -1,7 +1,7 @@ #pragma once #include "libslic3r/CommonDefs.hpp" #include "libslic3r/MultiNozzleUtils.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include "DevNozzleSystem.h" #include "DevFirmware.h" diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp index e8d720a324..484eb77098 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevNozzleRackCtrl.cpp @@ -1,7 +1,7 @@ #include "DevNozzleRack.h" #include "DevExtruderSystem.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/MsgDialog.hpp" #include "slic3r/GUI/I18N.hpp" @@ -14,6 +14,8 @@ #include "slic3r/GUI/DeviceCore/DevNozzleSystem.h" +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp index 70eec0f795..98d5d5bd5f 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp @@ -4,7 +4,7 @@ #include "DevNozzleSystem.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/I18N.hpp" @@ -28,6 +28,8 @@ #include #include +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h index f4fc97938b..040ecb58b4 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.h @@ -4,7 +4,7 @@ #include "libslic3r/CommonDefs.hpp" #include "libslic3r/MultiNozzleUtils.hpp" -#include "slic3r/Utils/json_diff.hpp" +#include #include "libslic3r/PrintConfig.hpp" #include @@ -195,6 +195,6 @@ namespace Slic3r { public: static void ParseV1_0(const nlohmann::json& nozzletype_json, const nlohmann::json& diameter_json, DevNozzleSystem* system, std::optional flag_e3d); - static void ParseV2_0(const json& device_json, DevNozzleSystem* system); + static void ParseV2_0(const nlohmann::json& device_json, DevNozzleSystem* system); }; }; diff --git a/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp b/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp index 082997e177..c80597e28b 100644 --- a/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp +++ b/src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp @@ -8,9 +8,11 @@ #include #include -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" +using json = nlohmann::json; + namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevStorage.cpp b/src/slic3r/GUI/DeviceCore/DevStorage.cpp index b2bd9f06ef..04a5ff8433 100644 --- a/src/slic3r/GUI/DeviceCore/DevStorage.cpp +++ b/src/slic3r/GUI/DeviceCore/DevStorage.cpp @@ -1,8 +1,10 @@ #include "DevStorage.h" -#include "json_diff.hpp" +#include #include +using json = nlohmann::json; + namespace Slic3r { DevStorage::SdcardState Slic3r::DevStorage::set_sdcard_state(int state) diff --git a/src/slic3r/GUI/DeviceCore/DevStorage.h b/src/slic3r/GUI/DeviceCore/DevStorage.h index 58f556499b..e436bbd9ea 100644 --- a/src/slic3r/GUI/DeviceCore/DevStorage.h +++ b/src/slic3r/GUI/DeviceCore/DevStorage.h @@ -1,7 +1,6 @@ #pragma once #include #include -#include "slic3r/Utils/json_diff.hpp" namespace Slic3r { @@ -27,7 +26,7 @@ public: SdcardState get_sdcard_state() const { return m_sdcard_state; }; SdcardState set_sdcard_state(int state); - static void ParseV1_0(const json &print_json, DevStorage *system); + static void ParseV1_0(const nlohmann::json &print_json, DevStorage *system); bool is_timelapse_storage_low(const std::string& storage) const; diff --git a/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp b/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp index c35ec8bfce..16ffbf21fb 100644 --- a/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp +++ b/src/slic3r/GUI/DeviceCore/DevUpgrade.cpp @@ -1,7 +1,7 @@ #include "DevUpgrade.h" #include "DevUtil.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/GUI_App.hpp" @@ -13,6 +13,8 @@ #include "slic3r/GUI/DeviceCore/DevDefs.h" #include +using json = nlohmann::json; + namespace Slic3r { int DevUpgrade::GetUpgradeProgressInt() const diff --git a/src/slic3r/GUI/DeviceCore/DevUpgrade.h b/src/slic3r/GUI/DeviceCore/DevUpgrade.h index 1593f54260..7ff06b09f0 100644 --- a/src/slic3r/GUI/DeviceCore/DevUpgrade.h +++ b/src/slic3r/GUI/DeviceCore/DevUpgrade.h @@ -4,7 +4,6 @@ #include #include #include -#include "slic3r/Utils/json_diff.hpp" #include "DevDefs.h" #include "DevFirmware.h" @@ -47,8 +46,8 @@ public: int CtrlUpgradeModule(std::string url, std::string module_type, std::string version); // parser - void ParseUpgrade_V1_0(const json &print_jj); - void ParseUpgradeDisplayState(const json &upgrade_state_jj); + void ParseUpgrade_V1_0(const nlohmann::json &print_jj); + void ParseUpgradeDisplayState(const nlohmann::json &upgrade_state_jj); protected: DevUpgrade(MachineObject *owner) : m_owner(owner) {} @@ -90,7 +89,7 @@ public: public: int CtrlGetVersion(bool with_retry = true); - void ParseGetVersion(const json &print_jj); + void ParseGetVersion(const nlohmann::json &print_jj); private: MachineObject *m_owner; diff --git a/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp index a6d4550a2b..58aa6ce6db 100644 --- a/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevUpgradeCtrl.cpp @@ -1,10 +1,12 @@ #include "DevUpgrade.h" -#include "json_diff.hpp" +#include #include "slic3r/GUI/DeviceManager.hpp" #include #include "slic3r/GUI/DeviceCore/DevFirmware.h" +using json = nlohmann::json; + namespace Slic3r { int DevUpgrade::CtrlUpgradeConfirm() diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 392ff4587b..0eca3239b2 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1,5 +1,5 @@ #include "PrinterNetworkTypes.hpp" -#include "json_diff.hpp" +#include #include "DeviceManager.hpp" #include "HMS.hpp" #include "I18N.hpp" @@ -105,6 +105,8 @@ #include "libslic3r/PresetBundle.hpp" #include "slic3r/GUI/Jobs/SendJob.hpp" +using json = nlohmann::json; + class wxWindow; namespace fs = boost::filesystem; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index c4a63cb588..f41a32ada7 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -63,7 +63,6 @@ #define END_SEQ_ID 30000 #define SUBSCRIBE_RETRY_COUNT 5 -using namespace nlohmann; namespace Slic3r { namespace GUI @@ -467,7 +466,7 @@ public: std::string get_print_error_str() const { return MachineObject::get_error_code_str(this->print_error); } std::unordered_set m_command_error_code_dlgs; - void add_command_error_code_dlg(int command_err, json action_json=json{}); + void add_command_error_code_dlg(int command_err, nlohmann::json action_json=nlohmann::json{}); int curr_layer = 0; int total_layers = 0; @@ -759,9 +758,9 @@ public: int command_set_printer_nozzle2(int id, std::string nozzle_type, float diameter); int command_get_access_code(); int command_start_camera(); - int command_ack_proceed(json& proceed); + int command_ack_proceed(nlohmann::json& proceed); int command_purification_disable(); - int command_dont_remind_next_time(json& mqtt_guard_json); + int command_dont_remind_next_time(nlohmann::json& mqtt_guard_json); /* command upgrade */ int command_upgrade_confirm(); @@ -887,7 +886,7 @@ public: static bool is_in_printing_status(std::string status); void set_print_state(std::string status); - void update_print_progress(const json& value); + void update_print_progress(const nlohmann::json& value); bool is_connected(); bool is_connecting(); @@ -903,7 +902,7 @@ public: /* Msg for display MsgFn */ typedef std::function MsgFn; - int publish_json(const json& json_item, int qos = 0, int flag = 0) ; + int publish_json(const nlohmann::json& json_item, int qos = 0, int flag = 0) ; int publish_json(const std::string& json_str, int qos = 0, int flag = 0) = delete; int cloud_publish_json(std::string json_str, int qos = 0, int flag = 0); int local_publish_json(std::string json_str, int qos = 0, int flag = 0); @@ -947,16 +946,16 @@ public: * or scenarios where users want to bypass the AMS. */ std::vector vt_slot; - DevAmsTray parse_vt_tray(json vtray); + DevAmsTray parse_vt_tray(nlohmann::json vtray); /*get ams slot info*/ bool contains_tray(const std::string &ams_id, const std::string &tray_id) const; DevAmsTray get_tray(const std::string &ams_id, const std::string &tray_id) const;/*use contains_tray() check first*/ /*for parse new info*/ - bool check_enable_np(const json& print) const; - void parse_new_info(json print); - void parse_new_info2(const json& info); + bool check_enable_np(const nlohmann::json& print) const; + void parse_new_info(nlohmann::json print); + void parse_new_info2(const nlohmann::json& info); int get_flag_bits(std::string str, int start, int count = 1) const; uint32_t get_flag_bits_no_border(std::string str, int start_idx, int count = 1) const; int get_flag_bits(int num, int start, int count = 1, int base = 10) const; diff --git a/src/slic3r/GUI/ExportPresetBundleDialog.hpp b/src/slic3r/GUI/ExportPresetBundleDialog.hpp index 2038cd7677..a2a66ddbe6 100644 --- a/src/slic3r/GUI/ExportPresetBundleDialog.hpp +++ b/src/slic3r/GUI/ExportPresetBundleDialog.hpp @@ -67,7 +67,7 @@ public: void on_script_message(const nlohmann::json& payload) override; void OnRequestPresets(); - void OnExportData(const wxString& path, const wxString& name, json data); + void OnExportData(const wxString& path, const wxString& name, nlohmann::json data); protected: bool m_seq_top_layer_only_changed{false}; diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 6c56e4fa54..9c6c200050 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -2816,7 +2816,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector>>& title_columns, float extra_size = 0.0f) { + auto calculate_offsets = [max_width, window_padding](const std::vector>>& title_columns, float extra_size = 0.0f) { const ImGuiStyle& style = ImGui::GetStyle(); std::vector offsets; offsets.push_back(max_width(title_columns[0].second, title_columns[0].first, extra_size) + 3.0f * style.ItemSpacing.x + style.WindowPadding.x); @@ -2963,7 +2963,7 @@ void GCodeViewer::render_all_plates_stats(const std::vector>> title_columns; + std::vector>> title_columns; if (displayed_columns & ColumnData::Model) { title_columns.push_back({ _u8L("Filament"), {""} }); title_columns.push_back({ _u8L("Model"), {buff} }); @@ -3184,7 +3184,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) float ams_item_height = 0; float filament_group_item_align_width = 0; { - float three_words_width = imgui.calc_text_size("ABC"sv).x; + float three_words_width = imgui.calc_text_size(std::string_view("ABC")).x; const int line_capacity = 4; for (const auto& extruder_filaments : {m_left_extruder_filament,m_right_extruder_filament }) @@ -3195,8 +3195,8 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) for (int j = idx; j < extruder_filaments.size() && j < idx + line_capacity; ++j) { auto text_info = imgui.calculate_filament_group_text_size(get_filament_display_type(extruder_filaments[j])); auto text_size = std::get<0>(text_info); - filament_group_item_align_width = max(filament_group_item_align_width, text_size.x); - text_line_height = max(text_line_height, text_size.y); + filament_group_item_align_width = std::max(filament_group_item_align_width, text_size.x); + text_line_height = std::max(text_line_height, text_size.y); } container_height += (three_words_width * 1.3f + text_line_height ); } @@ -3589,7 +3589,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv return ret; }; - auto calculate_offsets = [max_width, this](const std::vector>>& title_columns, float extra_size = 0.0f) { + auto calculate_offsets = [max_width, this](const std::vector>>& title_columns, float extra_size = 0.0f) { const ImGuiStyle& style = ImGui::GetStyle(); std::vector offsets; // ORCA increase spacing for more readable format. Using direct number requires much less code change in here. GetTextLineHeight for additional spacing for icon_size @@ -4014,7 +4014,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv total_filaments.push_back(buffer); - std::vector>> title_columns; + std::vector>> title_columns; if (displayed_columns & ColumnData::Model) { title_columns.push_back({ _u8L("Filament"), {""} }); title_columns.push_back({ _u8L("Model"), total_filaments }); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 2293a94d62..705c489863 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -311,6 +311,7 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS2)( using namespace std::literals; namespace pt = boost::property_tree; +using json = nlohmann::json; struct StaticBambuLib { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index 2800b2b146..e807ef1d4e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -3651,7 +3651,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection) // model_name failing reason std::vector> failed_models; auto plater = wxGetApp().plater(); - auto fix_and_update_progress = [keep_painting](ModelObject *model_object, const int vol_idx, const string &model_name, ProgressDialog &progress_dlg, + auto fix_and_update_progress = [keep_painting](ModelObject *model_object, const int vol_idx, const std::string &model_name, ProgressDialog &progress_dlg, std::vector &succes_models, std::vector> &failed_models) { wxString msg = _L("Repairing model object"); msg += ": " + from_u8(model_name) + "\n"; diff --git a/src/slic3r/GUI/HMS.cpp b/src/slic3r/GUI/HMS.cpp index a210a99656..0a5dba5a0e 100644 --- a/src/slic3r/GUI/HMS.cpp +++ b/src/slic3r/GUI/HMS.cpp @@ -6,7 +6,7 @@ #include "DeviceCore/DevManager.h" #include "DeviceCore/DevUtil.h" #include "Http.hpp" -#include "json_diff.hpp" +#include #include "libslic3r/AppConfig.hpp" #include @@ -26,6 +26,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; static const char* HMS_PATH = "hms"; static const char* HMS_LOCAL_IMG_PATH = "hms/local_image"; diff --git a/src/slic3r/GUI/IMSlider.cpp b/src/slic3r/GUI/IMSlider.cpp index ce2aa2ecba..c031705f14 100644 --- a/src/slic3r/GUI/IMSlider.cpp +++ b/src/slic3r/GUI/IMSlider.cpp @@ -1405,7 +1405,7 @@ void IMSlider::render_input_custom_gcode(std::string custom_gcode) } void IMSlider::do_go_to_layer(size_t layer_number) { - layer_number = clamp((int)layer_number, m_min_value, m_max_value); + layer_number = std::clamp((int)layer_number, m_min_value, m_max_value); GetSelection() == ssLower ? SetLowerValue(layer_number) : SetHigherValue(layer_number); } diff --git a/src/slic3r/GUI/Jobs/PrintJob.cpp b/src/slic3r/GUI/Jobs/PrintJob.cpp index 29f2e5b403..9e5e2cc7c4 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -19,7 +19,7 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include "slic3r/GUI/PartPlate.hpp" #include "libslic3r/PrintConfig.hpp" @@ -39,6 +39,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Jobs/SendJob.cpp b/src/slic3r/GUI/Jobs/SendJob.cpp index 0aa0dd98c6..419b03afd3 100644 --- a/src/slic3r/GUI/Jobs/SendJob.cpp +++ b/src/slic3r/GUI/Jobs/SendJob.cpp @@ -1,5 +1,5 @@ #include "SendJob.hpp" -#include "json_diff.hpp" +#include #include "bambu_networking.hpp" #include "libslic3r/LifecycleEvents.hpp" #include "slic3r/GUI/I18N.hpp" @@ -23,6 +23,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 689f9eb87c..c882667d90 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -34,7 +34,7 @@ #include "slic3r/GUI/Widgets/SideMenuPopup.hpp" #include #include "libslic3r/libslic3r.h" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -155,6 +155,8 @@ #include +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/MediaFilePanel.cpp b/src/slic3r/GUI/MediaFilePanel.cpp index 249db6c3d7..54ce5907fb 100644 --- a/src/slic3r/GUI/MediaFilePanel.cpp +++ b/src/slic3r/GUI/MediaFilePanel.cpp @@ -45,6 +45,8 @@ #include "../Utils/MacDarkMode.hpp" #endif +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/ModelMall.cpp b/src/slic3r/GUI/ModelMall.cpp index 66d26f1042..e8b08f7e02 100644 --- a/src/slic3r/GUI/ModelMall.cpp +++ b/src/slic3r/GUI/ModelMall.cpp @@ -13,7 +13,7 @@ #include "slic3r/GUI/Widgets/WebView.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -24,6 +24,8 @@ #include "GUI_App.hpp" #include "Plater.hpp" +using json = nlohmann::json; + namespace Slic3r::GUI { class Plater; } namespace Slic3r { diff --git a/src/slic3r/GUI/Monitor.cpp b/src/slic3r/GUI/Monitor.cpp index 2c800ecebb..b23c5ab468 100644 --- a/src/slic3r/GUI/Monitor.cpp +++ b/src/slic3r/GUI/Monitor.cpp @@ -15,7 +15,7 @@ #include "slic3r/GUI/StatusPanel.hpp" #include "slic3r/GUI/UpgradePanel.hpp" #include "slic3r/GUI/Widgets/SideTools.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -57,6 +57,8 @@ #include "slic3r/GUI/I18N.hpp" #include "slic3r/GUI/Widgets/Button.hpp" +using json = nlohmann::json; + namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/NotificationManager.hpp b/src/slic3r/GUI/NotificationManager.hpp index 2613d3da9a..2fcd872390 100644 --- a/src/slic3r/GUI/NotificationManager.hpp +++ b/src/slic3r/GUI/NotificationManager.hpp @@ -631,8 +631,8 @@ private: // Aditional text after hypertext - currently not used std::string m_text2; // mark for render operation - size_t pos_start = string::npos; - size_t pos_end = string::npos; + size_t pos_start = std::string::npos; + size_t pos_end = std::string::npos; std::string error_start = ""; std::string error_end = ""; diff --git a/src/slic3r/GUI/PresetBundleDialog.cpp b/src/slic3r/GUI/PresetBundleDialog.cpp index 9c11fc67aa..c067d99c28 100644 --- a/src/slic3r/GUI/PresetBundleDialog.cpp +++ b/src/slic3r/GUI/PresetBundleDialog.cpp @@ -16,7 +16,7 @@ #include #include #include "slic3r/GUI/GUI.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -32,6 +32,9 @@ #include #include #include + +using json = nlohmann::json; + namespace Slic3r { namespace GUI { PresetBundleDialog::PresetBundleDialog( diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp index a74780660c..9ae746c6e0 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.cpp +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.cpp @@ -58,6 +58,8 @@ //#define PRINTER_FILE_SYSTEM_TEST #endif +using json = nlohmann::json; + std::string last_system_error() { return Slic3r::decode_path(std::error_code( #ifdef _WIN32 diff --git a/src/slic3r/GUI/Printer/PrinterFileSystem.h b/src/slic3r/GUI/Printer/PrinterFileSystem.h index 2748e0ae0c..337fa6931d 100644 --- a/src/slic3r/GUI/Printer/PrinterFileSystem.h +++ b/src/slic3r/GUI/Printer/PrinterFileSystem.h @@ -22,7 +22,6 @@ #include #include "nlohmann/json_fwd.hpp" -using nlohmann::json; #include #include @@ -290,17 +289,17 @@ private: static void DumpLog(void* context, int level, tchar const *msg); private: - template using Translator = std::function; + template using Translator = std::function; - typedef std::function callback_t; + typedef std::function callback_t; - typedef std::function callback_t2; + typedef std::function callback_t2; typedef std::function callback_t3; - template boost::uint32_t SendRequest(int type, json const &req, Translator const &translator, Callback const &callback, const std::string ¶m = "") + template boost::uint32_t SendRequest(int type, nlohmann::json const &req, Translator const &translator, Callback const &callback, const std::string ¶m = "") { - auto c = [translator, callback, this](int result, json const &resp, unsigned char const *data) -> int + auto c = [translator, callback, this](int result, nlohmann::json const &resp, unsigned char const *data) -> int { T t; if (result == 0 || result == CONTINUE || result == FILE_EXIST) { @@ -323,7 +322,7 @@ private: template void InstallNotify(int type, Translator const& translator, Applier const& applier) { - auto c = [translator, applier, this](int result, json const &resp, unsigned char const *data) -> int + auto c = [translator, applier, this](int result, nlohmann::json const &resp, unsigned char const *data) -> int { T t; if (result == 0 || result == CONTINUE) { @@ -345,7 +344,7 @@ private: InstallNotify(type, c); } - boost::uint32_t SendRequest(int type, json const &req, callback_t2 const &callback, const std::string ¶m = ""); + boost::uint32_t SendRequest(int type, nlohmann::json const &req, callback_t2 const &callback, const std::string ¶m = ""); void InstallNotify(int type, callback_t2 const &callback); diff --git a/src/slic3r/GUI/PrinterCloudAuthDialog.cpp b/src/slic3r/GUI/PrinterCloudAuthDialog.cpp index 3b1b15ea6b..4bb9824f99 100644 --- a/src/slic3r/GUI/PrinterCloudAuthDialog.cpp +++ b/src/slic3r/GUI/PrinterCloudAuthDialog.cpp @@ -6,7 +6,6 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" #include "slic3r/GUI/GUI.hpp" #include #include @@ -30,6 +29,9 @@ #include #include + +using json = nlohmann::json; + //------------------------------------------ // PrinterCloundAuthDialog //------------------------------------------ diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index 2ce0da582c..a0ed54cfe2 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -16,7 +16,7 @@ #include #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/Auxiliary.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -54,7 +54,8 @@ #include #include "slic3r/GUI/Jobs/SendJob.hpp" #include "slic3r/GUI/Plater.hpp" -#include "slic3r/Utils/json_diff.hpp" + +using json = nlohmann::json; class wxWindow; diff --git a/src/slic3r/GUI/Project.hpp b/src/slic3r/GUI/Project.hpp index 13d234a697..3a8460e42b 100644 --- a/src/slic3r/GUI/Project.hpp +++ b/src/slic3r/GUI/Project.hpp @@ -30,7 +30,6 @@ #include #include "nlohmann/json.hpp" -#include "slic3r/Utils/json_diff.hpp" #include #include @@ -109,7 +108,7 @@ public: void OnScriptMessage(wxWebViewEvent& evt); void RunScript(std::string content); - std::map> Reload(wxString aux_path); + std::map> Reload(wxString aux_path); std::string formatBytes(unsigned long bytes); wxString to_base64(std::string path); }; diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 67dc80ca6d..11b62728f2 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -74,6 +74,8 @@ #include "slic3r/Utils/NetworkAgent.hpp" #include +using json = nlohmann::json; + namespace Slic3r::GUI { class Plater; } namespace fs = boost::filesystem; diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 5d51e5429f..3a23889c6c 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -62,7 +62,7 @@ #include #include #include "libslic3r/Config.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -133,6 +133,8 @@ #include "slic3r/Utils/NetworkAgent.hpp" #include +using json = nlohmann::json; + namespace Slic3r { class PrintBase; } namespace fs = boost::filesystem; diff --git a/src/slic3r/GUI/SendMultiMachinePage.cpp b/src/slic3r/GUI/SendMultiMachinePage.cpp index c66a0f6055..acf4fe11b5 100644 --- a/src/slic3r/GUI/SendMultiMachinePage.cpp +++ b/src/slic3r/GUI/SendMultiMachinePage.cpp @@ -26,7 +26,7 @@ #include "slic3r/GUI/DeviceCore/DevDefs.h" #include "slic3r/GUI/PartPlate.hpp" #include "libslic3r/PrintConfig.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "slic3r/GUI/MsgDialog.hpp" #include "slic3r/GUI/Widgets/Label.hpp" #include "slic3r/GUI/Widgets/TextInput.hpp" @@ -77,6 +77,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index 4a17aff571..af908c0c80 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -23,7 +23,7 @@ #include #include "slic3r/GUI/wxMediaCtrl3.h" #include "slic3r/GUI/Widgets/StaticBox.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include "libslic3r/calib.hpp" @@ -689,7 +689,7 @@ protected: int m_last_vcamera = -1; int m_model_mall_request_count = 0; bool m_is_load_with_temp = false; - json m_rating_result; + nlohmann::json m_rating_result; wxWebRequest web_request; bool bed_temp_input = false; diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index f4c59088bd..a9dba84871 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -15,7 +15,7 @@ #include "libslic3r/Utils.hpp" #include #include "slic3r/GUI/BBLStatusBarPrint.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include "libslic3r/PrintConfig.hpp" #include @@ -85,6 +85,7 @@ #include "slic3r/Utils/NetworkAgent.hpp" namespace fs = boost::filesystem; +using json = nlohmann::json; using namespace Slic3r; using namespace Slic3r::GUI; diff --git a/src/slic3r/GUI/TaskManager.cpp b/src/slic3r/GUI/TaskManager.cpp index 8170da5a34..712bfea67e 100644 --- a/src/slic3r/GUI/TaskManager.cpp +++ b/src/slic3r/GUI/TaskManager.cpp @@ -20,7 +20,6 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" using namespace nlohmann; diff --git a/src/slic3r/GUI/UserManager.cpp b/src/slic3r/GUI/UserManager.cpp index cdc2bfcaf5..44e21223a8 100644 --- a/src/slic3r/GUI/UserManager.cpp +++ b/src/slic3r/GUI/UserManager.cpp @@ -1,4 +1,4 @@ -#include "json_diff.hpp" +#include #include "UserManager.hpp" #include "BindDialog.hpp" #include "GUI_App.hpp" @@ -10,6 +10,8 @@ #include +using json = nlohmann::json; + namespace Slic3r { UserManager::UserManager(NetworkAgent* agent) diff --git a/src/slic3r/GUI/UserManager.hpp b/src/slic3r/GUI/UserManager.hpp index a7f402cbac..9e80e23bbe 100644 --- a/src/slic3r/GUI/UserManager.hpp +++ b/src/slic3r/GUI/UserManager.hpp @@ -9,12 +9,9 @@ #include #include #include "nlohmann/json.hpp" -#include "slic3r/Utils/json_diff.hpp" #include "slic3r/Utils/NetworkAgent.hpp" -using namespace nlohmann; - namespace Slic3r { class NetworkAgent; diff --git a/src/slic3r/GUI/WebDownPluginDlg.cpp b/src/slic3r/GUI/WebDownPluginDlg.cpp index 93c8c77d46..0bb93ef55b 100644 --- a/src/slic3r/GUI/WebDownPluginDlg.cpp +++ b/src/slic3r/GUI/WebDownPluginDlg.cpp @@ -4,7 +4,7 @@ #include "slic3r/GUI/GUI.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include "I18N.hpp" diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 665280aca9..8ca85d4119 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -36,7 +36,7 @@ #include "libslic3r/PresetBundle.hpp" #include "libslic3r/PresetCacheFormat.hpp" #include "slic3r/GUI/GUI_App.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "libslic3r_version.h" #include @@ -78,7 +78,6 @@ #include "libslic3r/PrintConfig.hpp" #include "slic3r/Utils/NetworkAgent.hpp" #include "slic3r/Utils/PresetUpdater.hpp" -#include "slic3r/Utils/json_diff.hpp" class wxWindow; diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index bf7c7d9365..0f35a90a09 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -5,7 +5,6 @@ #include "slic3r/GUI/HttpServer.hpp" #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" #include "slic3r/GUI/GUI.hpp" #include #include diff --git a/src/slic3r/GUI/WebViewDialog.cpp b/src/slic3r/GUI/WebViewDialog.cpp index d46615328b..f73eec6abd 100644 --- a/src/slic3r/GUI/WebViewDialog.cpp +++ b/src/slic3r/GUI/WebViewDialog.cpp @@ -24,7 +24,7 @@ #include #include #include -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include #include #include @@ -44,6 +44,7 @@ #include namespace pt = boost::property_tree; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Widgets/FanControl.cpp b/src/slic3r/GUI/Widgets/FanControl.cpp index adb440d876..a6352ebd1d 100644 --- a/src/slic3r/GUI/Widgets/FanControl.cpp +++ b/src/slic3r/GUI/Widgets/FanControl.cpp @@ -3,7 +3,7 @@ #include "../I18N.hpp" #include "../GUI_App.hpp" #include "../MsgDialog.hpp" -#include "json_diff.hpp" +#include #include #include @@ -28,6 +28,8 @@ #include #include +using json = nlohmann::json; + namespace Slic3r { namespace GUI { wxDEFINE_EVENT(EVT_FAN_SWITCH_ON, wxCommandEvent); diff --git a/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp b/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp index 2fe66de8de..de863bd06d 100644 --- a/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp +++ b/src/slic3r/GUI/Widgets/MultiNozzleSync.cpp @@ -12,7 +12,7 @@ #include "Label.hpp" #include "ComboBox.hpp" #include "StaticBox.hpp" -#include "json_diff.hpp" +#include #include "libslic3r/PresetBundle.hpp" #include "libslic3r/Utils.hpp" @@ -55,6 +55,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/WipeTowerDialog.cpp b/src/slic3r/GUI/WipeTowerDialog.cpp index 8e2b0fcb9c..3aaee6b849 100644 --- a/src/slic3r/GUI/WipeTowerDialog.cpp +++ b/src/slic3r/GUI/WipeTowerDialog.cpp @@ -38,11 +38,12 @@ #include "Widgets/Label.hpp" #include "MainFrame.hpp" #include "libslic3r/PresetBundle.hpp" -#include "slic3r/GUI/Printer/PrinterFileSystem.h" +#include #include "slic3r/GUI/Jobs/SendJob.hpp" -#include "slic3r/Utils/json_diff.hpp" #include +using json = nlohmann::json; + class wxWindow; namespace fs = boost::filesystem; diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 5babf843bc..56b58b5c57 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -453,7 +453,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in, const bool menu_bitmap/* = false*/, const bool resize/* = false*/, const bool bitmap2/* = false*/, - const vector& array_new_color/* = vector*/)//used for semi transparent material) + const std::vector& array_new_color/* = vector*/)//used for semi transparent material) { static Slic3r::GUI::BitmapCache cache; @@ -501,7 +501,7 @@ wxBitmap create_scaled_bitmap( const std::string& bmp_name_in, wxBitmap create_scaled_bitmap2(const std::string& bmp_name_in, Slic3r::GUI::BitmapCache& cache, wxWindow* win/* = nullptr*/ , const int px_cnt/* = 16*/, const bool grayscale/* = false*/ , const bool resize/* = false*/ , - const vector& array_new_color/* = vector()*/) // color witch will used instead of orange + const std::vector& array_new_color/* = vector()*/) // color witch will used instead of orange { unsigned int width = 0; // win may be nullptr; see create_scaled_bitmap() above. diff --git a/src/slic3r/Utils/CalibUtils.cpp b/src/slic3r/Utils/CalibUtils.cpp index f0fcdd53e6..2a4ca8c05a 100644 --- a/src/slic3r/Utils/CalibUtils.cpp +++ b/src/slic3r/Utils/CalibUtils.cpp @@ -6,7 +6,7 @@ #include "NetworkAgent.hpp" #include "../GUI/Jobs/ProgressIndicator.hpp" #include "../GUI/PartPlate.hpp" -#include "json_diff.hpp" +#include #include "libslic3r/CutUtils.hpp" #include "libslic3r/ClipperUtils.hpp" #include "libslic3r/Utils.hpp" @@ -61,6 +61,7 @@ #include namespace fs = boost::filesystem; +using json = nlohmann::json; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 90807eb723..ee67950b20 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -38,7 +38,7 @@ #include #include -#include "json_diff.hpp" +#include #include "libslic3r/format.hpp" #include "libslic3r/Utils.hpp" #include "libslic3r/PresetBundle.hpp" @@ -58,6 +58,8 @@ #include "slic3r/GUI/MarkdownTip.hpp" #include "libslic3r/miniz_extension.hpp" +using json = nlohmann::json; + namespace Slic3r::GUI::Config { class Snapshot; } namespace Slic3r::GUI::Config { class SnapshotDB; } diff --git a/src/slic3r/Utils/json_diff.hpp b/src/slic3r/Utils/json_diff.hpp index 6ba5a1b8e4..bb88e78c7f 100644 --- a/src/slic3r/Utils/json_diff.hpp +++ b/src/slic3r/Utils/json_diff.hpp @@ -8,7 +8,6 @@ #include "nlohmann/json.hpp" -using json = nlohmann::json; using namespace std; class json_diff @@ -16,25 +15,25 @@ class json_diff private: std::string printer_type; std::string printer_version = "00.00.00.00"; - json settings_base; - json full_message; + nlohmann::json settings_base; + nlohmann::json full_message; - json diff2all_base; - json all2diff_base; + nlohmann::json diff2all_base; + nlohmann::json all2diff_base; int decode_error_count = 0; - int diff_objects(json const &in, json &out, json const &base); - int restore_objects(json const &in, json &out, json const &base); - int restore_append_objects(json const &in, json &out); - void merge_objects(json const &in, json &out); + int diff_objects(nlohmann::json const &in, nlohmann::json &out, nlohmann::json const &base); + int restore_objects(nlohmann::json const &in, nlohmann::json &out, nlohmann::json const &base); + int restore_append_objects(nlohmann::json const &in, nlohmann::json &out); + void merge_objects(nlohmann::json const &in, nlohmann::json &out); public: bool load_compatible_settings(std::string const &type, std::string const &version); - int all2diff(json const &in, json &out); - int diff2all(json const &in, json &out); - int all2diff_base_reset(json const &base); - int diff2all_base_reset(json &base); - void compare_print(json &a, json &b); + int all2diff(nlohmann::json const &in, nlohmann::json &out); + int diff2all(nlohmann::json const &in, nlohmann::json &out); + int all2diff_base_reset(nlohmann::json const &base); + int diff2all_base_reset(nlohmann::json &base); + void compare_print(nlohmann::json &a, nlohmann::json &b); bool is_need_request(); }; From 23546e71ceb682ad595e74fd2e488d80dad33b5b Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:22:32 +0800 Subject: [PATCH 09/22] Remove Unused Usings and the Includes Kept Only for Them (#16220) 151 using-directives, using-declarations, type aliases and namespace aliases in source and test files that nothing refers to: the name is never used, it duplicates a using already in scope, or the code sits inside the namespace it names. Each one was removed on its own and the file still compiled, both as it is and with every header-level using taken away, so none of them was only redundant because a header leaks the same name. With the using gone, 28 #include lines and one forward declaration had no other reference left in their file (boost/optional.hpp without any optional, property_tree headers without any ptree) and go with it. No header is touched. --- .../Arachne/SkeletalTrapezoidation.cpp | 2 - src/libslic3r/Arrange.cpp | 1 - src/libslic3r/CutSurface.cpp | 1 - src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp | 2 - src/libslic3r/Fill/FillTpmsFK.cpp | 2 - src/libslic3r/Format/AMF.cpp | 1 - src/libslic3r/GCode/SeamPlacer.cpp | 1 - src/libslic3r/GCode/ToolOrdering.cpp | 2 - src/libslic3r/LayerRegion.cpp | 2 - src/libslic3r/MeshBoolean.cpp | 1 - src/libslic3r/NSVGUtils.cpp | 1 - src/libslic3r/PlaceholderParser.cpp | 1 - src/libslic3r/PresetBundle.cpp | 1 - src/libslic3r/utils.cpp | 2 - src/slic3r/GUI/BaseTransparentDPIFrame.cpp | 2 - src/slic3r/GUI/BitmapComboBox.cpp | 2 - src/slic3r/GUI/ConfigWizard.cpp | 1 - .../GUI/DeviceCore/DevExtensionTool.cpp | 2 - .../GUI/DeviceCore/DevExtruderSystemCtrl.cpp | 3 -- src/slic3r/GUI/DeviceCore/DevMapping.cpp | 3 -- src/slic3r/GUI/DeviceManager.cpp | 2 - src/slic3r/GUI/ExtraRenderers.cpp | 3 -- src/slic3r/GUI/Gizmos/GLGizmoCut.cpp | 2 - src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp | 1 - src/slic3r/GUI/ImageDPIFrame.cpp | 3 -- .../GUI/Jobs/CreateFontNameImageJob.cpp | 1 - .../GUI/Jobs/CreateFontStyleImagesJob.cpp | 3 -- src/slic3r/GUI/MonitorBasePanel.cpp | 1 - src/slic3r/GUI/PartPlate.cpp | 5 --- src/slic3r/GUI/Plater.cpp | 4 -- src/slic3r/GUI/PresetComboBoxes.cpp | 2 - src/slic3r/GUI/ReleaseNote.cpp | 2 - src/slic3r/GUI/SavePresetDialog.cpp | 2 - src/slic3r/GUI/Search.cpp | 4 -- src/slic3r/GUI/SyncAmsInfoDialog.cpp | 3 -- src/slic3r/GUI/UnsavedChangesDialog.cpp | 4 -- src/slic3r/GUI/WebGuideDialog.cpp | 2 - src/slic3r/GUI/WebUserLoginDialog.cpp | 1 - src/slic3r/Utils/3DPrinterOS.cpp | 3 -- src/slic3r/Utils/AstroBox.cpp | 1 - src/slic3r/Utils/BBLCloudServiceAgent.cpp | 2 - src/slic3r/Utils/CrealityPrint.cpp | 6 --- src/slic3r/Utils/CrealityPrintAgent.cpp | 1 - src/slic3r/Utils/Duet.cpp | 6 --- src/slic3r/Utils/ESP3D.cpp | 5 --- src/slic3r/Utils/ElegooLink.cpp | 1 - src/slic3r/Utils/EmbossStyleManager.cpp | 1 - src/slic3r/Utils/FlashAir.cpp | 4 -- src/slic3r/Utils/Flashforge.cpp | 3 -- src/slic3r/Utils/FontConfigHelp.cpp | 2 - src/slic3r/Utils/MKS.cpp | 6 --- src/slic3r/Utils/Obico.cpp | 1 - src/slic3r/Utils/OctoPrint.cpp | 1 - src/slic3r/Utils/PresetUpdater.cpp | 2 - src/slic3r/Utils/PrintHost.cpp | 3 -- src/slic3r/Utils/QidiPrinterAgent.cpp | 2 - src/slic3r/Utils/Repetier.cpp | 1 - src/slic3r/Utils/Serial.cpp | 1 - src/slic3r/Utils/SnapmakerPrinterAgent.cpp | 2 - src/slic3r/Utils/TCPConsole.cpp | 5 --- src/slic3r/Utils/UltiMaker.cpp | 3 -- src/slic3r/Utils/json_diff.cpp | 1 - tests/fff_print/test_flow.cpp | 1 - tests/fff_print/test_helpers.cpp | 2 - tests/fff_print/test_model.cpp | 1 - tests/fff_print/test_trianglemesh.cpp | 1 - tests/libslic3r/test_arachne_walls.cpp | 1 - tests/libslic3r/test_caddocument.cpp | 43 ------------------- tests/libslic3r/test_config.cpp | 3 -- tests/libslic3r/test_indexed_triangle_set.cpp | 5 --- tests/libslic3r/test_marchingsquares.cpp | 2 - tests/libslic3r/test_timeutils.cpp | 2 - tests/libslic3r/test_voronoi.cpp | 4 -- tests/slic3rutils/test_plugin_sort.cpp | 3 -- .../test_slicing_pipeline_bindings.cpp | 4 -- 75 files changed, 213 deletions(-) diff --git a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp index 3248116169..077ffd1af6 100644 --- a/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp +++ b/src/libslic3r/Arachne/SkeletalTrapezoidation.cpp @@ -466,8 +466,6 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys) edge.from->incident_edge = &edge; } -using NodeSet = SkeletalTrapezoidation::NodeSet; - void SkeletalTrapezoidation::separatePointyQuadEndNodes() { NodeSet visited_nodes; diff --git a/src/libslic3r/Arrange.cpp b/src/libslic3r/Arrange.cpp index 520f02f5f2..b79450a535 100644 --- a/src/libslic3r/Arrange.cpp +++ b/src/libslic3r/Arrange.cpp @@ -93,7 +93,6 @@ using namespace libnest2d; using Item = _Item; using Box = _Box; using Circle = _Circle; -using Segment = _Segment; using MultiPolygon = ExPolygons; // Summon the spatial indexing facilities from boost diff --git a/src/libslic3r/CutSurface.cpp b/src/libslic3r/CutSurface.cpp index 8967f6c2ba..cf5bd119f4 100644 --- a/src/libslic3r/CutSurface.cpp +++ b/src/libslic3r/CutSurface.cpp @@ -2851,7 +2851,6 @@ bool is_patch_inside_of_model(const SurfacePatch &patch, /// shape point index uint32_t get_shape_point_index(const CutAOI &cut, const CutMesh &model); -using PatchNumber = CutMesh::Property_map; /// /// Separate triangles singned with number n /// diff --git a/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp b/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp index ae8d50edb7..301eabebc3 100644 --- a/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp +++ b/src/libslic3r/Feature/FuzzySkin/FuzzySkin.cpp @@ -32,8 +32,6 @@ // #define DEBUG_FUZZY -using namespace Slic3r; - namespace Slic3r::Feature::FuzzySkin { // Produces a random value between 0 and 1. Thread-safe. diff --git a/src/libslic3r/Fill/FillTpmsFK.cpp b/src/libslic3r/Fill/FillTpmsFK.cpp index 61dd220e64..164e240280 100644 --- a/src/libslic3r/Fill/FillTpmsFK.cpp +++ b/src/libslic3r/Fill/FillTpmsFK.cpp @@ -122,8 +122,6 @@ Polylines get_polylines(const ScalarField& sf, const double tolerance = SCALED_E namespace Slic3r { -using namespace std; - void FillTpmsFK::_fill_surface_single(const FillParams& params, unsigned int thickness_layers, const std::pair& direction, diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp index 57165794c2..fa28d93f09 100644 --- a/src/libslic3r/Format/AMF.cpp +++ b/src/libslic3r/Format/AMF.cpp @@ -25,7 +25,6 @@ #include #include #include -namespace pt = boost::property_tree; #include #include diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index 07e1cc8882..c591dd1c6a 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -1135,7 +1135,6 @@ void SeamPlacer::gather_seam_candidates(const PrintObject *po, const SeamPlacerI void SeamPlacer::calculate_candidates_visibility(const PrintObject *po, const SeamPlacerImpl::GlobalModelInfo &global_model_info) { - using namespace SeamPlacerImpl; std::vector &layers = m_seam_per_object[po].layers; tbb::parallel_for(tbb::blocked_range(0, layers.size()), diff --git a/src/libslic3r/GCode/ToolOrdering.cpp b/src/libslic3r/GCode/ToolOrdering.cpp index 701c2a5858..c0f43f1888 100644 --- a/src/libslic3r/GCode/ToolOrdering.cpp +++ b/src/libslic3r/GCode/ToolOrdering.cpp @@ -1482,7 +1482,6 @@ static FilamentGroupContext build_filament_group_context( FilamentMapMode mode, const std::unordered_map& nozzle_status) { - using namespace MultiNozzleUtils; using namespace FilamentGroupUtils; FilamentGroupContext context; @@ -1691,7 +1690,6 @@ static std::vector apply_master_extruder_preference(const FilamentGroupCont // multi-nozzle (H2C/A2L) resolves to a nozzle-granular result. MultiNozzleUtils::LayeredNozzleGroupResult ToolOrdering::get_recommended_filament_maps(const std::vector>& layer_filaments, const Print* print, const FilamentMapMode mode, const std::vector>& physical_unprintables, const std::vector>& geometric_unprintables, const std::map>& unprintable_volumes, const std::unordered_map& nozzle_status) { - using namespace FilamentGroupUtils; using namespace MultiNozzleUtils; if (!print || layer_filaments.empty()) diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index 5bc68c4ca5..340f9a590d 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -230,7 +230,6 @@ std::vector get_grouped_bridges( { result.reserve(bridge_expansions.size()); uint32_t group_id = 0; - using std::move_iterator; for (ExPolygon& expolygon : bridge_expolygons) result.push_back({ std::move(expolygon), group_id ++, bridge_expansions.end() }); } @@ -432,7 +431,6 @@ Surfaces expand_bridges_detect_orientations( const float closing_radius ) { - using namespace Slic3r::Algorithm; double thickness; ExPolygons bridge_expolygons = fill_surfaces_extract_expolygons(surfaces, {stBottomBridge}, thickness); diff --git a/src/libslic3r/MeshBoolean.cpp b/src/libslic3r/MeshBoolean.cpp index 2a05378f58..8f30b356d1 100644 --- a/src/libslic3r/MeshBoolean.cpp +++ b/src/libslic3r/MeshBoolean.cpp @@ -660,7 +660,6 @@ bool empty(const CGALMesh &mesh) bool repair(TriangleMesh& mesh, RepairedMeshErrors* repaired_errors, std::string* error) { - using namespace CGAL; namespace PMP = CGAL::Polygon_mesh_processing; if (mesh.empty()) diff --git a/src/libslic3r/NSVGUtils.cpp b/src/libslic3r/NSVGUtils.cpp index 5274ffad4f..d81d5d5258 100644 --- a/src/libslic3r/NSVGUtils.cpp +++ b/src/libslic3r/NSVGUtils.cpp @@ -263,7 +263,6 @@ size_t get_shapes_count(const NSVGimage &image) } // namespace Slic3r namespace { -using namespace Slic3r; // Polygon + Vec2f Point::coord_type to_coor(float val, double scale) { return static_cast(std::round(val * scale)); } diff --git a/src/libslic3r/PlaceholderParser.cpp b/src/libslic3r/PlaceholderParser.cpp index 8bddfc1f10..18bbc7812e 100644 --- a/src/libslic3r/PlaceholderParser.cpp +++ b/src/libslic3r/PlaceholderParser.cpp @@ -2175,7 +2175,6 @@ namespace client { macro_processor() : macro_processor::base_type(start) { - using namespace qi::labels; qi::alpha_type alpha; qi::alnum_type alnum; qi::eps_type eps; diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 4edcc70656..7e679adf21 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -1529,7 +1529,6 @@ bool PresetBundle::apply_vendor_config( const std::string& preferred_printer_variant, const std::string& preferred_filament) { - namespace fs = boost::filesystem; // Get current configuration from AppConfig const auto old_vendors = app_config->vendors(); diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 8d5ab732be..cd9ecf100d 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -404,7 +404,6 @@ std::string debug_out_path(const char *name, ...) } namespace logging = boost::log; -namespace src = boost::log::sources; namespace expr = boost::log::expressions; namespace keywords = boost::log::keywords; namespace attrs = boost::log::attributes; @@ -892,7 +891,6 @@ int copy_file_linux_read_write(int infile, int outfile, uintmax_t file_size) // and only features supported by Linux 3.10 (on our build server with CentOS 7) are kept, namely sendfile with ranges and statx() are not supported. bool copy_file_linux(const boost::filesystem::path &from, const boost::filesystem::path &to, boost::system::error_code &ec) { - using namespace boost::filesystem; struct fd_wrapper { diff --git a/src/slic3r/GUI/BaseTransparentDPIFrame.cpp b/src/slic3r/GUI/BaseTransparentDPIFrame.cpp index 14575aa988..c9e4e4b76e 100644 --- a/src/slic3r/GUI/BaseTransparentDPIFrame.cpp +++ b/src/slic3r/GUI/BaseTransparentDPIFrame.cpp @@ -22,8 +22,6 @@ #include "CapsuleButton.hpp" namespace Slic3r::GUI { struct IntEvent; } -using namespace Slic3r; -using namespace Slic3r::GUI; namespace Slic3r { namespace GUI { #define ANIMATION_REFRESH_INTERVAL 20 diff --git a/src/slic3r/GUI/BitmapComboBox.cpp b/src/slic3r/GUI/BitmapComboBox.cpp index 217b885b91..9e5645bb41 100644 --- a/src/slic3r/GUI/BitmapComboBox.cpp +++ b/src/slic3r/GUI/BitmapComboBox.cpp @@ -45,8 +45,6 @@ #include #endif -using Slic3r::GUI::format_wxstr; - #define BORDER_W 10 // --------------------------------- diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 6596cdca0c..347973c667 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -95,7 +95,6 @@ namespace GUI { using Config::Snapshot; -using Config::SnapshotDB; // Configuration data structures extensions needed for the wizard diff --git a/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp b/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp index 1947cf1d87..86cb7362c8 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp +++ b/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp @@ -5,8 +5,6 @@ #include #include -using namespace nlohmann; - namespace Slic3r { diff --git a/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp b/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp index 38513a2274..9379920b27 100644 --- a/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp +++ b/src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp @@ -1,11 +1,8 @@ -#include #include "DevExtruderSystem.h" #include "slic3r/GUI/DeviceManager.hpp" -using namespace nlohmann; - namespace Slic3r { int DevExtderSystem::CtrlRetrySwitching() diff --git a/src/slic3r/GUI/DeviceCore/DevMapping.cpp b/src/slic3r/GUI/DeviceCore/DevMapping.cpp index 1ad35d3ee9..906ac2345b 100644 --- a/src/slic3r/GUI/DeviceCore/DevMapping.cpp +++ b/src/slic3r/GUI/DeviceCore/DevMapping.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -21,8 +20,6 @@ #include "slic3r/GUI/DeviceManager.hpp" #include "slic3r/GUI/GuiColor.hpp" -using namespace nlohmann; - namespace Slic3r { bool DevMappingUtil::is_valid_mapping_result(const MachineObject* obj, std::vector& result, bool check_empty_slot) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 0eca3239b2..3729387040 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -117,8 +117,6 @@ namespace fs = boost::filesystem; #define ORCA_NETWORK_DEBUG -namespace pt = boost::property_tree; - float string_to_float(const std::string& str_value) { float value = 0.0; fast_float::from_chars(str_value.c_str(), str_value.c_str() + str_value.size(), value); diff --git a/src/slic3r/GUI/ExtraRenderers.cpp b/src/slic3r/GUI/ExtraRenderers.cpp index 92f39145f0..8f390b82e4 100644 --- a/src/slic3r/GUI/ExtraRenderers.cpp +++ b/src/slic3r/GUI/ExtraRenderers.cpp @@ -38,9 +38,6 @@ #include "wx/private/markupparser.h" #endif // wxUSE_ACCESSIBILITY -using Slic3r::GUI::from_u8; -using Slic3r::GUI::into_u8; - //----------------------------------------------------------------------------- // DataViewBitmapText diff --git a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp index e807ef1d4e..b3fe914afa 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoCut.cpp @@ -4098,8 +4098,6 @@ void GLGizmoCut3D::apply_cut_connectors(ModelObject* mo, const std::string& conn if (mo->cut_connectors.empty()) return; - using namespace Geometry; - size_t connector_id = mo->cut_id.connectors_cnt(); for (const CutConnector& connector : mo->cut_connectors) { TriangleMesh mesh = TriangleMesh(get_connector_mesh(connector.attribs)); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp index 2ab05d6179..c4d76a0315 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSVG.cpp @@ -77,7 +77,6 @@ #include using namespace Slic3r; -using namespace Slic3r::Emboss; using namespace Slic3r::GUI; using namespace Slic3r::GUI::Emboss; diff --git a/src/slic3r/GUI/ImageDPIFrame.cpp b/src/slic3r/GUI/ImageDPIFrame.cpp index 83904fe650..2884792451 100644 --- a/src/slic3r/GUI/ImageDPIFrame.cpp +++ b/src/slic3r/GUI/ImageDPIFrame.cpp @@ -19,9 +19,6 @@ #include #include "wxExtensions.hpp" -using namespace Slic3r; -using namespace Slic3r::GUI; - namespace Slic3r { namespace GUI { #define ANIMATION_REFRESH_INTERVAL 20 ImageDPIFrame::ImageDPIFrame() diff --git a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp index 6159182c2b..d80873d223 100644 --- a/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp +++ b/src/slic3r/GUI/Jobs/CreateFontNameImageJob.cpp @@ -30,7 +30,6 @@ #include "libslic3r/libslic3r.h" #include -using namespace Slic3r; using namespace Slic3r::GUI; const std::string CreateFontImageJob::default_text = "AaBbCc 123"; diff --git a/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp b/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp index ac9b11b81e..f1b545ad4c 100644 --- a/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp +++ b/src/slic3r/GUI/Jobs/CreateFontStyleImagesJob.cpp @@ -23,9 +23,6 @@ #include #include -using namespace Slic3r; -using namespace Slic3r::Emboss; -using namespace Slic3r::GUI; using namespace Slic3r::GUI::Emboss; diff --git a/src/slic3r/GUI/MonitorBasePanel.cpp b/src/slic3r/GUI/MonitorBasePanel.cpp index d8a1f3b835..e09be6d6f9 100644 --- a/src/slic3r/GUI/MonitorBasePanel.cpp +++ b/src/slic3r/GUI/MonitorBasePanel.cpp @@ -293,7 +293,6 @@ VideoMonitoringBasePanel::~VideoMonitoringBasePanel() /////////////////////////////////////////////////////////////////////////// -using namespace Slic3r::GUI; TaskListBasePanel::TaskListBasePanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxPanel(parent, id, pos, size, style, name) { diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 6450bf0747..9798d2df23 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -60,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -113,9 +111,6 @@ #include "slic3r/GUI/GLModel.hpp" class wxFont; -namespace boost { template class optional; } -using boost::optional; -namespace fs = boost::filesystem; static const float GROUND_Z = -0.03f; static const float GROUND_Z_GRIDLINE = -0.26f; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index c2b0e6f0a9..08dad219b0 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -296,11 +296,7 @@ #include "DeviceCore/DevConfigUtil.h" #include "DeviceCore/DevDefs.h" -using boost::optional; namespace fs = boost::filesystem; -using Slic3r::_3DScene; -using Slic3r::Preset; -using Slic3r::GUI::format_wxstr; using namespace nlohmann; static const std::pair THUMBNAIL_SIZE_3MF = { 512, 512 }; diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 29e34d98a0..d1e4d6126a 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -81,8 +81,6 @@ #include #endif -using Slic3r::GUI::format_wxstr; - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/ReleaseNote.cpp b/src/slic3r/GUI/ReleaseNote.cpp index 11b62728f2..b200473e08 100644 --- a/src/slic3r/GUI/ReleaseNote.cpp +++ b/src/slic3r/GUI/ReleaseNote.cpp @@ -78,8 +78,6 @@ using json = nlohmann::json; namespace Slic3r::GUI { class Plater; } -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent); diff --git a/src/slic3r/GUI/SavePresetDialog.cpp b/src/slic3r/GUI/SavePresetDialog.cpp index 1d4c2913db..1cae6420ed 100644 --- a/src/slic3r/GUI/SavePresetDialog.cpp +++ b/src/slic3r/GUI/SavePresetDialog.cpp @@ -42,8 +42,6 @@ #include "Widgets/DialogButtons.hpp" -using Slic3r::GUI::format_wxstr; - namespace Slic3r { namespace GUI { #define BORDER_W 10 diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index dcf0573321..597f809adc 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -1,6 +1,5 @@ #include "Search.hpp" -#include #include "slic3r/GUI/GUI.hpp" #include "libslic3r/Preset.hpp" #include "libslic3r/Config.hpp" @@ -22,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -56,8 +54,6 @@ #include "LinuxDisplayBackend.hpp" #endif -using boost::optional; - namespace Slic3r { wxDEFINE_EVENT(wxCUSTOMEVT_JUMP_TO_OPTION, wxCommandEvent); diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index a9dba84871..61998dc963 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -87,9 +87,6 @@ namespace fs = boost::filesystem; using json = nlohmann::json; -using namespace Slic3r; -using namespace Slic3r::GUI; - #define OK_BUTTON_SIZE wxSize(FromDIP(90), FromDIP(24)) #define CANCEL_BUTTON_SIZE wxSize(FromDIP(58), FromDIP(24)) #define SyncAmsInfoDialogWidth FromDIP(675) diff --git a/src/slic3r/GUI/UnsavedChangesDialog.cpp b/src/slic3r/GUI/UnsavedChangesDialog.cpp index dffc86a25c..b2bc818ad1 100644 --- a/src/slic3r/GUI/UnsavedChangesDialog.cpp +++ b/src/slic3r/GUI/UnsavedChangesDialog.cpp @@ -1,6 +1,5 @@ #include "UnsavedChangesDialog.hpp" -#include #include #include #include @@ -26,7 +25,6 @@ #include #include #include -#include #include #include @@ -66,8 +64,6 @@ #include "Widgets/DialogButtons.hpp" #include "Widgets/HyperLink.hpp" -using boost::optional; - #ifdef __linux__ #define wxLinux true #else diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index 8ca85d4119..b5b48d413e 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -81,8 +81,6 @@ class wxWindow; -namespace fs = boost::filesystem; - using namespace nlohmann; namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/WebUserLoginDialog.cpp b/src/slic3r/GUI/WebUserLoginDialog.cpp index 0f35a90a09..7f7c8c51c0 100644 --- a/src/slic3r/GUI/WebUserLoginDialog.cpp +++ b/src/slic3r/GUI/WebUserLoginDialog.cpp @@ -52,7 +52,6 @@ #include #include #include // ORCA -using namespace std; using namespace nlohmann; diff --git a/src/slic3r/Utils/3DPrinterOS.cpp b/src/slic3r/Utils/3DPrinterOS.cpp index 29b6bd63f8..f7a3387a7c 100644 --- a/src/slic3r/Utils/3DPrinterOS.cpp +++ b/src/slic3r/Utils/3DPrinterOS.cpp @@ -43,9 +43,6 @@ #include -using json = nlohmann::json; - -namespace fs = boost::filesystem; namespace pt = boost::property_tree; namespace { diff --git a/src/slic3r/Utils/AstroBox.cpp b/src/slic3r/Utils/AstroBox.cpp index 6904b56920..75976f7aa3 100644 --- a/src/slic3r/Utils/AstroBox.cpp +++ b/src/slic3r/Utils/AstroBox.cpp @@ -21,7 +21,6 @@ #include "Http.hpp" -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/BBLCloudServiceAgent.cpp b/src/slic3r/Utils/BBLCloudServiceAgent.cpp index 96525354e5..3737af2f18 100644 --- a/src/slic3r/Utils/BBLCloudServiceAgent.cpp +++ b/src/slic3r/Utils/BBLCloudServiceAgent.cpp @@ -18,8 +18,6 @@ #include #include "libslic3r/AppConfig.hpp" -using json = nlohmann::json; - namespace Slic3r { diff --git a/src/slic3r/Utils/CrealityPrint.cpp b/src/slic3r/Utils/CrealityPrint.cpp index 8a187ff998..081c5dd543 100644 --- a/src/slic3r/Utils/CrealityPrint.cpp +++ b/src/slic3r/Utils/CrealityPrint.cpp @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include #include #include @@ -55,7 +53,6 @@ #include #include using json = nlohmann::json; -using std::to_string; namespace beast = boost::beast; namespace http = beast::http; @@ -63,9 +60,6 @@ namespace websocket = beast::websocket; namespace net = boost::asio; using tcp = boost::asio::ip::tcp; -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { CrealityPrint::CrealityPrint(DynamicPrintConfig* config) : diff --git a/src/slic3r/Utils/CrealityPrintAgent.cpp b/src/slic3r/Utils/CrealityPrintAgent.cpp index 10f6a51c5d..a8910c2e09 100644 --- a/src/slic3r/Utils/CrealityPrintAgent.cpp +++ b/src/slic3r/Utils/CrealityPrintAgent.cpp @@ -214,7 +214,6 @@ bool CrealityPrintAgent::parse_cfs_response(const std::string& response, int& box_count, std::string& error) { - using nlohmann::json; slots.clear(); box_count = 0; diff --git a/src/slic3r/Utils/Duet.cpp b/src/slic3r/Utils/Duet.cpp index b5ad48fbae..419d795b65 100644 --- a/src/slic3r/Utils/Duet.cpp +++ b/src/slic3r/Utils/Duet.cpp @@ -3,11 +3,8 @@ #include #include #include -#include #include #include -#include -#include #include #include @@ -25,9 +22,6 @@ #include "slic3r/GUI/I18N.hpp" #include "Http.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { Duet::Duet(DynamicPrintConfig *config) : diff --git a/src/slic3r/Utils/ESP3D.cpp b/src/slic3r/Utils/ESP3D.cpp index 7f0cba2414..3890da8235 100644 --- a/src/slic3r/Utils/ESP3D.cpp +++ b/src/slic3r/Utils/ESP3D.cpp @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include #include @@ -28,9 +26,6 @@ #include "slic3r/GUI/I18N.hpp" #include "Http.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { ESP3D::ESP3D(DynamicPrintConfig* config) : m_host(config->opt_string("print_host")), m_console_port("8888") {} diff --git a/src/slic3r/Utils/ElegooLink.cpp b/src/slic3r/Utils/ElegooLink.cpp index d6b40578aa..bb83dca2f5 100644 --- a/src/slic3r/Utils/ElegooLink.cpp +++ b/src/slic3r/Utils/ElegooLink.cpp @@ -50,7 +50,6 @@ #include "slic3r/GUI/BonjourDialog.hpp" #include -namespace fs = boost::filesystem; namespace pt = boost::property_tree; #define MAX_UPLOAD_PACKAGE_LENGTH 1048576 //(1024*1024) diff --git a/src/slic3r/Utils/EmbossStyleManager.cpp b/src/slic3r/Utils/EmbossStyleManager.cpp index 5f03bd5df3..d873b40cf3 100644 --- a/src/slic3r/Utils/EmbossStyleManager.cpp +++ b/src/slic3r/Utils/EmbossStyleManager.cpp @@ -561,7 +561,6 @@ bool StyleManager::set_wx_font(const wxFont &wx_font, std::unique_ptr // StylesSerializable namespace { -using namespace Slic3r; using namespace Slic3r::GUI; using Section = std::map; diff --git a/src/slic3r/Utils/FlashAir.cpp b/src/slic3r/Utils/FlashAir.cpp index 16648c711d..0257fec556 100644 --- a/src/slic3r/Utils/FlashAir.cpp +++ b/src/slic3r/Utils/FlashAir.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -23,9 +22,6 @@ #include "slic3r/GUI/I18N.hpp" #include "Http.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { FlashAir::FlashAir(DynamicPrintConfig *config) : diff --git a/src/slic3r/Utils/Flashforge.cpp b/src/slic3r/Utils/Flashforge.cpp index b0697b80d4..fd6ad6fcf7 100644 --- a/src/slic3r/Utils/Flashforge.cpp +++ b/src/slic3r/Utils/Flashforge.cpp @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include #include @@ -55,7 +53,6 @@ #include "SerialMessageType.hpp" namespace fs = boost::filesystem; -namespace pt = boost::property_tree; using json = nlohmann::json; namespace Slic3r { diff --git a/src/slic3r/Utils/FontConfigHelp.cpp b/src/slic3r/Utils/FontConfigHelp.cpp index f3280ad83d..81f7d9784c 100644 --- a/src/slic3r/Utils/FontConfigHelp.cpp +++ b/src/slic3r/Utils/FontConfigHelp.cpp @@ -13,8 +13,6 @@ #include #include "libslic3r/Utils.hpp" -using namespace Slic3r::GUI; - // @Vojta suggest to make static variable global // Guard for finalize Font Config diff --git a/src/slic3r/Utils/MKS.cpp b/src/slic3r/Utils/MKS.cpp index 52649a667f..cac9f08110 100644 --- a/src/slic3r/Utils/MKS.cpp +++ b/src/slic3r/Utils/MKS.cpp @@ -4,11 +4,8 @@ #include #include #include -#include #include #include -#include -#include #include #include @@ -31,9 +28,6 @@ #include "SerialMessage.hpp" #include "SerialMessageType.hpp" -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; - namespace Slic3r { MKS::MKS(DynamicPrintConfig* config) : diff --git a/src/slic3r/Utils/Obico.cpp b/src/slic3r/Utils/Obico.cpp index 37a618445a..1a86be377b 100644 --- a/src/slic3r/Utils/Obico.cpp +++ b/src/slic3r/Utils/Obico.cpp @@ -30,7 +30,6 @@ #include "libslic3r/AppConfig.hpp" #include "slic3r/GUI/BonjourDialog.hpp" -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/OctoPrint.cpp b/src/slic3r/Utils/OctoPrint.cpp index 63199c8781..8fb511d193 100644 --- a/src/slic3r/Utils/OctoPrint.cpp +++ b/src/slic3r/Utils/OctoPrint.cpp @@ -37,7 +37,6 @@ #include #include -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index ee67950b20..344a5f881c 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -66,8 +66,6 @@ namespace Slic3r::GUI::Config { class SnapshotDB; } namespace fs = boost::filesystem; using Slic3r::GUI::Config::Index; using Slic3r::GUI::Config::Version; -using Slic3r::GUI::Config::Snapshot; -using Slic3r::GUI::Config::SnapshotDB; // FIXME: Incompat bundle resolution doesn't deal with inherited user presets diff --git a/src/slic3r/Utils/PrintHost.cpp b/src/slic3r/Utils/PrintHost.cpp index 2b3c4d181d..b51dcc6af3 100644 --- a/src/slic3r/Utils/PrintHost.cpp +++ b/src/slic3r/Utils/PrintHost.cpp @@ -1,6 +1,5 @@ #include "PrintHost.hpp" -#include #include "libslic3r/Config.hpp" #include #include @@ -16,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -50,7 +48,6 @@ #include "Moonraker.hpp" namespace fs = boost::filesystem; -using boost::optional; using Slic3r::GUI::PrintHostQueueDialog; namespace Slic3r { diff --git a/src/slic3r/Utils/QidiPrinterAgent.cpp b/src/slic3r/Utils/QidiPrinterAgent.cpp index 06499e1092..c2dc4411a6 100644 --- a/src/slic3r/Utils/QidiPrinterAgent.cpp +++ b/src/slic3r/Utils/QidiPrinterAgent.cpp @@ -18,8 +18,6 @@ #include #include -using json = nlohmann::json; - namespace Slic3r { namespace { diff --git a/src/slic3r/Utils/Repetier.cpp b/src/slic3r/Utils/Repetier.cpp index ae269cac4f..1663a3570a 100644 --- a/src/slic3r/Utils/Repetier.cpp +++ b/src/slic3r/Utils/Repetier.cpp @@ -27,7 +27,6 @@ #include "Http.hpp" -namespace fs = boost::filesystem; namespace pt = boost::property_tree; diff --git a/src/slic3r/Utils/Serial.cpp b/src/slic3r/Utils/Serial.cpp index 2b64330826..1b54125c0f 100644 --- a/src/slic3r/Utils/Serial.cpp +++ b/src/slic3r/Utils/Serial.cpp @@ -288,7 +288,6 @@ std::vector scan_serial_ports() // Class Serial namespace asio = boost::asio; -using boost::system::error_code; Serial::Serial(asio::io_service& io_service) : asio::serial_port(io_service) diff --git a/src/slic3r/Utils/SnapmakerPrinterAgent.cpp b/src/slic3r/Utils/SnapmakerPrinterAgent.cpp index a237d1b2b1..b172ebb015 100644 --- a/src/slic3r/Utils/SnapmakerPrinterAgent.cpp +++ b/src/slic3r/Utils/SnapmakerPrinterAgent.cpp @@ -13,8 +13,6 @@ #include #include -using json = nlohmann::json; - namespace Slic3r { namespace { diff --git a/src/slic3r/Utils/TCPConsole.cpp b/src/slic3r/Utils/TCPConsole.cpp index 78d4624abc..45192c2786 100644 --- a/src/slic3r/Utils/TCPConsole.cpp +++ b/src/slic3r/Utils/TCPConsole.cpp @@ -3,9 +3,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -24,9 +22,6 @@ #include "SerialMessage.hpp" #include "SerialMessageType.hpp" -using boost::asio::steady_timer; -using boost::asio::ip::tcp; - namespace Slic3r { namespace Utils { diff --git a/src/slic3r/Utils/UltiMaker.cpp b/src/slic3r/Utils/UltiMaker.cpp index 432725f0e8..9b6894034e 100644 --- a/src/slic3r/Utils/UltiMaker.cpp +++ b/src/slic3r/Utils/UltiMaker.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -34,8 +33,6 @@ #include #include #include -namespace fs = boost::filesystem; -namespace pt = boost::property_tree; namespace Slic3r { diff --git a/src/slic3r/Utils/json_diff.cpp b/src/slic3r/Utils/json_diff.cpp index 171a44c63d..37bb55f799 100644 --- a/src/slic3r/Utils/json_diff.cpp +++ b/src/slic3r/Utils/json_diff.cpp @@ -16,7 +16,6 @@ #include #include -using namespace std; using json = nlohmann::json; int json_diff::diff_objects(json const &in, json &out, json const &base) diff --git a/tests/fff_print/test_flow.cpp b/tests/fff_print/test_flow.cpp index 328c610e02..f3e8abd02e 100644 --- a/tests/fff_print/test_flow.cpp +++ b/tests/fff_print/test_flow.cpp @@ -12,7 +12,6 @@ #include "libslic3r/Flow.hpp" #include "libslic3r/libslic3r.h" -using namespace Slic3r::Test; using namespace Slic3r; /// Test the expected behavior for auto-width, diff --git a/tests/fff_print/test_helpers.cpp b/tests/fff_print/test_helpers.cpp index e32f79944e..14365a5860 100644 --- a/tests/fff_print/test_helpers.cpp +++ b/tests/fff_print/test_helpers.cpp @@ -27,8 +27,6 @@ #include "test_utils.hpp" -using namespace std; - namespace Slic3r { namespace Test { const std::unordered_map mesh_names { diff --git a/tests/fff_print/test_model.cpp b/tests/fff_print/test_model.cpp index 43041c0bdf..1ad806e455 100644 --- a/tests/fff_print/test_model.cpp +++ b/tests/fff_print/test_model.cpp @@ -19,7 +19,6 @@ #include "libslic3r/Print.hpp" using namespace Slic3r; -using namespace Slic3r::Test; SCENARIO("Model construction", "[Model]") { GIVEN("A Slic3r Model") { diff --git a/tests/fff_print/test_trianglemesh.cpp b/tests/fff_print/test_trianglemesh.cpp index b7e3b96beb..ab5c334d2e 100644 --- a/tests/fff_print/test_trianglemesh.cpp +++ b/tests/fff_print/test_trianglemesh.cpp @@ -21,7 +21,6 @@ //#include "test_options.hpp" using namespace Slic3r; -using namespace std; static inline TriangleMesh make_cube() { return make_cube(20., 20, 20); } diff --git a/tests/libslic3r/test_arachne_walls.cpp b/tests/libslic3r/test_arachne_walls.cpp index f568a0d014..9f216a0518 100644 --- a/tests/libslic3r/test_arachne_walls.cpp +++ b/tests/libslic3r/test_arachne_walls.cpp @@ -241,7 +241,6 @@ TEST_CASE("Arachne wall generation - 60% min_bead_width", "[Arachne]") { // getTransitionThickness(1) = (1 + 0.619) * 0.42 = 0.68mm. A 0.5mm-thick wall therefore sits // in the transition band: alpha produced 2 beads here, beta collapses it to 1 fat bead. TEST_CASE("Arachne widening keeps two beads in transition band (#14376)", "[Arachne]") { - using namespace Slic3r::Arachne; // Widths in mm; the scaled coord_t values and the thresholds below are both derived from // these so a width change cannot silently desync the transition-band math. diff --git a/tests/libslic3r/test_caddocument.cpp b/tests/libslic3r/test_caddocument.cpp index 84c93a39d0..4ee1de587d 100644 --- a/tests/libslic3r/test_caddocument.cpp +++ b/tests/libslic3r/test_caddocument.cpp @@ -992,7 +992,6 @@ TEST_CASE("tessellate tracks per-triangle face id", "[CadDocument]") TEST_CASE("extrude two-sided + through-all + intersect", "[CadDocument]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); // a 10x10 square wire centred on origin SketchProfile sp; @@ -1013,7 +1012,6 @@ TEST_CASE("extrude two-sided + through-all + intersect", "[CadDocument]") TEST_CASE("extrude taper + up-to-face distance", "[CadDocument]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); SketchProfile sp; sp.points = { Vec2d(-5,-5),Vec2d(5,-5),Vec2d(5,5),Vec2d(-5,5) }; sp.closed = true; TopoDS_Wire w = sp.to_occt_wire(xy); @@ -1047,7 +1045,6 @@ TEST_CASE("extrude taper + up-to-face distance", "[CadDocument]") // asserting, because that is what "the thread actually cuts" means. TEST_CASE("internal thread cuts a visible groove into the bore wall", "[CadDocument][thread]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); // 40x40x20 box centred on the origin, extruded +Z. @@ -1093,7 +1090,6 @@ TEST_CASE("internal thread cuts a visible groove into the bore wall", "[CadDocum TEST_CASE("revolve builds a solid of revolution about an in-plane axis", "[CadDocument]") { - using namespace Slic3r; SketchPlane xy = SketchPlane::XY(); // Rectangle profile (10 wide x 10 tall, area 100) offset to +v so it lies entirely @@ -1136,7 +1132,6 @@ TEST_CASE("revolve builds a solid of revolution about an in-plane axis", "[CadDo TEST_CASE("sweep builds a solid by sweeping a profile along a path", "[CadDocument]") { - using namespace Slic3r; CadDocument doc; // Profile: circle r=5 on the XY plane at the origin (area = 25*pi). @@ -1172,7 +1167,6 @@ TEST_CASE("sweep builds a solid by sweeping a profile along a path", "[CadDocume TEST_CASE("pattern replicates a body linearly and circularly", "[CadDocument]") { - using namespace Slic3r; // Linear: a 10x10x10 box (V=1000) repeated 3x at 20mm spacing along plane X. // 20 > 10 so the copies are disjoint -> total V = 3*1000 = 3000. @@ -1221,8 +1215,6 @@ TEST_CASE("pattern replicates a body linearly and circularly", "[CadDocument]") TEST_CASE("pattern-on-curve: copies land on a line and bbox spans the curve length", "[CadDocument][pattern]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; - using namespace Slic3r; CadDocument doc; @@ -1250,7 +1242,6 @@ TEST_CASE("pattern-on-curve: copies land on a line and bbox spans the curve leng TEST_CASE("pattern-on-curve: bad refs are safe", "[CadDocument][pattern]") { - using namespace Slic3r; CadDocument doc; int s0 = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 4, 4, 0, "Seed"); @@ -1266,7 +1257,6 @@ TEST_CASE("pattern-on-curve: bad refs are safe", "[CadDocument][pattern]") TEST_CASE("pattern-on-curve: round-trip through serialize/deserialize", "[CadDocument][pattern]") { using Catch::Matchers::WithinRel; - using namespace Slic3r; CadDocument doc; int s0 = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 4, 4, 0, "Seed"); @@ -1312,7 +1302,6 @@ TEST_CASE("pattern-on-curve: round-trip through serialize/deserialize", "[CadDoc TEST_CASE("thread standards table carries correct ISO/UTS measures", "[CadDocument]") { - using namespace Slic3r; // Table is non-empty and every entry is self-consistent. const auto& table = thread_standards(); @@ -1459,7 +1448,6 @@ TEST_CASE("loft builds a solid skinning two profiles on parallel planes", "[CadD TEST_CASE("draft tapers a solid face about the body base", "[CadDocument]") { - using namespace Slic3r; // 10x10x10 box from z=0..10 (V=1000). Drafting a vertical side face by +10deg about // the bottom (neutral) plane tilts its top edge inward, removing material so V<1000. @@ -1740,7 +1728,6 @@ TEST_CASE("split by face keep upper only", "[CadDocument][cut]") TEST_CASE("split by face round-trip serialization", "[CadDocument][cut]") { - using Catch::Matchers::WithinRel; using Catch::Matchers::WithinAbs; CadDocument doc; @@ -1808,7 +1795,6 @@ TEST_CASE("split by face round-trip serialization", "[CadDocument][cut]") TEST_CASE("mirror reflects a body about a plane", "[CadDocument]") { using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; auto make_box = [](CadDocument& doc, double w, double h, double d) { int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), w, h, 0, "Box"); @@ -1939,7 +1925,6 @@ TEST_CASE("mirror reflects a body about a plane", "[CadDocument]") TEST_CASE("mirror serialization round-trip", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Box"); @@ -2453,7 +2438,6 @@ TEST_CASE("a v3 recipe is refused with a message naming the version", "[CadDocum TEST_CASE("re-edit: editing a mid-timeline feature rebuilds downstream", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), @@ -2486,7 +2470,6 @@ TEST_CASE("re-edit: editing a mid-timeline feature rebuilds downstream", "[CadDo TEST_CASE("re-edit survives serialize -> deserialize", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), @@ -2519,7 +2502,6 @@ TEST_CASE("re-edit survives serialize -> deserialize", "[CadDocument]") TEST_CASE("re-edit: multi-type timeline replays all downstream features", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), @@ -2994,7 +2976,6 @@ TEST_CASE("datum coordinate system: point_world gives world axes", "[CadDocument TEST_CASE("helix curve: arc length, bounding box, left-handed, conical", "[CadDocument]") { using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; // --- Cylindrical helix r=5, pitch=2, height=10 (5 turns) --- // One turn arc length = sqrt((2*pi*r)^2 + pitch^2) = sqrt((10*pi)^2 + 4). @@ -3386,7 +3367,6 @@ TEST_CASE("transform degenerate axis errors", "[CadDocument]") TEST_CASE("transform moved body participates in later boolean at its new position", "[CadDocument]") { - using Catch::Matchers::WithinAbs; CadDocument doc; // Two boxes that do NOT overlap @@ -3516,7 +3496,6 @@ TEST_CASE("thicken a planar face to a plate", "[CadDocument]") TEST_CASE("thicken flip offsets against face normal", "[CadDocument]") { - using Catch::Matchers::WithinAbs; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "BoxSketch"); @@ -3615,7 +3594,6 @@ TEST_CASE("thicken zero thickness returns error", "[CadDocument]") TEST_CASE("thickened plate fuses with source", "[CadDocument]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Box"); @@ -3649,7 +3627,6 @@ TEST_CASE("thickened plate fuses with source", "[CadDocument]") TEST_CASE("thicken round-trip serialization", "[CadDocument]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Box"); @@ -3833,7 +3810,6 @@ TEST_CASE("project bad face id returns error", "[CadDocument][project]") TEST_CASE("project round-trip serialization", "[CadDocument][project]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 10, "Box"); @@ -4609,8 +4585,6 @@ TEST_CASE("golden recipe v1 still deserialises", "[CadDocument]") TEST_CASE("rib adds material to a box", "[CadDocument][rib]") { - using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; CadDocument doc; @@ -4763,7 +4737,6 @@ TEST_CASE("bridge two collinear lines", "[CadDocument][bridge]") TEST_CASE("bridge closes a C profile and extrudes", "[CadDocument][bridge]") { - using Catch::Matchers::WithinAbs; using Catch::Matchers::WithinRel; CadDocument doc; @@ -4861,8 +4834,6 @@ TEST_CASE("bridge round-trip serialization", "[CadDocument][bridge]") TEST_CASE("delete_face removes a fillet face and restores volume", "[CadDocument][deleteface]") { - using Catch::Matchers::WithinRel; - using Catch::Matchers::WithinAbs; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 10, "Box"); @@ -4912,7 +4883,6 @@ TEST_CASE("delete_face with bad face index fails safely", "[CadDocument][deletef TEST_CASE("delete_face round-trip serialization", "[CadDocument][deleteface]") { - using Catch::Matchers::WithinRel; using Catch::Matchers::WithinAbs; CadDocument doc; @@ -4970,7 +4940,6 @@ TEST_CASE("delete_face round-trip serialization", "[CadDocument][deleteface]") TEST_CASE("hole: counterbore removes more material than a simple bore", "[CadDocument][hole]") { - using Catch::Matchers::WithinAbs; auto make_box_hole = [](int style, double cbore_d, double cbore_depth, double csink_d, double csink_angle, const std::string& desig) { CadDocument doc; @@ -4998,7 +4967,6 @@ TEST_CASE("hole: counterbore removes more material than a simple bore", "[CadDoc TEST_CASE("hole: countersink removes more material than a simple bore", "[CadDocument][hole]") { - using Catch::Matchers::WithinAbs; auto make_box = []() { CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 30, 30, 0, "Box"); @@ -5301,7 +5269,6 @@ TEST_CASE("parametric recipe round-trips through serialize/deserialize", "[CadDo TEST_CASE("surface-extrude makes an open shell", "[CadDocument][surface]") { - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Rect"); @@ -5324,7 +5291,6 @@ TEST_CASE("surface-extrude makes an open shell", "[CadDocument][surface]") TEST_CASE("surface-revolve makes an open shell", "[CadDocument][surface]") { - using Catch::Matchers::WithinRel; CadDocument doc; // A small rectangle offset from the axis: u=10..15, v=0..5. @@ -5395,7 +5361,6 @@ TEST_CASE("surface round-trip serialize/deserialize", "[CadDocument][surface]") TEST_CASE("thicken-surface makes a solid from a sheet", "[CadDocument][surface]") { - using Catch::Matchers::WithinRel; using Catch::Matchers::WithinAbs; CadDocument doc; @@ -5519,7 +5484,6 @@ TEST_CASE("thicken surface fills the corners of a closed-loop wall", "[CadDocume TEST_CASE("surface-offset creates another sheet shifted outward", "[CadDocument][surface]") { - using Catch::Matchers::WithinAbs; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Rect"); @@ -5568,7 +5532,6 @@ TEST_CASE("thicken-surface on non-sheet fails", "[CadDocument][surface]") TEST_CASE("thicken-surface round-trip serialize/deserialize", "[CadDocument][surface]") { using Catch::Matchers::WithinAbs; - using Catch::Matchers::WithinRel; CadDocument doc; int sk = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 20, 20, 0, "Rect"); @@ -5608,7 +5571,6 @@ TEST_CASE("thicken-surface round-trip serialize/deserialize", "[CadDocument][sur TEST_CASE("surface-loft makes an open shell", "[CadDocument][surface]") { - using Catch::Matchers::WithinAbs; CadDocument doc; SketchProfile bot; @@ -6315,7 +6277,6 @@ TEST_CASE("mate conflicts: a broken mate is left to apply_mate", "[CadDocument][ TEST_CASE("ordering: fillet after mate resolves face ids", "[CadDocument][mate]") { - using Catch::Matchers::WithinAbs; CadDocument doc; int sk_a = doc.add_sketch(SketchShape::Rectangle, SketchPlane::XY(), 10, 10, 0, "BoxA"); @@ -7846,7 +7807,6 @@ TEST_CASE("plane_of_face gives a sketchable plane for a planar face only", "[Cad // that asserts a state the code cannot reach is exactly what the contract forbids. TEST_CASE("recompute on a healthy box + fillet leaves no body null and no error (positive contract)", "[CadDocument]") { - using namespace Slic3r; CadDocument doc; SketchProfile sp; sp.points.push_back(Vec2d(0, 0)); @@ -8758,7 +8718,6 @@ TEST_CASE("a body carries its own name, through recompute and the recipe", "[Cad TEST_CASE("deleting a feature remaps the references of every consumer, not just Extrude", "[CadDocument]") { - using namespace Slic3r; const SketchPlane xy = SketchPlane::XY(); // A rectangle 10x10 centred at v = 15, revolved 360 deg about the plane X axis. @@ -9098,7 +9057,6 @@ namespace { // centerline x = 0 from (0,0) to (0,20): the half-profile of a tube, drawn the usual way. Slic3r::CadFeature tube_half_profile() { - using namespace Slic3r; CadFeature sk; sk.type = CadFeatureType::Sketch; sk.plane = SketchPlane::XY(); @@ -9113,7 +9071,6 @@ Slic3r::CadFeature tube_half_profile() TEST_CASE("revolve about a line of the sketch", "[CadDocument][revolve]") { - using namespace Slic3r; SECTION("a construction centerline: the profile sweeps into a tube around it") { CadDocument doc; diff --git a/tests/libslic3r/test_config.cpp b/tests/libslic3r/test_config.cpp index e13070062f..553e94b1c0 100644 --- a/tests/libslic3r/test_config.cpp +++ b/tests/libslic3r/test_config.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include "libslic3r/Config.hpp" #include @@ -32,8 +31,6 @@ #include #include -namespace fs = boost::filesystem; - using namespace Slic3r; SCENARIO("Generic config validation performs as expected.", "[Config]") { diff --git a/tests/libslic3r/test_indexed_triangle_set.cpp b/tests/libslic3r/test_indexed_triangle_set.cpp index c65bf589a8..c6e5007c4b 100644 --- a/tests/libslic3r/test_indexed_triangle_set.cpp +++ b/tests/libslic3r/test_indexed_triangle_set.cpp @@ -19,7 +19,6 @@ using namespace Slic3r; TEST_CASE("Split empty mesh", "[its_split][its]") { - using namespace Slic3r; indexed_triangle_set its; @@ -29,7 +28,6 @@ TEST_CASE("Split empty mesh", "[its_split][its]") { } TEST_CASE("Split simple mesh consisting of one part", "[its_split][its]") { - using namespace Slic3r; auto cube = its_make_cube(10., 10., 10.); @@ -53,7 +51,6 @@ void debug_write_obj(const std::vector &res, const std::st } TEST_CASE("Split two non-watertight mesh", "[its_split][its]") { - using namespace Slic3r; auto cube1 = its_make_cube(10., 10., 10.); cube1.indices.pop_back(); @@ -76,7 +73,6 @@ TEST_CASE("Split two non-watertight mesh", "[its_split][its]") { } TEST_CASE("Split non-manifold mesh", "[its_split][its]") { - using namespace Slic3r; auto cube = its_make_cube(10., 10., 10.), cube_low = cube; @@ -96,7 +92,6 @@ TEST_CASE("Split non-manifold mesh", "[its_split][its]") { } TEST_CASE("Split two watertight meshes", "[its_split][its]") { - using namespace Slic3r; auto sphere1 = its_make_sphere(10., 2 * PI / 200.), sphere2 = sphere1; diff --git a/tests/libslic3r/test_marchingsquares.cpp b/tests/libslic3r/test_marchingsquares.cpp index dd6f5dbd97..55dac1e939 100644 --- a/tests/libslic3r/test_marchingsquares.cpp +++ b/tests/libslic3r/test_marchingsquares.cpp @@ -377,7 +377,6 @@ TEST_CASE("10x10 raster with two rings", "[MarchingSquares]") TEST_CASE("Square with hole in the middle", "[MarchingSquares]") { - using namespace Slic3r; ExPolygons inp = {square_with_hole(50.)}; @@ -434,7 +433,6 @@ TEST_CASE("Square with hole in the middle", "[MarchingSquares]") TEST_CASE("Circle with hole in the middle", "[MarchingSquares]") { - using namespace Slic3r; test_expolys(create_raster({1000, 1000}), circle_with_hole(25.), W1x1, "circle_with_hole"); } diff --git a/tests/libslic3r/test_timeutils.cpp b/tests/libslic3r/test_timeutils.cpp index 213b5e6788..9550740fa8 100644 --- a/tests/libslic3r/test_timeutils.cpp +++ b/tests/libslic3r/test_timeutils.cpp @@ -9,8 +9,6 @@ #include #include -using namespace Slic3r; - static void test_time_fmt(Slic3r::Utils::TimeFormat fmt) { using namespace Slic3r::Utils; time_t t = get_current_time_utc(); diff --git a/tests/libslic3r/test_voronoi.cpp b/tests/libslic3r/test_voronoi.cpp index b512fe38fe..a08b84d3eb 100644 --- a/tests/libslic3r/test_voronoi.cpp +++ b/tests/libslic3r/test_voronoi.cpp @@ -29,10 +29,6 @@ #include #endif -using boost::polygon::voronoi_builder; -using boost::polygon::voronoi_diagram; -using boost::polygon::construct_voronoi; - using namespace Slic3r; using VD = Geometry::VoronoiDiagram; diff --git a/tests/slic3rutils/test_plugin_sort.cpp b/tests/slic3rutils/test_plugin_sort.cpp index 8af2ce3b5b..2db7911436 100644 --- a/tests/slic3rutils/test_plugin_sort.cpp +++ b/tests/slic3rutils/test_plugin_sort.cpp @@ -13,9 +13,6 @@ using Slic3r::GUI::PluginSortKey; using Slic3r::GUI::PluginSortOrder; using Slic3r::GUI::PluginSource; using Slic3r::GUI::PluginStatus; -using Slic3r::GUI::plugin_sort_key_from_string; -using Slic3r::GUI::plugin_sort_order_from_string; -using Slic3r::GUI::sort_plugin_items_for_dialog; namespace { diff --git a/tests/slic3rutils/test_slicing_pipeline_bindings.cpp b/tests/slic3rutils/test_slicing_pipeline_bindings.cpp index bb29f6d607..d05589b552 100644 --- a/tests/slic3rutils/test_slicing_pipeline_bindings.cpp +++ b/tests/slic3rutils/test_slicing_pipeline_bindings.cpp @@ -144,7 +144,6 @@ TEST_CASE("orca.slicing is workflow-only: context exposes raw print/object; view } #include "libslic3r/PrintConfig.hpp" // DynamicPrintConfig for the psGCodePostProcess context -#include #include #include #include "libslic3r/BoundingBox.hpp" @@ -157,7 +156,6 @@ TEST_CASE("orca.slicing is workflow-only: context exposes raw print/object; view // the export path handed in. Exercising the real bindings by calling the Python execute() directly // (not the C++ audit trampoline) keeps this a pure binding-surface test. TEST_CASE("orca.slicing psGCodePostProcess context: file edit in place + config fallback", "[slicing_pipeline]") { - namespace fs = boost::filesystem; ensure_python_initialized(); import_orca_module(); py::gil_scoped_acquire gil; @@ -237,7 +235,6 @@ struct TestLayerRegion : Slic3r::LayerRegion { // decomposition of an ExtrusionLoop into its contained ExtrusionPath (flatten() // does NOT decompose loops, hence the hand-rolled recursive walk). static void build_nested_perimeters(TestLayerRegion& region) { - using namespace Slic3r; ExtrusionPath pathA(erExternalPerimeter); // -> "Outer wall" pathA.mm3_per_mm = 0.05; pathA.width = 0.45f; pathA.height = 0.20f; pathA.polyline.points = { Point3(0, 0, 0), Point3(10, 0, 0), Point3(10, 10, 0) }; @@ -434,7 +431,6 @@ namespace { // Nested collection: outer -> inner -> [ ExtrusionLoop(pathA), ExtrusionPath(pathB) ]. // Exercises polymorphic downcast of .entities and loop decomposition in flatten_paths(). static Slic3r::ExtrusionEntityCollection build_nested_collection() { - using namespace Slic3r; ExtrusionPath pathA(erExternalPerimeter); // -> "Outer wall" pathA.mm3_per_mm = 0.05; pathA.width = 0.45f; pathA.height = 0.20f; pathA.polyline.points = { Point3(0, 0, 0), Point3(10, 0, 0), Point3(10, 10, 0) }; From f02292f1637dd645eadb3afd8317c01391480d7a Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:22:45 +0800 Subject: [PATCH 10/22] Stop Exporting Names Through Usings in GUI and Voronoi Headers (#16223) Each of these headers put a using or namespace alias at global or namespace scope, which every includer inherited: - BBLTopbar.hpp: "using namespace Slic3r::GUI;" at global scope, reached through MainFrame.hpp. Seven source files used GUI names unqualified outside the namespace because of it, one of them as "::RadioBox". - IMSlider.hpp and TickCode.hpp: "using namespace CustomGCode;" inside Slic3r. - ProjectTask.hpp, Jobs/PrintJob.hpp and ConfigWizard_private.hpp: "namespace fs = boost::filesystem;". PresetBundle.cpp and GUI_App.cpp had no alias of their own. - VoronoiUtils.hpp: "using VD = Slic3r::Geometry::VoronoiDiagram;" at global scope. The headers now spell the names out. Source files that used them get the qualifier, or a using of their own where there are many uses. --- src/libslic3r/Geometry/Voronoi.cpp | 1 + src/libslic3r/Geometry/VoronoiUtils.cpp | 1 + src/libslic3r/Geometry/VoronoiUtils.hpp | 30 ++++++++++----------- src/libslic3r/MultiMaterialSegmentation.cpp | 1 + src/libslic3r/PresetBundle.cpp | 2 ++ src/libslic3r/ProjectTask.hpp | 6 ++--- src/slic3r/GUI/BBLTopbar.cpp | 1 + src/slic3r/GUI/BBLTopbar.hpp | 2 -- src/slic3r/GUI/BackgroundSlicingProcess.cpp | 4 +-- src/slic3r/GUI/ConfigWizard_private.hpp | 4 +-- src/slic3r/GUI/GCodeViewer.cpp | 10 +++---- src/slic3r/GUI/GLCanvas3D.cpp | 4 +-- src/slic3r/GUI/GUI_App.cpp | 1 + src/slic3r/GUI/GUI_Preview.cpp | 2 +- src/slic3r/GUI/IMSlider.cpp | 2 ++ src/slic3r/GUI/IMSlider.hpp | 25 +++++++++-------- src/slic3r/GUI/Jobs/PrintJob.hpp | 8 +++--- src/slic3r/GUI/Plater.cpp | 6 ++--- src/slic3r/GUI/PresetComboBoxes.cpp | 2 +- src/slic3r/GUI/PrintHostDialogs.cpp | 4 +-- src/slic3r/GUI/TickCode.cpp | 3 +++ src/slic3r/GUI/TickCode.hpp | 17 ++++++------ src/slic3r/Utils/SimplyPrint.cpp | 2 +- src/slic3r/plugin/host/PluginHostUi.cpp | 24 ++++++++--------- 24 files changed, 81 insertions(+), 81 deletions(-) diff --git a/src/libslic3r/Geometry/Voronoi.cpp b/src/libslic3r/Geometry/Voronoi.cpp index 7d59e2d2b8..31f9f974a7 100644 --- a/src/libslic3r/Geometry/Voronoi.cpp +++ b/src/libslic3r/Geometry/Voronoi.cpp @@ -16,6 +16,7 @@ namespace Slic3r::Geometry { +using VD = VoronoiDiagram; using PolygonsSegmentIndexConstIt = std::vector::const_iterator; using LinesIt = Lines::iterator; using ColoredLinesConstIt = ColoredLines::const_iterator; diff --git a/src/libslic3r/Geometry/VoronoiUtils.cpp b/src/libslic3r/Geometry/VoronoiUtils.cpp index d0ad07cc7e..305e9128ef 100644 --- a/src/libslic3r/Geometry/VoronoiUtils.cpp +++ b/src/libslic3r/Geometry/VoronoiUtils.cpp @@ -20,6 +20,7 @@ namespace Slic3r::Geometry { +using VD = VoronoiDiagram; using PolygonsSegmentIndexConstIt = std::vector::const_iterator; using LinesIt = Lines::iterator; using ColoredLinesIt = ColoredLines::iterator; diff --git a/src/libslic3r/Geometry/VoronoiUtils.hpp b/src/libslic3r/Geometry/VoronoiUtils.hpp index d9b15fd839..13c2492bf9 100644 --- a/src/libslic3r/Geometry/VoronoiUtils.hpp +++ b/src/libslic3r/Geometry/VoronoiUtils.hpp @@ -10,8 +10,6 @@ #include "libslic3r/Point.hpp" #include "libslic3r/libslic3r.h" -using VD = Slic3r::Geometry::VoronoiDiagram; - namespace Slic3r::Geometry { // Represent trapezoid Voronoi cell around segment. @@ -19,8 +17,8 @@ template struct SegmentCellRange { const PT source_segment_start_point; // The start point of the source segment of this cell. const PT source_segment_end_point; // The end point of the source segment of this cell. - const VD::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. - const VD::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. + const VoronoiDiagram::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. + const VoronoiDiagram::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. SegmentCellRange() = delete; explicit SegmentCellRange(const PT &source_segment_start_point, const PT &source_segment_end_point) @@ -34,8 +32,8 @@ template struct SegmentCellRange template struct PointCellRange { const PT source_point; // The source point of this cell. - const VD::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. - const VD::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. + const VoronoiDiagram::edge_type *edge_begin = nullptr; // The edge of the Voronoi diagram where the loop around the cell starts. + const VoronoiDiagram::edge_type *edge_end = nullptr; // The edge of the Voronoi diagram where the loop around the cell ends. PointCellRange() = delete; explicit PointCellRange(const PT &source_point) : source_point(source_point) {} @@ -46,20 +44,20 @@ template struct PointCellRange class VoronoiUtils { public: - static Vec2i64 to_point(const VD::vertex_type *vertex); + static Vec2i64 to_point(const VoronoiDiagram::vertex_type *vertex); - static Vec2i64 to_point(const VD::vertex_type &vertex); + static Vec2i64 to_point(const VoronoiDiagram::vertex_type &vertex); - static bool is_finite(const VD::vertex_type &vertex); + static bool is_finite(const VoronoiDiagram::vertex_type &vertex); - static VD::vertex_type make_rotated_vertex(VD::vertex_type &vertex, double angle); + static VoronoiDiagram::vertex_type make_rotated_vertex(VoronoiDiagram::vertex_type &vertex, double angle); template static typename boost::polygon::enable_if< typename boost::polygon::gtl_if::value_type>::type>::type>::type, typename std::iterator_traits::reference>::type - get_source_segment(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + get_source_segment(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); template static typename boost::polygon::enable_if< @@ -73,7 +71,7 @@ public: typename boost::polygon::gtl_if::value_type>::type>::type>::type, Arachne::PolygonsPointIndex>::type - get_source_point_index(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + get_source_point_index(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); /** * Discretize a parabola based on (approximate) step size. @@ -113,7 +111,7 @@ public: typename boost::polygon::geometry_concept::value_type>::type>::type>::type, Geometry::SegmentCellRange< typename boost::polygon::segment_point_type::value_type>::type>>::type - compute_segment_cell_range(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + compute_segment_cell_range(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); /** * Compute the range of line segments that surround a cell of the skeletal @@ -140,19 +138,19 @@ public: typename boost::polygon::geometry_concept::value_type>::type>::type>::type, Geometry::PointCellRange< typename boost::polygon::segment_point_type::value_type>::type>>::type - compute_point_cell_range(const VD::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); + compute_point_cell_range(const VoronoiDiagram::cell_type &cell, SegmentIterator segment_begin, SegmentIterator segment_end); template static bool is_in_range(double value) { return double(std::numeric_limits::lowest()) <= value && value <= double(std::numeric_limits::max()); } - template static bool is_in_range(const VD::vertex_type &vertex) + template static bool is_in_range(const VoronoiDiagram::vertex_type &vertex) { return VoronoiUtils::is_finite(vertex) && is_in_range(vertex.x()) && is_in_range(vertex.y()); } - template static bool is_in_range(const VD::edge_type &edge) + template static bool is_in_range(const VoronoiDiagram::edge_type &edge) { if (edge.vertex0() == nullptr || edge.vertex1() == nullptr) return false; diff --git a/src/libslic3r/MultiMaterialSegmentation.cpp b/src/libslic3r/MultiMaterialSegmentation.cpp index b7dfd6a160..d2f76e7e66 100644 --- a/src/libslic3r/MultiMaterialSegmentation.cpp +++ b/src/libslic3r/MultiMaterialSegmentation.cpp @@ -63,6 +63,7 @@ namespace Slic3r { enum class EnforcerBlockerType : int8_t; } namespace Slic3r { using boost::polygon::voronoi_diagram; +using VD = Geometry::VoronoiDiagram; static inline Point mk_point(const Voronoi::VD::vertex_type *point) { return {coord_t(point->x()), coord_t(point->y())}; } diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 7e679adf21..b1fad347f1 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -80,6 +80,8 @@ #include #include +namespace fs = boost::filesystem; + // Mark string for localization and translate. #define L(s) Slic3r::I18N::translate(s) diff --git a/src/libslic3r/ProjectTask.hpp b/src/libslic3r/ProjectTask.hpp index 47eaa37dcc..64c4ddc447 100644 --- a/src/libslic3r/ProjectTask.hpp +++ b/src/libslic3r/ProjectTask.hpp @@ -11,8 +11,6 @@ #include #include -namespace fs = boost::filesystem; - namespace Slic3r { class BBLProject; @@ -208,7 +206,7 @@ public: std::string task_profile_id; /* profile id*/ std::string task_name; /* task name, generally filename as task name */ std::string task_file; /* local full file path of 3mf or gcode */ - fs::path task_path; /* local path of 3mf or gcode */ + boost::filesystem::path task_path; /* local path of 3mf or gcode */ std::string task_gcode_in_3mf; /* gcode in 3mf */ std::string task_create_time; /* time created by cloud */ std::string task_thumbnail_url; /* url of task thumbnail */ @@ -326,7 +324,7 @@ public: std::string project_url_md5; /* md5 of project url file */ std::string project_name; std::string project_3mf_file; - fs::path project_path; + boost::filesystem::path project_path; std::string project_content; std::string project_country_code; diff --git a/src/slic3r/GUI/BBLTopbar.cpp b/src/slic3r/GUI/BBLTopbar.cpp index 40f6457ae4..eb85b9413b 100644 --- a/src/slic3r/GUI/BBLTopbar.cpp +++ b/src/slic3r/GUI/BBLTopbar.cpp @@ -41,6 +41,7 @@ #define TOPBAR_TITLE_WIDTH 300 using namespace Slic3r; +using namespace Slic3r::GUI; enum CUSTOM_ID { diff --git a/src/slic3r/GUI/BBLTopbar.hpp b/src/slic3r/GUI/BBLTopbar.hpp index 3d71a56e4c..bad0727452 100644 --- a/src/slic3r/GUI/BBLTopbar.hpp +++ b/src/slic3r/GUI/BBLTopbar.hpp @@ -18,8 +18,6 @@ class wxMouseCaptureLostEvent; class wxMouseEvent; class wxWindow; -using namespace Slic3r::GUI; - class CenteredTitle : public wxControl { public: diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index e9417782db..50c69f40dc 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -218,7 +218,7 @@ std::string BackgroundSlicingProcess::output_filepath_for_project(const boost::f void BackgroundSlicingProcess::process_fff() { assert(m_print == m_fff_print); - PresetBundle& preset_bundle = *wxGetApp().preset_bundle; + PresetBundle& preset_bundle = *GUI::wxGetApp().preset_bundle; m_fff_print->is_BBL_printer() = preset_bundle.is_bbl_vendor(); // BBS: add the logic to process from an existed gcode file if (m_print->finished()) { @@ -727,7 +727,7 @@ StringObjectException BackgroundSlicingProcess::validate(std::vectoris_BBL_printer() = wxGetApp().preset_bundle->is_bbl_vendor(); + m_fff_print->is_BBL_printer() = GUI::wxGetApp().preset_bundle->is_bbl_vendor(); return m_print->validate(warnings, collison_polygons, height_polygons); } diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index a1f9b61b00..5f7720ab84 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -43,8 +43,6 @@ #include -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { @@ -88,7 +86,7 @@ struct Bundle // cache or its profile JSONs, whichever is usable. // Returns false if not loaded. Reason for that is logged as boost::log error. //BBS: set BBL as default - bool load(fs::path dir, const std::string &vendor_name, bool is_in_resources, bool is_bbl_bundle = false); + bool load(boost::filesystem::path dir, const std::string &vendor_name, bool is_in_resources, bool is_bbl_bundle = false); const std::string& vendor_id() const { return vendor_profile->id; } }; diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 9c6c200050..4727ed0871 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -3622,7 +3622,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv if (extruder_id + 1 != static_cast(item.extruder)) continue; - if (item.type != ColorChange) + if (item.type != CustomGCode::ColorChange) continue; if (!zs_built) { @@ -4789,10 +4789,10 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv ImGui::SameLine(); switch (custom_gcode.type) { - case PausePrint: imgui.text(cgcode_pause_str); break; - case Template: imgui.text(cgcode_template_str); break; - case ToolChange: imgui.text(cgcode_toolchange_str); break; - case Custom: imgui.text(cgcode_custom_str); break; + case CustomGCode::PausePrint: imgui.text(cgcode_pause_str); break; + case CustomGCode::Template: imgui.text(cgcode_template_str); break; + case CustomGCode::ToolChange: imgui.text(cgcode_toolchange_str); break; + case CustomGCode::Custom: imgui.text(cgcode_custom_str); break; default: imgui.text(cgcode_unknown_str); break; } ImGui::SameLine(max_len); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index d8e0e97212..4f6c54fac5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -184,12 +184,12 @@ static Slic3r::ColorRGBA DEFAULT_BG_LIGHT_COLOR_DARK = { 0.329f, 0.329f, 0.353f, static Slic3r::ColorRGBA ERROR_BG_LIGHT_COLOR = { 0.753f, 0.192f, 0.039f, 1.0f }; static Slic3r::ColorRGBA ERROR_BG_LIGHT_COLOR_DARK = { 0.753f, 0.192f, 0.039f, 1.0f }; -void GLCanvas3D::update_render_colors() +void Slic3r::GUI::GLCanvas3D::update_render_colors() { DEFAULT_BG_LIGHT_COLOR = ImGuiWrapper::from_ImVec4(RenderColor::colors[RenderCol_3D_Background]); } -void GLCanvas3D::load_render_colors() +void Slic3r::GUI::GLCanvas3D::load_render_colors() { RenderColor::colors[RenderCol_3D_Background] = ImGuiWrapper::to_ImVec4(DEFAULT_BG_LIGHT_COLOR); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 705c489863..499ac6f23d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -309,6 +309,7 @@ typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS2)( #include #endif +namespace fs = boost::filesystem; using namespace std::literals; namespace pt = boost::property_tree; using json = nlohmann::json; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 1968df996f..fd477cf767 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -396,7 +396,7 @@ void Preview::sys_color_changed() // m_layers_slider->sys_color_changed(); } -void Preview::on_tick_changed(Type type) +void Preview::on_tick_changed(CustomGCode::Type type) { //if (type == Type::PausePrint) { // m_schedule_background_process(); diff --git a/src/slic3r/GUI/IMSlider.cpp b/src/slic3r/GUI/IMSlider.cpp index c031705f14..eab44adf76 100644 --- a/src/slic3r/GUI/IMSlider.cpp +++ b/src/slic3r/GUI/IMSlider.cpp @@ -46,6 +46,8 @@ namespace Slic3r { +using namespace CustomGCode; + namespace GUI { // equal to 25 mm2 diff --git a/src/slic3r/GUI/IMSlider.hpp b/src/slic3r/GUI/IMSlider.hpp index 9df84a7a75..4f02167669 100644 --- a/src/slic3r/GUI/IMSlider.hpp +++ b/src/slic3r/GUI/IMSlider.hpp @@ -20,7 +20,6 @@ struct IMGUI_API ImRect; namespace Slic3r { -using namespace CustomGCode; class PrintObject; class Layer; @@ -89,8 +88,8 @@ public: void SetSliderValues(const std::vector &values); void SetSliderAlternateValues(const std::vector &values) { m_alternate_values = values; } - Info GetTicksValues() const; - void SetTicksValues(const Info &custom_gcode_per_print_z); + CustomGCode::Info GetTicksValues() const; + void SetTicksValues(const CustomGCode::Info &custom_gcode_per_print_z); void SetLayersTimes(const std::vector &layers_times, float total_time); void SetLayersTimes(const std::vector &layers_times); @@ -98,8 +97,8 @@ public: void SetDrawMode(DrawMode mode) { m_draw_mode = mode; } //BBS void SetExtraStyle(long style) { m_extra_style = style; } - void SetManipulationMode(Mode mode) { m_mode = mode; } - Mode GetManipulationMode() const { return m_mode; } + void SetManipulationMode(CustomGCode::Mode mode) { m_mode = mode; } + CustomGCode::Mode GetManipulationMode() const { return m_mode; } void SetModeAndOnlyExtruder(const bool is_one_extruder_printed_model, const int only_extruder, bool can_change_color); void SetExtruderColors(const std::vector &extruder_colors); @@ -117,8 +116,8 @@ public: void UseDefaultColors(bool def_colors_on) { m_ticks.set_default_colors(def_colors_on); } void on_mouse_wheel(wxMouseEvent& evt); - void post_ticks_changed_event(Type type = Unknown); - bool check_ticks_changed_event(Type type); + void post_ticks_changed_event(CustomGCode::Type type = CustomGCode::Unknown); + bool check_ticks_changed_event(CustomGCode::Type type); bool switch_one_layer_mode(); void show_go_to_layer(bool show) { m_show_go_to_layer_dialog = show; } @@ -130,9 +129,9 @@ public: bool is_need_post_tick_event() { return m_is_need_post_tick_changed_event; } void reset_post_tick_event(bool val = false) { m_is_need_post_tick_changed_event = val; - m_tick_change_event_type = Type::Unknown; + m_tick_change_event_type = CustomGCode::Type::Unknown; } - Type get_post_tick_event_type() { return m_tick_change_event_type; } + CustomGCode::Type get_post_tick_event_type() { return m_tick_change_event_type; } float m_scale = 1.0; void set_scale(float scale = 1.0); @@ -143,7 +142,7 @@ public: protected: void add_custom_gcode(std::string custom_gcode); - void add_code_as_tick(Type type, int selected_extruder = -1); + void add_code_as_tick(CustomGCode::Type type, int selected_extruder = -1); void delete_tick(const TickCode& tick); void do_go_to_layer(size_t layer_number); //menu void correct_lower_value(); @@ -156,7 +155,7 @@ protected: void render_edit_menu(const TickCode& tick); //menu void draw_background_and_groove(const ImRect& bg_rect, const ImRect& groove); void draw_colored_band(const ImRect& groove, const ImRect& slideable_region); - void draw_custom_label_block(const ImVec2 anchor, Type type); + void draw_custom_label_block(const ImVec2 anchor, CustomGCode::Type type); void draw_ticks(const ImRect& slideable_region); void draw_tick_on_mouse_position(const ImRect& slideable_region); void show_tooltip(const TickCode& tick); //menu @@ -217,7 +216,7 @@ private: void *m_delete_icon_id; DrawMode m_draw_mode = dmRegular; - Mode m_mode = SingleExtruder; + CustomGCode::Mode m_mode = CustomGCode::SingleExtruder; int m_only_extruder = -1; long m_style; @@ -232,7 +231,7 @@ private: bool m_can_change_color; std::string m_print_obj_idxs; bool m_is_need_post_tick_changed_event { false }; - Type m_tick_change_event_type; + CustomGCode::Type m_tick_change_event_type; std::vector m_alternate_values; diff --git a/src/slic3r/GUI/Jobs/PrintJob.hpp b/src/slic3r/GUI/Jobs/PrintJob.hpp index 4207824471..150635cfb1 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.hpp +++ b/src/slic3r/GUI/Jobs/PrintJob.hpp @@ -12,8 +12,6 @@ #include "Job.hpp" #include "slic3r/GUI/DeviceCore/DevStorage.h" -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { @@ -26,9 +24,9 @@ class PrintPrepareData public: bool is_from_plater = true; int plate_idx; - fs::path _3mf_path; - fs::path _3mf_config_path; - fs::path _temp_path; + boost::filesystem::path _3mf_path; + boost::filesystem::path _3mf_config_path; + boost::filesystem::path _temp_path; PrintPrepareData() { plate_idx = 0; } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 08dad219b0..707bed30b1 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -8107,13 +8107,13 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_COLLAPSE_SIDEBAR, [this](SimpleEvent&) { this->q->collapse_sidebar(!this->q->is_sidebar_collapsed()); }); preview->get_wxglcanvas()->Bind(EVT_CUSTOMEVT_TICKSCHANGED, [this](wxCommandEvent& event) { - Type tick_event_type = (Type)event.GetInt(); + CustomGCode::Type tick_event_type = (CustomGCode::Type)event.GetInt(); Model& model = wxGetApp().plater()->model(); //BBS: replace model custom gcode with current plate custom gcode model.plates_custom_gcodes[model.curr_plate_index] = preview->get_canvas3d()->get_gcode_viewer().get_layers_slider()->GetTicksValues(); // BBS set to invalid state only - if (tick_event_type == Type::ToolChange || tick_event_type == Type::Custom || tick_event_type == Type::Template || tick_event_type == Type::PausePrint) { + if (tick_event_type == CustomGCode::Type::ToolChange || tick_event_type == CustomGCode::Type::Custom || tick_event_type == CustomGCode::Type::Template || tick_event_type == CustomGCode::Type::PausePrint) { PartPlate *plate = this->q->get_partplate_list().get_curr_plate(); if (plate) { plate->update_slice_result_valid_state(false); @@ -20540,7 +20540,7 @@ void Plater::on_filaments_delete(size_t num_filaments, size_t filament_id, int r // update customize gcode for (auto item = p->model.plates_custom_gcodes.begin(); item != p->model.plates_custom_gcodes.end(); ++item) { - auto iter = std::remove_if(item->second.gcodes.begin(), item->second.gcodes.end(), [filament_id](const Item& gcode_item) { + auto iter = std::remove_if(item->second.gcodes.begin(), item->second.gcodes.end(), [filament_id](const CustomGCode::Item& gcode_item) { return (gcode_item.type == CustomGCode::Type::ToolChange && gcode_item.extruder == filament_id + 1); }); if (replace_filament_id == -1) diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index d1e4d6126a..9611e7ec5c 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -2175,7 +2175,7 @@ void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt) wxPostEvent(m_parent, e); } -void PlaterPresetComboBox::sys_color_changed() +void GUI::PlaterPresetComboBox::sys_color_changed() { PresetComboBox::sys_color_changed(); if (clr_picker) { diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index ee7d14552c..2e8047cf72 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -1752,8 +1752,8 @@ void ElegooPrintHostSendDialog::init() { } { - auto radioBoxA = new ::RadioBox(this); - auto radioBoxB = new ::RadioBox(this); + auto radioBoxA = new RadioBox(this); + auto radioBoxB = new RadioBox(this); if (m_BedType == BedType::btPC) radioBoxB->SetValue(true); else diff --git a/src/slic3r/GUI/TickCode.cpp b/src/slic3r/GUI/TickCode.cpp index 92997095b6..c8ad170862 100644 --- a/src/slic3r/GUI/TickCode.cpp +++ b/src/slic3r/GUI/TickCode.cpp @@ -6,6 +6,9 @@ #include namespace Slic3r { + +using namespace CustomGCode; + namespace GUI { std::string TickCodeInfo::get_color_for_tick(TickCode tick, Type type, const int extruder) { diff --git a/src/slic3r/GUI/TickCode.hpp b/src/slic3r/GUI/TickCode.hpp index e8cb848d76..e75ecc7a22 100644 --- a/src/slic3r/GUI/TickCode.hpp +++ b/src/slic3r/GUI/TickCode.hpp @@ -7,7 +7,6 @@ #include namespace Slic3r { -using namespace CustomGCode; namespace GUI { struct TickCode @@ -16,7 +15,7 @@ struct TickCode bool operator>(const TickCode& other) const { return other.tick < this->tick; } int tick = 0; - Type type = ColorChange; + CustomGCode::Type type = CustomGCode::ColorChange; int extruder = 0; std::string color; std::string extra; @@ -31,22 +30,22 @@ class TickCodeInfo std::vector* m_colors{ nullptr };// reference to IMSlider::m_extruder_colors - std::string get_color_for_tick(TickCode tick, Type type, const int extruder); + std::string get_color_for_tick(TickCode tick, CustomGCode::Type type, const int extruder); public: std::set ticks{}; - Mode mode = Undef; + CustomGCode::Mode mode = CustomGCode::Undef; bool empty() const { return ticks.empty(); } void set_pause_print_msg(const std::string& message) { pause_print_msg = message; } - bool add_tick(const int tick, Type type, int extruder, double print_z); + bool add_tick(const int tick, CustomGCode::Type type, int extruder, double print_z); bool edit_tick(std::set::iterator it, double print_z); - void switch_code(Type type_from, Type type_to); - bool switch_code_for_tick(std::set::iterator it, Type type_to, const int extruder); - void erase_all_ticks_with_code(Type type); + void switch_code(CustomGCode::Type type_from, CustomGCode::Type type_to); + bool switch_code_for_tick(std::set::iterator it, CustomGCode::Type type_to, const int extruder); + void erase_all_ticks_with_code(CustomGCode::Type type); - bool has_tick_with_code(Type type); + bool has_tick_with_code(CustomGCode::Type type); bool has_tick(int tick); void suppress_plus(bool suppress) { m_suppress_plus = suppress; } diff --git a/src/slic3r/Utils/SimplyPrint.cpp b/src/slic3r/Utils/SimplyPrint.cpp index 5c68878986..ff6860a244 100644 --- a/src/slic3r/Utils/SimplyPrint.cpp +++ b/src/slic3r/Utils/SimplyPrint.cpp @@ -115,7 +115,7 @@ static void set_auth(Http& http, const std::string& access_token) { http.header( static bool should_open_in_external_browser() { - const auto& app = wxGetApp(); + const auto& app = GUI::wxGetApp(); if (app.preset_bundle->use_bbl_device_tab()) { // When using bbl device tab, we always need to open external browser diff --git a/src/slic3r/plugin/host/PluginHostUi.cpp b/src/slic3r/plugin/host/PluginHostUi.cpp index 54de1df0d6..46d46b402f 100644 --- a/src/slic3r/plugin/host/PluginHostUi.cpp +++ b/src/slic3r/plugin/host/PluginHostUi.cpp @@ -565,7 +565,7 @@ void progress_close(int id) }); } -void plater_notification(NotificationManager::NotificationLevel notification_level, const std::string& text, +void plater_notification(GUI::NotificationManager::NotificationLevel notification_level, const std::string& text, const std::string& hypertext, py::object on_click) { const std::string plugin_key = PluginAuditManager::instance().current_plugin(); @@ -600,7 +600,7 @@ void plater_notification(NotificationManager::NotificationLevel notification_lev } run_on_ui_blocking([notification_level, text, hypertext, callback = std::move(callback)]() mutable { - wxGetApp().plater()->get_notification_manager()->push_notification(NotificationType::CustomNotification, notification_level, text, + GUI::wxGetApp().plater()->get_notification_manager()->push_notification(GUI::NotificationType::CustomNotification, notification_level, text, hypertext, std::move(callback)); }); } @@ -713,16 +713,16 @@ void PluginHostUi::RegisterBindings(pybind11::module_& host) py::arg("maximum") = 100, py::arg("style") = wxPD_APP_MODAL | wxPD_AUTO_HIDE, "Create a native progress dialog and return a ProgressDialog handle."); - py::enum_(ui, "NotificationLevel") - .value("ProgressBarNotificationLevel", NotificationManager::NotificationLevel::ProgressBarNotificationLevel) - .value("HintNotificationLevel", NotificationManager::NotificationLevel::HintNotificationLevel) - .value("RegularNotificationLevel", NotificationManager::NotificationLevel::RegularNotificationLevel) - .value("PrintInfoNotificationLevel", NotificationManager::NotificationLevel::PrintInfoNotificationLevel) - .value("PrintInfoShortNotificationLevel", NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel) - .value("ImportantNotificationLevel", NotificationManager::NotificationLevel::ImportantNotificationLevel) - .value("WarningNotificationLevel", NotificationManager::NotificationLevel::WarningNotificationLevel) - .value("SeriousWarningNotificationLevel", NotificationManager::NotificationLevel::SeriousWarningNotificationLevel) - .value("ErrorNotificationLevel", NotificationManager::NotificationLevel::ErrorNotificationLevel) + py::enum_(ui, "NotificationLevel") + .value("ProgressBarNotificationLevel", GUI::NotificationManager::NotificationLevel::ProgressBarNotificationLevel) + .value("HintNotificationLevel", GUI::NotificationManager::NotificationLevel::HintNotificationLevel) + .value("RegularNotificationLevel", GUI::NotificationManager::NotificationLevel::RegularNotificationLevel) + .value("PrintInfoNotificationLevel", GUI::NotificationManager::NotificationLevel::PrintInfoNotificationLevel) + .value("PrintInfoShortNotificationLevel", GUI::NotificationManager::NotificationLevel::PrintInfoShortNotificationLevel) + .value("ImportantNotificationLevel", GUI::NotificationManager::NotificationLevel::ImportantNotificationLevel) + .value("WarningNotificationLevel", GUI::NotificationManager::NotificationLevel::WarningNotificationLevel) + .value("SeriousWarningNotificationLevel", GUI::NotificationManager::NotificationLevel::SeriousWarningNotificationLevel) + .value("ErrorNotificationLevel", GUI::NotificationManager::NotificationLevel::ErrorNotificationLevel) .export_values(); ui.def("push_notification", &plater_notification, py::arg("notification_level"), py::arg("text"), From de6b0b9f2de6a6d190d41a408c262e01539a8cd8 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:23:00 +0800 Subject: [PATCH 11/22] Remove Header Usings and Aliases Nothing Depends On (#16224) - ClipperUtils.hpp imported jtMiter, jtRound and jtSquare into the global namespace for every includer. No code names them there. - BBLStatusBar.hpp, BBLStatusBarBind.hpp, BBLStatusBarPrint.hpp, BBLStatusBarSend.hpp and ProgressStatusBar.hpp re-exported their class into Slic3r::GUI. Nothing refers to the class through that namespace. - Jobs/SendJob.hpp, Jobs/BindJob.hpp, Jobs/UpgradeNetworkJob.hpp and AuxiliaryDataViewModel.hpp declared "namespace fs = boost::filesystem;" at global scope without using it. --- src/libslic3r/ClipperUtils.hpp | 5 ----- src/slic3r/GUI/AuxiliaryDataViewModel.hpp | 2 -- src/slic3r/GUI/BBLStatusBar.hpp | 4 ---- src/slic3r/GUI/BBLStatusBarBind.hpp | 4 ---- src/slic3r/GUI/BBLStatusBarPrint.hpp | 4 ---- src/slic3r/GUI/BBLStatusBarSend.hpp | 4 ---- src/slic3r/GUI/Jobs/BindJob.hpp | 2 -- src/slic3r/GUI/Jobs/SendJob.hpp | 2 -- src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp | 2 -- src/slic3r/GUI/ProgressStatusBar.hpp | 4 ---- 10 files changed, 33 deletions(-) diff --git a/src/libslic3r/ClipperUtils.hpp b/src/libslic3r/ClipperUtils.hpp index 00cf60076b..26585a1fef 100644 --- a/src/libslic3r/ClipperUtils.hpp +++ b/src/libslic3r/ClipperUtils.hpp @@ -23,11 +23,6 @@ enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor }; } // namespace Slic3r -// import these wherever we're included -using Slic3r::jtMiter; -using Slic3r::jtRound; -using Slic3r::jtSquare; - namespace Slic3r { static constexpr const float ClipperSafetyOffset = 10.f; diff --git a/src/slic3r/GUI/AuxiliaryDataViewModel.hpp b/src/slic3r/GUI/AuxiliaryDataViewModel.hpp index 026f22421b..c26988e9bb 100644 --- a/src/slic3r/GUI/AuxiliaryDataViewModel.hpp +++ b/src/slic3r/GUI/AuxiliaryDataViewModel.hpp @@ -18,8 +18,6 @@ class AuxiliaryModelNode; WX_DEFINE_ARRAY_PTR(AuxiliaryModelNode*, AuxiliaryModelNodePtrArray); -namespace fs = boost::filesystem; - class AuxiliaryModelNode { public: diff --git a/src/slic3r/GUI/BBLStatusBar.hpp b/src/slic3r/GUI/BBLStatusBar.hpp index e643a9b536..1ff2fd6f0f 100644 --- a/src/slic3r/GUI/BBLStatusBar.hpp +++ b/src/slic3r/GUI/BBLStatusBar.hpp @@ -73,10 +73,6 @@ private: CancelFn m_cancel_cb; }; -namespace GUI { - using Slic3r::BBLStatusBar; -} - } #endif // BBLSTATUSBAR_HPP diff --git a/src/slic3r/GUI/BBLStatusBarBind.hpp b/src/slic3r/GUI/BBLStatusBarBind.hpp index dd647aa26c..b1b06b60b6 100644 --- a/src/slic3r/GUI/BBLStatusBarBind.hpp +++ b/src/slic3r/GUI/BBLStatusBarBind.hpp @@ -80,10 +80,6 @@ private: CancelFn m_cancel_cb_fina; }; -namespace GUI { -using Slic3r::BBLStatusBarBind; -} - } // namespace Slic3r #endif // BBLSTATUSBAR_HPP diff --git a/src/slic3r/GUI/BBLStatusBarPrint.hpp b/src/slic3r/GUI/BBLStatusBarPrint.hpp index 0622516791..bc82d80068 100644 --- a/src/slic3r/GUI/BBLStatusBarPrint.hpp +++ b/src/slic3r/GUI/BBLStatusBarPrint.hpp @@ -97,10 +97,6 @@ private: CancelFn m_cancel_cb_fina; }; -namespace GUI { -using Slic3r::BBLStatusBarPrint; -} - wxDECLARE_EVENT(EVT_SHOW_ERROR_INFO, wxCommandEvent); } // namespace Slic3r diff --git a/src/slic3r/GUI/BBLStatusBarSend.hpp b/src/slic3r/GUI/BBLStatusBarSend.hpp index abe4bece3b..1c4b267c6f 100644 --- a/src/slic3r/GUI/BBLStatusBarSend.hpp +++ b/src/slic3r/GUI/BBLStatusBarSend.hpp @@ -99,10 +99,6 @@ private: CancelFn m_cancel_cb_fina; }; -namespace GUI { -using Slic3r::BBLStatusBarSend; -} - wxDECLARE_EVENT(EVT_SHOW_ERROR_INFO_SEND, wxCommandEvent); wxDECLARE_EVENT(EVT_SHOW_ERROR_FAIL_SEND, wxCommandEvent); } // namespace Slic3r diff --git a/src/slic3r/GUI/Jobs/BindJob.hpp b/src/slic3r/GUI/Jobs/BindJob.hpp index 06de566e52..f2a8cbe1c4 100644 --- a/src/slic3r/GUI/Jobs/BindJob.hpp +++ b/src/slic3r/GUI/Jobs/BindJob.hpp @@ -11,8 +11,6 @@ class wxWindow; -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Jobs/SendJob.hpp b/src/slic3r/GUI/Jobs/SendJob.hpp index c77efe69bb..3d96a3a6dd 100644 --- a/src/slic3r/GUI/Jobs/SendJob.hpp +++ b/src/slic3r/GUI/Jobs/SendJob.hpp @@ -11,8 +11,6 @@ #include "Job.hpp" #include "PrintJob.hpp" -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp b/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp index 77a1e9544d..1b0892d0eb 100644 --- a/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp +++ b/src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp @@ -12,8 +12,6 @@ class wxWindow; -namespace fs = boost::filesystem; - namespace Slic3r { namespace GUI { diff --git a/src/slic3r/GUI/ProgressStatusBar.hpp b/src/slic3r/GUI/ProgressStatusBar.hpp index e29883c63e..79343d51df 100644 --- a/src/slic3r/GUI/ProgressStatusBar.hpp +++ b/src/slic3r/GUI/ProgressStatusBar.hpp @@ -68,10 +68,6 @@ private: CancelFn m_cancel_cb; }; -namespace GUI { - using Slic3r::ProgressStatusBar; -} - } #endif // PROGRESSSTATUSBAR_HPP From 559ad3e2b7c7e80d9aa0c8f6a1ce3227e06418d6 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:23:11 +0800 Subject: [PATCH 12/22] Flag Global Usings in Headers with clang-tidy (#16225) A using-directive or using-declaration in the global namespace of a header reaches every file that includes it, and a using-declaration also makes the include checker treat that header as the one to include for the name. google-global-names-in-headers reports both, on changed lines like the existing check, so headers that still have one are not held to it until the line is touched. The check does not see a using inside a namespace. clang_tidy_diff.py's closing message assumed every finding was a missing include; it now says other findings need a manual fix. --- .clang-tidy | 13 +++++++++---- scripts/clang_tidy_diff.py | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index ed2378536e..ab2a1dfbd7 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,10 +1,15 @@ # clang-tidy configuration, enforced by the clang-tidy CI job on the lines a pull -# request changes (scripts/clang_tidy_diff.py). Only missing includes are reported -# for now: a file should include the header for every symbol it uses, not rely on -# the precompiled header or another header's includes. Run with --fix to add them. +# request changes (scripts/clang_tidy_diff.py). Two things are reported. +# Missing includes: a file should include the header for every symbol it uses, not +# rely on the precompiled header or another header's includes. Run with --fix to +# add them. +# Using-directives and using-declarations in the global namespace of a header: +# they reach every file that includes the header, and a using-declaration also +# makes the header look like the one to include for that name. Qualify the name +# in the header, and put the using in the source files that want it. # Every check listed here gates pull requests, so enable a new one only once the # code it flags on touched lines is reasonable to fix in passing. -Checks: '-*,misc-include-cleaner' +Checks: '-*,misc-include-cleaner,google-global-names-in-headers' WarningsAsErrors: '*' CheckOptions: # Missing includes only. Builds without the precompiled header break on these. diff --git a/scripts/clang_tidy_diff.py b/scripts/clang_tidy_diff.py index 130e4661df..1e716b6baf 100644 --- a/scripts/clang_tidy_diff.py +++ b/scripts/clang_tidy_diff.py @@ -311,11 +311,12 @@ def main(): for path in fixed: print(f" {path}") if failed and fixed: - print(f"\nclang-tidy still fails on {len(failed)} file(s); the findings above are what --fix could not add.") + print(f"\nclang-tidy still fails on {len(failed)} file(s); the findings above are what --fix could not fix.") return 1 if failed: print(f"\nclang-tidy failed on {len(failed)} file(s). Add the includes it names, or apply its " - "suggestions locally with scripts/run_clang_tidy.sh --fix (scripts\\run_clang_tidy.ps1 -Fix on Windows).") + "suggestions locally with scripts/run_clang_tidy.sh --fix (scripts\\run_clang_tidy.ps1 -Fix on Windows). " + "Other findings need a manual fix.") return 1 print("clang-tidy passed.") return 0 From 1ec195a221d65b0cadcf4c6b9e6bc4e87b2beeb5 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 7 Oct 2026 14:44:04 +0800 Subject: [PATCH 13/22] Update build commands in AGENTS.md to use Release configuration --- AGENTS.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 51db547133..8e7b141718 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,15 +4,17 @@ OrcaSlicer — open-source C++17 3D slicer. wxWidgets GUI, CMake build system. ## Build Commands +Build the Release configuration unless asked otherwise. + ```bash # macOS -cmake --build build/arm64 --config RelWithDebInfo --target all -- +cmake --build build/arm64 --config Release --target all -- # Linux -cmake --build build --config RelWithDebInfo --target all -- +cmake --build build --config Release --target all -- -# Windows (replace %build_type% with Debug/Release/RelWithDebInfo) -cmake --build . --config %build_type% --target ALL_BUILD -- -m +# Windows +cmake --build . --config Release --target ALL_BUILD -- -m ``` ## Testing From 6639a32b0c3fa667dfc2a7605dfe512525dadc86 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:58:49 +0800 Subject: [PATCH 14/22] Remove using namespace std from json_diff.hpp (#16222) The directive sat at global scope in a header that DeviceManager.hpp includes, so most of the GUI compiled with all of std in the global namespace. 42 files had come to rely on it, mostly for string, vector and unordered_map, four of them for the ""sv and ""ms literals. Those sites are qualified. GCodeViewer.cpp spelled the type as std::vector<::string>, which only resolved through the directive. The files that use the ""sv and ""ms literals get a file-scope "using namespace std::string_view_literals;" or "using namespace std::chrono_literals;", as other sources already do. --- src/slic3r/GUI/AMSMaterialsSetting.cpp | 4 ++-- src/slic3r/GUI/Auxiliary.cpp | 6 +++--- src/slic3r/GUI/CalibrationWizardPresetPage.cpp | 6 +++--- src/slic3r/GUI/CreatePresetsDialog.cpp | 8 ++++---- src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp | 2 +- src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp | 2 +- src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp | 4 ++-- src/slic3r/GUI/DeviceErrorDialog.cpp | 2 +- src/slic3r/GUI/DeviceManager.cpp | 3 ++- src/slic3r/GUI/EditGCodeDialog.cpp | 6 +++--- src/slic3r/GUI/Field.cpp | 8 ++++---- src/slic3r/GUI/GCodeViewer.cpp | 4 +++- src/slic3r/GUI/GLCanvas3D.cpp | 2 ++ src/slic3r/GUI/GUI_App.cpp | 6 +++--- src/slic3r/GUI/GUI_ObjectList.cpp | 4 ++-- src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp | 2 ++ src/slic3r/GUI/HMS.cpp | 14 +++++++------- src/slic3r/GUI/Jobs/PrintJob.cpp | 2 +- src/slic3r/GUI/NotificationManager.cpp | 10 +++++----- src/slic3r/GUI/PartSkipDialog.cpp | 8 ++++---- src/slic3r/GUI/PartSkipDialog.hpp | 6 +++--- src/slic3r/GUI/Plater.cpp | 8 ++++---- src/slic3r/GUI/Preferences.cpp | 4 ++-- src/slic3r/GUI/Project.cpp | 2 +- src/slic3r/GUI/SelectMachine.cpp | 8 ++++---- src/slic3r/GUI/SelectMachine.hpp | 2 +- src/slic3r/GUI/SendToPrinter.cpp | 2 +- src/slic3r/GUI/StatusPanel.hpp | 4 ++-- src/slic3r/GUI/SyncAmsInfoDialog.cpp | 4 ++-- src/slic3r/GUI/Tab.cpp | 2 +- src/slic3r/GUI/WebGuideDialog.cpp | 10 +++++----- src/slic3r/GUI/Widgets/AMSControl.cpp | 2 +- src/slic3r/GUI/Widgets/AMSControl.hpp | 4 ++-- src/slic3r/GUI/Widgets/AMSItem.cpp | 6 +++--- src/slic3r/GUI/Widgets/AMSItem.hpp | 12 ++++++------ src/slic3r/Utils/json_diff.hpp | 3 --- 36 files changed, 93 insertions(+), 89 deletions(-) diff --git a/src/slic3r/GUI/AMSMaterialsSetting.cpp b/src/slic3r/GUI/AMSMaterialsSetting.cpp index 66e87ac3af..83dd6a2d07 100644 --- a/src/slic3r/GUI/AMSMaterialsSetting.cpp +++ b/src/slic3r/GUI/AMSMaterialsSetting.cpp @@ -974,8 +974,8 @@ bool AMSMaterialsSetting::Show(bool show) static void _collect_filament_info(const wxString& shown_name, const Preset& filament, - unordered_map& query_filament_vendors, - unordered_map& query_filament_types) + std::unordered_map& query_filament_vendors, + std::unordered_map& query_filament_types) { query_filament_vendors[shown_name] = filament.config.get_filament_vendor(); query_filament_types[shown_name] = filament.config.get_filament_type(); diff --git a/src/slic3r/GUI/Auxiliary.cpp b/src/slic3r/GUI/Auxiliary.cpp index 1827032b29..85f6533c1c 100644 --- a/src/slic3r/GUI/Auxiliary.cpp +++ b/src/slic3r/GUI/Auxiliary.cpp @@ -856,14 +856,14 @@ void AuxiliaryPanel::Split(const std::string &src, const std::string &separator, dest.clear(); index = str.find_first_of(separator, start); do { - if (index != string::npos) { + if (index != std::string::npos) { substring = str.substr(start, index - start); dest.push_back(substring); start = index + separator.size(); index = str.find(separator, start); - if (start == string::npos) break; + if (start == std::string::npos) break; } - } while (index != string::npos); + } while (index != std::string::npos); // the last part substring = str.substr(start); diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp index e49ebfb787..3ed3ca66df 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp @@ -1307,7 +1307,7 @@ void CalibrationPresetPage::stripWhiteSpace(std::string& str) { if (str == "") { return; } - string::iterator cur_it; + std::string::iterator cur_it; cur_it = str.begin(); while (cur_it != str.end()) { @@ -2597,7 +2597,7 @@ void CalibrationPresetPage::update_multi_extruder_filament_combobox(const std::s int ams_id_int = 0; try { if (!ams_id.empty()) - ams_id_int = stoi(ams_id.c_str()); + ams_id_int = std::stoi(ams_id.c_str()); } catch (...) {} @@ -2685,7 +2685,7 @@ void CalibrationPresetPage::update_filament_combobox(std::string ams_id) int ams_id_int = 0; try { if (!ams_id.empty()) - ams_id_int = stoi(ams_id.c_str()); + ams_id_int = std::stoi(ams_id.c_str()); } catch (...) {} diff --git a/src/slic3r/GUI/CreatePresetsDialog.cpp b/src/slic3r/GUI/CreatePresetsDialog.cpp index efe7bc16ba..c7c9cd2760 100644 --- a/src/slic3r/GUI/CreatePresetsDialog.cpp +++ b/src/slic3r/GUI/CreatePresetsDialog.cpp @@ -347,7 +347,7 @@ static std::string get_curr_timestmp() // return timestampString; } -static void get_filament_compatible_printer(Preset* preset, vector& printers) +static void get_filament_compatible_printer(Preset* preset, std::vector& printers) { auto compatible_printers = dynamic_cast(preset->config.option("compatible_printers")); if (compatible_printers == nullptr) return; @@ -1581,7 +1581,7 @@ void CreateFilamentPresetDialog::sort_printer_by_nozzle(std::vector nozzle_diameter = nozzle_diameter_map; std::sort(printer_name_to_filament_preset.begin(), printer_name_to_filament_preset.end(), - [&nozzle_diameter](const std::pair &a, const std::pair &b) { + [&nozzle_diameter](const std::pair &a, const std::pair &b) { size_t nozzle_index_a = a.first.find(" nozzle"); size_t nozzle_index_b = b.first.find(" nozzle"); if (nozzle_index_a == std::string::npos || nozzle_index_b == std::string::npos) return a.first < b.first; @@ -3143,7 +3143,7 @@ void CreatePrinterPresetDialog::set_current_visible_printer() wxArrayString CreatePrinterPresetDialog::printer_preset_sort_with_nozzle_diameter(const VendorProfile &vendor_profile, float nozzle_diameter) { - std::vector> preset_sort; + std::vector> preset_sort; auto get_nozzle_size_for_printer_model = [this](const std::string & model_name) -> size_t { auto iter = m_printer_name_to_preset.find(model_name); @@ -4964,7 +4964,7 @@ wxBoxSizer *CreatePresetForPrinterDialog::create_selected_filament_preset_sizer( m_selected_printer->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &e) { wxString printer_name = m_selected_printer->GetStringSelection(); - std::unordered_map>>::iterator filament_iter = m_printer_compatible_filament_presets.find(into_u8(printer_name)); + std::unordered_map>>::iterator filament_iter = m_printer_compatible_filament_presets.find(into_u8(printer_name)); if (m_printer_compatible_filament_presets.end() != filament_iter) { filament_choice_to_filament_preset.clear(); wxArrayString filament_choices; diff --git a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp index 8644047e64..14d78fba1f 100644 --- a/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp @@ -160,7 +160,7 @@ DevAms::~DevAms() m_trays.clear(); } -static unordered_map s_ams_display_formats = { +static std::unordered_map s_ams_display_formats = { {DevAms::AMS, "AMS-%d"}, {DevAms::AMS_LITE, "AMS Lite-%d"}, {DevAms::N3F, "AMS 2 PRO-%d"}, diff --git a/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp b/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp index 5eb0defa93..95081f5382 100644 --- a/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp +++ b/src/slic3r/GUI/DeviceCore/DevMappingNozzle.cpp @@ -250,7 +250,7 @@ int DevNozzleMappingCtrl::CtrlGetAutoNozzleMappingV1(Slic3r::GUI::Plater* plater void DevNozzleMappingCtrl::ParseAutoNozzleMapping(const json& print_jj) { - if (print_jj.contains("command") && print_jj["command"].get() == "get_auto_nozzle_mapping") { + if (print_jj.contains("command") && print_jj["command"].get() == "get_auto_nozzle_mapping") { if (print_jj.contains("sequence_id") && print_jj["sequence_id"] == m_sequence_id) { Clear(); DevJsonValParser::ParseVal(print_jj, "result", m_result); diff --git a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp index 98d5d5bd5f..14c29817ef 100644 --- a/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp +++ b/src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp @@ -426,7 +426,7 @@ void DevNozzleSystem::ClearNozzles() // ---- parsing ---------------------------------------------------------------------------------------- -static unordered_map _str2_nozzle_flow_type = { +static std::unordered_map _str2_nozzle_flow_type = { {"S", NozzleFlowType::S_FLOW}, {"H", NozzleFlowType::H_FLOW}, {"A", NozzleFlowType::S_FLOW}, @@ -436,7 +436,7 @@ static unordered_map _str2_nozzle_flow_type = { {"B", NozzleFlowType::E_FLOW}, // E3D High Flow -> nvtE3DHighFlow }; -static unordered_map _str2_nozzle_type = { +static std::unordered_map _str2_nozzle_type = { {"00", NozzleType::ntStainlessSteel}, {"01", NozzleType::ntHardenedSteel}, {"05", NozzleType::ntTungstenCarbide} diff --git a/src/slic3r/GUI/DeviceErrorDialog.cpp b/src/slic3r/GUI/DeviceErrorDialog.cpp index de578f78ed..23b7f3a665 100644 --- a/src/slic3r/GUI/DeviceErrorDialog.cpp +++ b/src/slic3r/GUI/DeviceErrorDialog.cpp @@ -368,7 +368,7 @@ wxString DeviceErrorDialog::parse_error_level(int error_code) } } -static const std::unordered_set s_jump_liveview_error_codes = { "0300-8003", "0300-8002", "0300-800A"}; +static const std::unordered_set s_jump_liveview_error_codes = { "0300-8003", "0300-8002", "0300-800A"}; wxString DeviceErrorDialog::show_error_code(int error_code) { if (m_error_code == error_code) { return wxEmptyString;} diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 3729387040..30e7282c0e 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -110,6 +110,7 @@ using json = nlohmann::json; class wxWindow; namespace fs = boost::filesystem; +using namespace std::chrono_literals; #define CALI_DEBUG #define MINUTE_30 1800000 //ms @@ -3103,7 +3104,7 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_ DevFirmwareVersionInfo ver_info; ver_info.name = (*it)["name"].get(); if ((*it).contains("product_name")) - ver_info.product_name = wxString::FromUTF8((*it)["product_name"].get()); + ver_info.product_name = wxString::FromUTF8((*it)["product_name"].get()); if ((*it).contains("sw_ver")) ver_info.sw_ver = (*it)["sw_ver"].get(); if ((*it).contains("sw_new_ver")) diff --git a/src/slic3r/GUI/EditGCodeDialog.cpp b/src/slic3r/GUI/EditGCodeDialog.cpp index 917ff56013..2ef70ab82b 100644 --- a/src/slic3r/GUI/EditGCodeDialog.cpp +++ b/src/slic3r/GUI/EditGCodeDialog.cpp @@ -294,8 +294,8 @@ wxDataViewItem EditGCodeDialog::add_presets_placeholders() // Orca: create subgroups from the pages of the tabs - auto init_from_tab = [this, full_config](wxDataViewItem parent, Tab* tab, const set& preset_keys){ - set extra_keys(preset_keys); + auto init_from_tab = [this, full_config](wxDataViewItem parent, Tab* tab, const std::set& preset_keys){ + std::set extra_keys(preset_keys); for (const auto& page : tab->m_pages) { // ORCA: Pull icons from tabs for subgroups, icons are hidden on tabs std::string icon_name = "empty"; // use empty icon if not defined @@ -549,7 +549,7 @@ void ParamsNode::RefreshSearch(const wxString& search_text) if (GetEnabledChildren().empty()) if (auto pos = text.find(search_text); IsParamNode() && pos != wxString::npos) { - m_highlight_index = make_unique>(pos, search_text.Len()); + m_highlight_index = make_unique>(pos, search_text.Len()); Enable(); } else { Disable(); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index 05ab99bae1..fda86e854d 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -702,11 +702,11 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true set_value(str, true); } } else if (m_opt.opt_key == "sparse_infill_rotate_template" || m_opt.opt_key == "solid_infill_rotate_template") { - string ustr(str.utf8_string()); + std::string ustr(str.utf8_string()); if (!ConfigOptionFloats::validate_string(ustr)) { - string v; + std::string v; std::smatch match; - string ps = (m_opt.opt_key == "sparse_infill_rotate_template") ? + std::string ps = (m_opt.opt_key == "sparse_infill_rotate_template") ? u8"[BT][!]?|[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[BT]?[!*]?" : u8"[#][\\d]+[!]?|[+\\-]?[\\d.]+[%]?[*]?[\\d]*[/NnZz$LlUuQq~^|#]?[+\\-]?[\\d.]*[%#\'\"cm]?[m]?[!*]?"; @@ -729,7 +729,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } break; } else if (m_opt.opt_key == "extra_solid_infills") { - string ustr(str.utf8_string()); + std::string ustr(str.utf8_string()); // New rule: accept either interval form (N or N#K) or explicit list (e.g. 1,7,9), with optional quotes. const std::regex rx_interval(u8R"(^\s*['"]?\s*\d+\s*(?:#\s*\d*)?\s*['"]?\s*$)"); // List entries may be plain numbers or number with optional #K count, e.g., 5, 9#2, 18 diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 4727ed0871..f21ce9ac15 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -94,6 +94,8 @@ #include "slic3r/GUI/Gizmos/GizmoObjectManipulation.hpp" #include "slic3r/GUI/PartPlate.hpp" +using namespace std::string_view_literals; + namespace Slic3r { class PrintBase; } @@ -3184,7 +3186,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) float ams_item_height = 0; float filament_group_item_align_width = 0; { - float three_words_width = imgui.calc_text_size(std::string_view("ABC")).x; + float three_words_width = imgui.calc_text_size("ABC"sv).x; const int line_capacity = 4; for (const auto& extruder_filaments : {m_left_extruder_filament,m_right_extruder_filament }) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 4f6c54fac5..6ad3e80dc0 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -177,6 +177,8 @@ extern wxPopupWindow* wxCurrentPopupWindow; #endif #endif +using namespace std::string_view_literals; + static constexpr const float TRACKBALLSIZE = 0.8f; static Slic3r::ColorRGBA DEFAULT_BG_LIGHT_COLOR = { 0.906f, 0.906f, 0.906f, 1.0f }; diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 499ac6f23d..11cde7e5f2 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -9040,7 +9040,7 @@ std::map GUI_App::get_delete_cache_presets_lock() void GUI_App::process_delete_presets() { - std::map delete_cache_presets = get_delete_cache_presets_lock(); + std::map delete_cache_presets = get_delete_cache_presets_lock(); for (auto it = delete_cache_presets.begin(); it != delete_cache_presets.end();) { if (it->first.empty()) continue; std::string del_setting_id = it->first; @@ -10068,7 +10068,7 @@ bool is_soluble_filament(int extruder_id) return support_option->get_at(0); }; -bool has_filaments(const std::vector& model_filaments) { +bool has_filaments(const std::vector& model_filaments) { auto &filament_presets = Slic3r::GUI::wxGetApp().preset_bundle->filament_presets; if (!Slic3r::GUI::wxGetApp().plater()) return false; auto model_objects = Slic3r::GUI::wxGetApp().plater()->model().objects; @@ -10103,7 +10103,7 @@ bool is_support_filament(int extruder_id, bool strict_check) Slic3r::ConfigOptionBools *support_option = dynamic_cast(filament->config.option("filament_is_support")); if(!strict_check &&(filament_type == "PETG" || filament_type == "PLA")) { - std::vector model_filaments; + std::vector model_filaments; if (filament_type == "PETG") model_filaments.emplace_back("PLA"); else { diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index fd6da1beef..47e391b2ed 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1108,7 +1108,7 @@ void ObjectList::update_name_column_width() const } } - GetColumn(colName)->SetWidth(max(0, client_size.x - (others_width)*em)); + GetColumn(colName)->SetWidth(std::max(0, client_size.x - (others_width)*em)); } void ObjectList::set_filament_column_hidden(const bool hide) const @@ -3970,7 +3970,7 @@ wxDataViewItem ObjectList::add_settings_item(wxDataViewItem parent_item, const D if (config->opt_float("layer_height") == object_cfg->opt_float("layer_height")) { SettingsFactory::Bundle new_cat_options; for (auto cat_opt : cat_options) { - std::vector temp; + std::vector temp; for (auto value : cat_opt.second) { if (value != "layer_height") temp.push_back(value); diff --git a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp index 72f08318c6..bb76a171b8 100644 --- a/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp +++ b/src/slic3r/GUI/Gizmos/GizmoObjectManipulation.cpp @@ -44,6 +44,8 @@ #define MAX_NUM 9999.99 #define MAX_SIZE std::string_view{"9999.99"} +using namespace std::string_view_literals; + namespace Slic3r { namespace GUI diff --git a/src/slic3r/GUI/HMS.cpp b/src/slic3r/GUI/HMS.cpp index 0a5dba5a0e..2234d1afb4 100644 --- a/src/slic3r/GUI/HMS.cpp +++ b/src/slic3r/GUI/HMS.cpp @@ -33,7 +33,7 @@ static const char* HMS_LOCAL_IMG_PATH = "hms/local_image"; // the local HMS info // Orca: dev-id-type set trimmed to the devices Orca ships local HMS images for -static unordered_set package_dev_id_types {"094", "239", "093", "22E"}; +static std::unordered_set package_dev_id_types {"094", "239", "093", "22E"}; // Orca: HMS should be disabled when stealth mode is on or networking is not installed static bool should_disable_hms() @@ -345,17 +345,17 @@ wxString HMSQuery::query_hms_msg(const std::string& dev_id, const std::string& l return _query_hms_msg(dev_id.substr(0, 3), long_error_code, lang_code); } -string HMSQuery::get_dev_id_type(const MachineObject* obj) const +std::string HMSQuery::get_dev_id_type(const MachineObject* obj) const { if (obj) { return obj->get_dev_id().substr(0, 3); } - return string(); + return std::string(); } -wxString HMSQuery::_query_hms_msg(const string& dev_id_type, const string& long_error_code, const string& lang_code) +wxString HMSQuery::_query_hms_msg(const std::string& dev_id_type, const std::string& long_error_code, const std::string& lang_code) { if (long_error_code.empty()) { @@ -426,9 +426,9 @@ wxString HMSQuery::_query_hms_msg(const string& dev_id_type, const string& long_ return wxEmptyString; } -bool HMSQuery::_is_internal_error(const string &dev_id_type, - const string &error_code, - const string &lang_code) +bool HMSQuery::_is_internal_error(const std::string &dev_id_type, + const std::string &error_code, + const std::string &lang_code) { init_hms_info(dev_id_type); auto iter = m_hms_info_jsons.find(dev_id_type); diff --git a/src/slic3r/GUI/Jobs/PrintJob.cpp b/src/slic3r/GUI/Jobs/PrintJob.cpp index 9e5e2cc7c4..b6b420969f 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -335,7 +335,7 @@ void PrintJob::process(Ctl &ctl) auto origin_profile_id = model_info->metadata_items.find(BBL_DESIGNER_PROFILE_ID_TAG); if (origin_profile_id != model_info->metadata_items.end()) { try { - params.origin_profile_id = stoi(origin_profile_id->second.c_str()); + params.origin_profile_id = std::stoi(origin_profile_id->second.c_str()); } catch(...) {} } diff --git a/src/slic3r/GUI/NotificationManager.cpp b/src/slic3r/GUI/NotificationManager.cpp index 7a7050429d..3e91d19cdd 100644 --- a/src/slic3r/GUI/NotificationManager.cpp +++ b/src/slic3r/GUI/NotificationManager.cpp @@ -536,12 +536,12 @@ void NotificationManager::PopNotification::count_lines() return; // handle with marks - if (pos_start == string::npos && pos_end == string::npos) { + if (pos_start == std::string::npos && pos_end == std::string::npos) { pos_start = text.find(error_start); - if (pos_start != string::npos) { + if (pos_start != std::string::npos) { text.erase(pos_start, error_start.length()); pos_end = text.find(error_end); - if (pos_end != string::npos) { + if (pos_end != std::string::npos) { text.erase(pos_end, error_end.length()); } } @@ -675,7 +675,7 @@ void NotificationManager::PopNotification::bbl_render_block_notif_text(ImGuiWrap if (m_text1.size() > m_endlines[i]) last_end += (m_text1[m_endlines[i]] == '\n' || m_text1[m_endlines[i]] == ' ' ? 1 : 0); - if (pos_start != string::npos && pos_end != string::npos && m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { + if (pos_start != std::string::npos && pos_end != std::string::npos && m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { push_style_color(ImGuiCol_Text, m_ErrorColor, m_state == EState::FadingOut, m_current_fade_opacity); imgui.text(line.c_str()); ImGui::PopStyleColor(); @@ -737,7 +737,7 @@ void NotificationManager::PopNotification::render_text(ImGuiWrapper& imgui, cons if (m_text1.size() > m_endlines[i]) last_end += (m_text1[m_endlines[i]] == '\n' || m_text1[m_endlines[i]] == ' ' ? 1 : 0); - if (pos_start != string::npos && pos_end != string::npos&& m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { + if (pos_start != std::string::npos && pos_end != std::string::npos&& m_endlines[i] - line.length() >= pos_start && m_endlines[i] <= pos_end) { push_style_color(ImGuiCol_Text, m_ErrorColor, m_state == EState::FadingOut, m_current_fade_opacity); imgui.text(line.c_str()); ImGui::PopStyleColor(); diff --git a/src/slic3r/GUI/PartSkipDialog.cpp b/src/slic3r/GUI/PartSkipDialog.cpp index ddf0d10965..4c0557abea 100644 --- a/src/slic3r/GUI/PartSkipDialog.cpp +++ b/src/slic3r/GUI/PartSkipDialog.cpp @@ -86,7 +86,7 @@ PartSkipDialog::PartSkipDialog(wxWindow *parent) : DPIDialog(parent, wxID_ANY, _ { std::time_t t = std::time(0); std::stringstream buf; - buf << put_time(std::localtime(&t), "%a_%b_%d_%H_%M_%S/"); + buf << std::put_time(std::localtime(&t), "%a_%b_%d_%H_%M_%S/"); m_timestamp = buf.str(); SetBackgroundColour(*wxWHITE); @@ -402,7 +402,7 @@ std::string PartSkipDialog::create_tmp_path() return tmp_path; } -bool PartSkipDialog::is_local_file_existed(const std::vector &local_paths) +bool PartSkipDialog::is_local_file_existed(const std::vector &local_paths) { for (auto path : local_paths) { if (!std::filesystem::exists(path)) { return false; } @@ -703,8 +703,8 @@ void PartSkipDialog::InitDialogUI() m_parts_state.clear(); m_parts_name.clear(); - string pick_img = m_local_paths[0]; - string slice_info = m_local_paths[2]; + std::string pick_img = m_local_paths[0]; + std::string slice_info = m_local_paths[2]; m_switch_drag_btn->SetIcon("canvas_drag"); m_switch_drag_btn->SetBackgroundColor(*wxWHITE); diff --git a/src/slic3r/GUI/PartSkipDialog.hpp b/src/slic3r/GUI/PartSkipDialog.hpp index f1aef1f022..4e4f7b6bb6 100644 --- a/src/slic3r/GUI/PartSkipDialog.hpp +++ b/src/slic3r/GUI/PartSkipDialog.hpp @@ -139,11 +139,11 @@ private: boost::shared_ptr m_file_sys; std::string m_timestamp; std::string m_tmp_path; - std::vector m_local_paths; - std::vector m_target_paths; + std::vector m_local_paths; + std::vector m_target_paths; std::string create_tmp_path(); - bool is_local_file_existed(const std::vector &local_paths); + bool is_local_file_existed(const std::vector &local_paths); void DownloadPartsFile(); void OnFileSystemEvent(wxCommandEvent &event); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 707bed30b1..76ccac2838 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -357,7 +357,7 @@ wxDEFINE_EVENT(EVT_NOTICE_FULL_SCREEN_CHANGED, IntEvent); #define PRINTER_PANEL_RADIUS (6) // ORCA #define BTN_SYNC_SIZE (wxSize(FromDIP(96), FromDIP(98))) -static string get_diameter_string(float diameter) +static std::string get_diameter_string(float diameter) { std::ostringstream stream; // ORCA ensure 0.25 returned as 0.25. previous code returned as 0.2 because of std::setprecision(1) stream << std::fixed << std::setprecision(2) << diameter; // Use 2 decimals to capture 0.25 / 0.15 reliably @@ -6323,7 +6323,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn) } // BBS:Record consumables information before synchronization - std::vector color_before_sync; + std::vector color_before_sync; std::vector is_support_before; DynamicPrintConfig& project_config = wxGetApp().preset_bundle->project_config; ConfigOptionStrings* color_opt = project_config.option("filament_colour"); @@ -12762,7 +12762,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt) Vec3d old_plate_pos = old_plate->get_center_origin(); // BBS: Save the model in the current platelist - std::vector > plate_object; + std::vector > plate_object; for (size_t i = 0; i < old_plate_list.get_plate_count(); ++i) { PartPlate* plate = old_plate_list.get_plate(i); std::vector obj_idxs; @@ -17975,7 +17975,7 @@ bool Plater::load_files(const wxArrayString& filenames) // Orca: Iters through given paths and imports files from zip then remove zip from paths // returns true if zip files were found - auto handle_zips = [this](vector& paths) { // NOLINT(*-no-recursion) - Recursion is intended and should be managed properly + auto handle_zips = [this](std::vector& paths) { // NOLINT(*-no-recursion) - Recursion is intended and should be managed properly bool res = false; for (auto it = paths.begin(); it != paths.end();) { if (boost::algorithm::iends_with(it->string(), ".zip")) { diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 735b02f58b..27e101745e 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -378,7 +378,7 @@ wxBoxSizer *PreferencesDialog::create_item_combobox(wxString title, wxString too auto current_setting = app_config->get(param); if (!current_setting.empty()) { - auto compare = [current_setting](string possible_setting) { return current_setting == possible_setting; }; + auto compare = [current_setting](std::string possible_setting) { return current_setting == possible_setting; }; auto iterator = find_if(config_name_index.begin(), config_name_index.end(), compare); if (iterator != config_name_index.end()) current_index = static_cast(iterator - config_name_index.begin()); @@ -1714,7 +1714,7 @@ void PreferencesDialog::create_items() g_sizer->Add(create_item_title(_L("Project")), 1, wxEXPAND); std::vector projectLoadSettingsBehaviourOptions = {_L("Load All"), _L("Ask When Relevant"), _L("Always Ask"), _L("Load Geometry Only")}; - std::vector projectLoadSettingsConfigOptions = { OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_ALL, OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT, OPTION_PROJECT_LOAD_BEHAVIOUR_ALWAYS_ASK, OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_GEOMETRY }; + std::vector projectLoadSettingsConfigOptions = { OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_ALL, OPTION_PROJECT_LOAD_BEHAVIOUR_ASK_WHEN_RELEVANT, OPTION_PROJECT_LOAD_BEHAVIOUR_ALWAYS_ASK, OPTION_PROJECT_LOAD_BEHAVIOUR_LOAD_GEOMETRY }; auto item_project_load = create_item_combobox(_L("Load behavior"), _L("Should printer/filament/process settings be loaded when opening a 3MF file?"), SETTING_PROJECT_LOAD_BEHAVIOUR, projectLoadSettingsBehaviourOptions, projectLoadSettingsConfigOptions); g_sizer->Add(item_project_load); diff --git a/src/slic3r/GUI/Project.cpp b/src/slic3r/GUI/Project.cpp index a0ed54cfe2..0680878999 100644 --- a/src/slic3r/GUI/Project.cpp +++ b/src/slic3r/GUI/Project.cpp @@ -239,7 +239,7 @@ void ProjectPanel::on_reload(wxCommandEvent& evt) } bool has_content = false; - for (const string& v : { + for (const std::string& v : { update_type, license, model_name, diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 3a23889c6c..a885dcd058 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -182,7 +182,7 @@ std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_t static int s_nozzle_mapping_last_request_time = 0; std::vector SelectMachineDialog::MACHINE_BED_TYPE_STRING; -std::vector SelectMachineDialog::MachineBedTypeString; +std::vector SelectMachineDialog::MachineBedTypeString; void SelectMachineDialog::init_machine_bed_types() { if (MACHINE_BED_TYPE_STRING.size() == 0) { @@ -2748,8 +2748,8 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event) std::vector confirm_text; // check more than one using in same external spool - std::unordered_set main_external_spool_filas; - std::unordered_set deputy_external_spool_filas; + std::unordered_set main_external_spool_filas; + std::unordered_set deputy_external_spool_filas; for (const auto& mapping_info : m_ams_mapping_result) { if (mapping_info.ams_id == VIRTUAL_AMS_MAIN_ID_STR){ main_external_spool_filas.insert(mapping_info.filament_id); @@ -5239,7 +5239,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_) /*Check high temperture slicing*/ if (m_print_type == PrintFromType::FROM_NORMAL) { - std::set high_temp_filaments; + std::set high_temp_filaments; std::unordered_set known_fila_soften_extruders; std::unordered_set unknown_fila_soften_extruders; auto preset_full_config = wxGetApp().preset_bundle->full_config(); diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index a0515dd20c..31ce752a2e 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -337,7 +337,7 @@ private: wxColour m_colour_bold_color{wxColour(38, 46, 48)}; StateColor m_btn_bg_enable; - std::unordered_map m_checkbox_list; + std::unordered_map m_checkbox_list; std::list m_checkbox_list_order; std::shared_ptr m_token = std::make_shared(0); diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index 370baf29d1..7e98fbe85e 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -126,7 +126,7 @@ void SendToPrinterDialog::stripWhiteSpace(std::string& str) { if (str == "") { return; } - string::iterator cur_it; + std::string::iterator cur_it; cur_it = str.begin(); while (cur_it != str.end()) { diff --git a/src/slic3r/GUI/StatusPanel.hpp b/src/slic3r/GUI/StatusPanel.hpp index af908c0c80..cd297eefe8 100644 --- a/src/slic3r/GUI/StatusPanel.hpp +++ b/src/slic3r/GUI/StatusPanel.hpp @@ -171,7 +171,7 @@ public: std::string current_nozzle_loc = ""; wxColour m_colour; - string m_file_name; + std::string m_file_name; bool m_ams_loading{false}; void doRender(wxDC &dc); ExtruderImage(wxWindow *parent, wxWindowID id, int nozzle_num, const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize); @@ -244,7 +244,7 @@ protected: { wxString local_image_url; //local image path std::string img_url_paths; // oss url path - vector image_broad; + std::vector image_broad; bool is_selected; bool is_uploaded; // load wxBoxSizer * image_tb_broad = nullptr; diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index 61998dc963..d6049451b9 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -1576,7 +1576,7 @@ bool SyncAmsInfoDialog::is_nozzle_type_match(DevExtderSystem data, wxString &err } } - vector map_extruders = {1, 0}; + std::vector map_extruders = {1, 0}; // The default two extruders are left, right, but the order of the extruders on the machine is right, left. std::vector flow_type_of_machine; @@ -1676,7 +1676,7 @@ void SyncAmsInfoDialog::stripWhiteSpace(std::string &str) { if (str == "") { return; } - string::iterator cur_it; + std::string::iterator cur_it; cur_it = str.begin(); while (cur_it != str.end()) { diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e08745666c..143025399f 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2257,7 +2257,7 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value) wxGetApp().plater()->update(); } - string opt_key_without_idx = opt_key.substr(0, opt_key.find('#')); + std::string opt_key_without_idx = opt_key.substr(0, opt_key.find('#')); if (opt_key_without_idx == "long_retractions_when_cut") { unsigned char activate = boost::any_cast(value); diff --git a/src/slic3r/GUI/WebGuideDialog.cpp b/src/slic3r/GUI/WebGuideDialog.cpp index b5b48d413e..b3e0aa7cd6 100644 --- a/src/slic3r/GUI/WebGuideDialog.cpp +++ b/src/slic3r/GUI/WebGuideDialog.cpp @@ -1682,13 +1682,13 @@ int GuideFrame::SaveProfileData() return 0; } -void StringReplace(string &strBase, string strSrc, string strDes) +void StringReplace(std::string &strBase, std::string strSrc, std::string strDes) { - string::size_type pos = 0; - string::size_type srcLen = strSrc.size(); - string::size_type desLen = strDes.size(); + std::string::size_type pos = 0; + std::string::size_type srcLen = strSrc.size(); + std::string::size_type desLen = strDes.size(); pos = strBase.find(strSrc, pos); - while ((pos != string::npos)) { + while ((pos != std::string::npos)) { strBase.replace(pos, srcLen, strDes); pos = strBase.find(strSrc, (pos + desLen)); } diff --git a/src/slic3r/GUI/Widgets/AMSControl.cpp b/src/slic3r/GUI/Widgets/AMSControl.cpp index c5015c9ddc..2fe4ac6014 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.cpp +++ b/src/slic3r/GUI/Widgets/AMSControl.cpp @@ -1052,7 +1052,7 @@ void AMSControl::UpdateAms(const std::string &series_name, /*update humidity popup*/ if (m_percent_humidity_dry_popup->IsShown()) { - string target_id = m_percent_humidity_dry_popup->get_owner_ams_id(); + std::string target_id = m_percent_humidity_dry_popup->get_owner_ams_id(); for (const auto& the_info : ams_info) { if (target_id == the_info.ams_id) diff --git a/src/slic3r/GUI/Widgets/AMSControl.hpp b/src/slic3r/GUI/Widgets/AMSControl.hpp index f4c83667c2..99146a01a6 100644 --- a/src/slic3r/GUI/Widgets/AMSControl.hpp +++ b/src/slic3r/GUI/Widgets/AMSControl.hpp @@ -63,7 +63,7 @@ protected: std::string m_dev_id; std::vector> m_item_ids{ {}, {} }; - std::vector> pair_id; + std::vector> pair_id; int m_total_ext_count = 1; AMSextruder *m_extruder{nullptr}; @@ -181,7 +181,7 @@ public: std::tuple isFilaSwitchReady(); void show_switcher_status(bool show); - void UpdatePassRoad(string ams_id, AMSPassRoadType type, AMSPassRoadSTEP step); + void UpdatePassRoad(std::string ams_id, AMSPassRoadType type, AMSPassRoadSTEP step); void CreateAms(); void CreateAmsDoubleNozzle(const std::string &series_name, const std::string& printer_type); void CreateAmsSingleNozzle(const std::string &series_name, const std::string &printer_type); diff --git a/src/slic3r/GUI/Widgets/AMSItem.cpp b/src/slic3r/GUI/Widgets/AMSItem.cpp index ef3643e531..95418f79a2 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.cpp +++ b/src/slic3r/GUI/Widgets/AMSItem.cpp @@ -634,7 +634,7 @@ void AMSextruderImage::doRender(wxDC &dc) } -AMSextruderImage::AMSextruderImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos) +AMSextruderImage::AMSextruderImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos) { wxWindow::Create(parent, id, pos, size); SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); @@ -823,7 +823,7 @@ void SwitcherImage::doRender(wxDC &dc) Layout(); } -SwitcherImage::SwitcherImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos) +SwitcherImage::SwitcherImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos) { wxWindow::Create(parent, id, pos, size); SetBackgroundColour(StateColor::darkModeColorFor(*wxWHITE)); @@ -899,7 +899,7 @@ void AMSextruder::OnAmsLoading(bool load, int nozzle_id, wxColour col /*= AMS_CO } /*return true if something is updated*/ -bool AMSextruder::updateNozzleNum(int nozzle_num, const string& series_name) +bool AMSextruder::updateNozzleNum(int nozzle_num, const std::string& series_name) { if (m_nozzle_num == nozzle_num && m_series_name == series_name) return false; m_series_name = series_name; diff --git a/src/slic3r/GUI/Widgets/AMSItem.hpp b/src/slic3r/GUI/Widgets/AMSItem.hpp index 55c0a3ca8d..c17b4ad59d 100644 --- a/src/slic3r/GUI/Widgets/AMSItem.hpp +++ b/src/slic3r/GUI/Widgets/AMSItem.hpp @@ -393,10 +393,10 @@ public: bool m_show_state = {false}; wxColour m_colour; ScalableBitmap m_ams_extruder; - string m_file_name; + std::string m_file_name; bool m_ams_loading{ false }; void doRender(wxDC &dc); - AMSextruderImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); + AMSextruderImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); ~AMSextruderImage(); }; @@ -444,10 +444,10 @@ public: bool m_show_state = {false}; wxColour m_colour; ScalableBitmap m_switcher; - string m_file_name; + std::string m_file_name; // bool m_ams_loading{ false }; void doRender(wxDC &dc); - SwitcherImage(wxWindow *parent, wxWindowID id, string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); + SwitcherImage(wxWindow *parent, wxWindowID id, std::string file_name, const wxSize& size, const wxPoint &pos = wxDefaultPosition); ~SwitcherImage(); }; @@ -456,7 +456,7 @@ class AMSextruder : public wxWindow { private: int m_nozzle_num = -1; - string m_series_name; + std::string m_series_name; public: void TurnOn(wxColour col); @@ -466,7 +466,7 @@ public: void msw_rescale(); void has_ams(bool hams) {m_has_vams = hams; Refresh();}; void no_ams_mode(bool mode) {m_none_ams_mode = mode; Refresh();}; - bool updateNozzleNum(int nozzle_num, const std::string& series_name = string()); + bool updateNozzleNum(int nozzle_num, const std::string& series_name = std::string()); bool m_none_ams_mode{true}; bool m_has_vams{false}; diff --git a/src/slic3r/Utils/json_diff.hpp b/src/slic3r/Utils/json_diff.hpp index bb88e78c7f..df097dc78c 100644 --- a/src/slic3r/Utils/json_diff.hpp +++ b/src/slic3r/Utils/json_diff.hpp @@ -7,9 +7,6 @@ #include "nlohmann/json.hpp" - -using namespace std; - class json_diff { private: From bd0ef35b90a017e1e86401b6d015eec0d25c8267 Mon Sep 17 00:00:00 2001 From: ExPikaPaka Date: Wed, 7 Oct 2026 09:25:19 +0200 Subject: [PATCH 15/22] Speed up the Linux image build Profiling build_linux_image.sh: 96 s, of which 51 s in the dependency audit. appimage_is_elf_file() ran file(1) and grep per candidate. An AppDir holds ~9.6k of them, 4.8k being the bundled Python runtime, none of them ELF: ~19k processes for 14 s. Read the four-byte magic instead; checked against the old result on 4000 files, no disagreement. The dependency walk popped its queue with "${queue[@]:1}", which rebuilds the whole array each time. At ~4.8k entries that was 22 s of copying. Use a read index. 96 s -> 12.7 s. The audit still passes. --- scripts/appimage_lib_policy.sh | 8 +++++++- src/dev-utils/platform/unix/build_linux_image.sh.in | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/appimage_lib_policy.sh b/scripts/appimage_lib_policy.sh index 35925227a0..81936d83c6 100755 --- a/scripts/appimage_lib_policy.sh +++ b/scripts/appimage_lib_policy.sh @@ -23,7 +23,13 @@ appimage_is_host_library() { } appimage_is_elf_file() { - file -b "$1" 2>/dev/null | grep -q '^ELF ' + # Read the four-byte ELF magic rather than asking file(1): this runs once per candidate, and an + # AppDir holds thousands of them (the bundled Python runtime alone is ~5k files, none of them + # ELF). Two processes per call made this ~14 s of a ~95 s image build on its own. + local magic + [[ -f "$1" && -r "$1" ]] || return 1 + IFS= read -r -n 4 -d '' magic < "$1" 2>/dev/null + [[ $magic == $'\177ELF' ]] } appimage_list_direct_dependencies() { diff --git a/src/dev-utils/platform/unix/build_linux_image.sh.in b/src/dev-utils/platform/unix/build_linux_image.sh.in index 873cf2e1b1..8466597d34 100755 --- a/src/dev-utils/platform/unix/build_linux_image.sh.in +++ b/src/dev-utils/platform/unix/build_linux_image.sh.in @@ -118,9 +118,13 @@ bundle_dependency_closure() { # (scripts/check_appimage_libs.sh). local -a search_dirs=("$dst_dir") - while [ ${#queue[@]} -gt 0 ]; do - target="${queue[0]}" - queue=("${queue[@]:1}") + # Walked with a read index rather than by reslicing the array: "${queue[@]:1}" rebuilds the whole + # queue on every pop, so draining it costs O(n^2). At the ~5k entries this bundle reaches that was + # ~22 s of the image build spent copying an array around. + local head=0 + while [ "$head" -lt ${#queue[@]} ]; do + target="${queue[$head]}" + head=$((head + 1)) if [ ! -e "$target" ] || ! appimage_is_elf_file "$target"; then continue From 662a8e340d5edd7fa5fbcf59c645a7bc931d216d Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 15:51:21 +0800 Subject: [PATCH 16/22] Support the 02.08.04 Bambu Network Plug-in Series (#16202) The 02.08.02 series appended queue_plate_id to PrintParams and nothing after it changed the ABI OrcaSlicer calls, so adding the field brings the current layout up to 02.08.04. Make 02.08.04 the latest series and drop 02.08.01 from the whitelist: its PrintParams no longer matches, and its malformed bind table is refused by dyld on macOS 27, so it cannot load there. A stored 02.08.01 falls back to the latest series through the existing unsupported-version path. --- src/slic3r/Utils/BBLNetworkPlugin.cpp | 3 +- src/slic3r/Utils/bambu_networking.hpp | 11 ++-- tests/slic3rutils/test_network_versions.cpp | 65 ++++++++++++--------- 3 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/slic3r/Utils/BBLNetworkPlugin.cpp b/src/slic3r/Utils/BBLNetworkPlugin.cpp index 5cffe6468d..bae9ce85a8 100644 --- a/src/slic3r/Utils/BBLNetworkPlugin.cpp +++ b/src/slic3r/Utils/BBLNetworkPlugin.cpp @@ -596,7 +596,8 @@ PrintParams_Legacy BBLNetworkPlugin::as_legacy(PrintParams& param) } // Every PrintParams field except the four the 02.08.01 series added -// (task_timelapse_use_internal, extruder_cali_manual_mode, svc_context, slicer_uid). +// (task_timelapse_use_internal, extruder_cali_manual_mode, svc_context, slicer_uid) and the +// queue_plate_id 02.08.02 appended. PrintParams_0203 BBLNetworkPlugin::as_0203(PrintParams& param) { PrintParams_0203 p; diff --git a/src/slic3r/Utils/bambu_networking.hpp b/src/slic3r/Utils/bambu_networking.hpp index 30c33c6c73..54079ee0bd 100644 --- a/src/slic3r/Utils/bambu_networking.hpp +++ b/src/slic3r/Utils/bambu_networking.hpp @@ -336,6 +336,7 @@ struct PrintParams { bool try_emmc_print; std::string svc_context; std::string slicer_uid; + std::string queue_plate_id; }; struct TaskQueryParams @@ -412,7 +413,7 @@ enum class NetworkAbi { Unsupported, // no generation in this build can call it - never dispatch through it Legacy, // 01.10.01: PrintParams_Legacy; send_message/send_message_to_printer take no flag V0203, // 02.03.00: PrintParams_0203; bind takes no dev_model - Current, // 02.08.01: the layouts and signatures this build declares directly + Current, // 02.08.04: the layouts and signatures this build declares directly }; struct NetworkLibraryVersion { @@ -425,10 +426,12 @@ struct NetworkLibraryVersion { }; // Every row names the generation that can call it, so a series can never be offered without a -// host-side ABI for it. Series with no generation - 02.01.01, 02.00.02 and older - must stay out; -// is_supported_network_version() is the gate that keeps them from loading. +// host-side ABI for it. Series with no generation - 02.08.01 (whose PrintParams lacks the +// queue_plate_id that 02.08.02 appended, and whose malformed bind table macOS 27 refuses to +// load), 02.01.01, 02.00.02 and older - must stay out; is_supported_network_version() is the +// gate that keeps them from loading. static const NetworkLibraryVersion AVAILABLE_NETWORK_VERSIONS[] = { - {"02.08.01", "02.08.01", nullptr, true, nullptr, NetworkAbi::Current}, + {"02.08.04", "02.08.04", nullptr, true, nullptr, NetworkAbi::Current}, {"02.03.00", "02.03.00", nullptr, false, "An older plug-in series. Features that need newer plug-in support, such as print-failure " "snapshots in the device error dialog, are unavailable.", NetworkAbi::V0203}, diff --git a/tests/slic3rutils/test_network_versions.cpp b/tests/slic3rutils/test_network_versions.cpp index ad352e0bfa..cac2c1543e 100644 --- a/tests/slic3rutils/test_network_versions.cpp +++ b/tests/slic3rutils/test_network_versions.cpp @@ -78,31 +78,34 @@ TEST_CASE("Series and managed classification", "[NetworkVersions]") TEST_CASE_METHOD(PluginFolderFixture, "Managed builds fold into the series; customs are surfaced", "[NetworkVersions]") { - add_plugin("02.08.01.55"); // managed, same series -> folded into the 02.08.01 row + add_plugin("02.08.04.60"); // managed, same series -> folded into the 02.08.04 row add_plugin("02.09.00.10"); // managed, unknown series -> not listed + add_plugin("02.08.01.55"); // managed, series this build no longer has an ABI for -> not listed add_plugin("02.03.00.62"); // managed, older whitelisted series -> folded into 02.03.00 add_plugin("02.01.01.52"); // managed, series with no ABI in this build -> not listed - add_plugin("02.08.01_custom"); // custom, whitelisted series -> listed under it - add_plugin("02.08.01.52-dev"); // custom (dash-suffixed), whitelisted series -> listed + add_plugin("02.08.04_custom"); // custom, whitelisted series -> listed under it + add_plugin("02.08.04.52-dev"); // custom (dash-suffixed), whitelisted series -> listed auto versions = get_all_available_versions(); // The specific managed build never gets its own row - the series represents it. - REQUIRE(count_version(versions, "02.08.01.55") == 0); - REQUIRE(count_version(versions, "02.08.01") == 1); + REQUIRE(count_version(versions, "02.08.04.60") == 0); + REQUIRE(count_version(versions, "02.08.04") == 1); REQUIRE(count_version(versions, "02.09.00.10") == 0); + REQUIRE(count_version(versions, "02.08.01.55") == 0); + REQUIRE(count_version(versions, "02.08.01") == 0); REQUIRE(count_version(versions, "02.03.00.62") == 0); REQUIRE(count_version(versions, "02.03.00") == 1); REQUIRE(count_version(versions, "02.01.01.52") == 0); // Custom-named builds are distinct files kept under their own name. - REQUIRE(count_version(versions, "02.08.01_custom") == 1); - REQUIRE(count_version(versions, "02.08.01.52-dev") == 1); + REQUIRE(count_version(versions, "02.08.04_custom") == 1); + REQUIRE(count_version(versions, "02.08.04.52-dev") == 1); // Newest series first, its customs nested under it (suffix sort: "" < ".52-dev" < "_custom"), // then older series, legacy last. - REQUIRE(versions[0].version == "02.08.01"); - REQUIRE(versions[1].version == "02.08.01.52-dev"); - REQUIRE(versions[2].version == "02.08.01_custom"); + REQUIRE(versions[0].version == "02.08.04"); + REQUIRE(versions[1].version == "02.08.04.52-dev"); + REQUIRE(versions[2].version == "02.08.04_custom"); REQUIRE(versions[3].version == "02.03.00"); REQUIRE(versions.back().version == BAMBU_NETWORK_AGENT_VERSION_LEGACY); @@ -111,9 +114,9 @@ TEST_CASE_METHOD(PluginFolderFixture, "Managed builds fold into the series; cust REQUIRE_FALSE(versions[3].is_latest); // Customs sort/render nested under their series (non-empty suffix, base = the series). - REQUIRE(versions[1].base_version == "02.08.01"); + REQUIRE(versions[1].base_version == "02.08.04"); REQUIRE_FALSE(versions[1].suffix.empty()); - REQUIRE(versions[2].base_version == "02.08.01"); + REQUIRE(versions[2].base_version == "02.08.04"); REQUIRE_FALSE(versions[2].suffix.empty()); // "(Latest)" is the series row, never a nested custom build. @@ -123,20 +126,20 @@ TEST_CASE_METHOD(PluginFolderFixture, "Managed builds fold into the series; cust REQUIRE_FALSE(versions[2].is_latest); // The stored default that drives download and update-check decisions is now the series. - REQUIRE(std::string(get_latest_network_version()) == "02.08.01"); + REQUIRE(std::string(get_latest_network_version()) == "02.08.04"); } TEST_CASE_METHOD(PluginFolderFixture, "Only the loaded series is marked installed", "[NetworkVersions]") { - add_plugin("02.08.01.55"); - add_plugin("02.08.01_custom"); + add_plugin("02.08.04.60"); + add_plugin("02.08.04_custom"); - // The loaded plug-in reports its full build (02.08.01.55); the series row is what gets marked. + // The loaded plug-in reports its full build (02.08.04.60); the series row is what gets marked. { - auto versions = get_all_available_versions("02.08.01.55"); + auto versions = get_all_available_versions("02.08.04.60"); int marked = 0; for (const auto& info : versions) - if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.01"); } + if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.04"); } REQUIRE(marked == 1); } @@ -152,10 +155,10 @@ TEST_CASE_METHOD(PluginFolderFixture, "Only the loaded series is marked installe // A loaded custom build matches its own row, never the bare series. { - auto versions = get_all_available_versions("02.08.01_custom"); + auto versions = get_all_available_versions("02.08.04_custom"); int marked = 0; for (const auto& info : versions) - if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.01_custom"); } + if (info.is_loaded) { ++marked; REQUIRE(info.version == "02.08.04_custom"); } REQUIRE(marked == 1); } @@ -167,11 +170,11 @@ TEST_CASE_METHOD(PluginFolderFixture, "Only the loaded series is marked installe TEST_CASE("Only whitelisted series pass the load gate", "[NetworkVersions]") { // Each whitelisted series, its builds, and custom-named builds of that series. - REQUIRE(is_supported_network_version("02.08.01")); - REQUIRE(is_supported_network_version("02.08.01.52")); - REQUIRE(is_supported_network_version("02.08.01.55")); - REQUIRE(is_supported_network_version("02.08.01_custom")); - REQUIRE(is_supported_network_version("02.08.01.52-dev")); + REQUIRE(is_supported_network_version("02.08.04")); + REQUIRE(is_supported_network_version("02.08.04.52")); + REQUIRE(is_supported_network_version("02.08.04.60")); + REQUIRE(is_supported_network_version("02.08.04_custom")); + REQUIRE(is_supported_network_version("02.08.04.52-dev")); REQUIRE(is_supported_network_version("02.03.00")); REQUIRE(is_supported_network_version("02.03.00.62")); REQUIRE(is_supported_network_version("02.03.00.70")); @@ -179,6 +182,9 @@ TEST_CASE("Only whitelisted series pass the load gate", "[NetworkVersions]") REQUIRE(is_supported_network_version(BAMBU_NETWORK_AGENT_VERSION_LEGACY)); // Series whitelisted by previous Orca releases that no generation here can call. + REQUIRE_FALSE(is_supported_network_version("02.08.01")); + REQUIRE_FALSE(is_supported_network_version("02.08.01.55")); + REQUIRE_FALSE(is_supported_network_version("02.08.01_custom")); REQUIRE_FALSE(is_supported_network_version("02.01.01.52")); REQUIRE_FALSE(is_supported_network_version("02.00.02.50")); @@ -198,9 +204,9 @@ TEST_CASE("Each version resolves to the ABI generation that can call it", "[Netw { // The generation is keyed on the series, so every build of a series - including the // custom-named ones - resolves to the same one. - CHECK(network_plugin_abi("02.08.01") == NetworkAbi::Current); - CHECK(network_plugin_abi("02.08.01.55") == NetworkAbi::Current); - CHECK(network_plugin_abi("02.08.01.52-dev") == NetworkAbi::Current); + CHECK(network_plugin_abi("02.08.04") == NetworkAbi::Current); + CHECK(network_plugin_abi("02.08.04.60") == NetworkAbi::Current); + CHECK(network_plugin_abi("02.08.04.52-dev") == NetworkAbi::Current); CHECK(network_plugin_abi("02.03.00") == NetworkAbi::V0203); CHECK(network_plugin_abi("02.03.00.62") == NetworkAbi::V0203); CHECK(network_plugin_abi("02.03.00_custom") == NetworkAbi::V0203); @@ -208,6 +214,7 @@ TEST_CASE("Each version resolves to the ABI generation that can call it", "[Netw // Anything the load gate rejects must dispatch through nothing at all, rather than // defaulting to a layout it does not share. + CHECK(network_plugin_abi("02.08.01.55") == NetworkAbi::Unsupported); CHECK(network_plugin_abi("02.01.01.52") == NetworkAbi::Unsupported); CHECK(network_plugin_abi("02.00.02.50") == NetworkAbi::Unsupported); CHECK(network_plugin_abi("02.09.00.10") == NetworkAbi::Unsupported); @@ -234,7 +241,7 @@ TEST_CASE_METHOD(PluginFolderFixture, "Legacy series never adopts discovered bui // With nothing else on disk, the series holds "(Latest)" even though its library is // not installed. for (const auto& info : versions) { - if (info.version == "02.08.01") { + if (info.version == "02.08.04") { REQUIRE(info.is_latest); REQUIRE_FALSE(info.is_loaded); } From a56d1bf33e81d7081e4e3464cdb71a43157eeea4 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 15:51:49 +0800 Subject: [PATCH 17/22] Keep a Project's Changed Values on Extruder Variants It Doesn't List (#16107) A project's listed settings are carried onto its base preset by update_non_diff_values_to_base_config, which matched variants by exact name and id. A variant the base gained after the project was saved got the base's value, while the same value in a user preset now falls back to the preset's first variant of that extruder. So an old project opened with its printer preset already modified, and saving it wrote the base's values into the 3MF. The function now maps variants with map_variant_indices, as update_diff_values_to_child_config does: a base variant the project does not list takes the project's first variant of the same extruder. The variant lists themselves stay the base's, so a fallback never writes one variant's name over another's. --- src/libslic3r/PrintConfig.cpp | 28 ++--- tests/libslic3r/test_config.cpp | 104 ++++++++++++++++++ .../libslic3r/test_preset_bundle_loading.cpp | 5 +- 3 files changed, 122 insertions(+), 15 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 832ff9b3b4..c9bd957ab1 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -11520,12 +11520,18 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi int cur_variant_count = cur_extruder_variants.size(); int target_variant_count = target_extruder_variants.size(); + // A base variant this config does not list (the base gained it after the config was saved, or the + // config lists none) takes this config's first variant of the same extruder, as a user preset's + // values do in update_diff_values_to_child_config. Left unmatched, the base's value would silently + // replace the user's. variant_index.resize(target_variant_count, -1); if (cur_variant_count == 0) { // Defensive: target_variant_count may be 0 if the preset doesn't carry extruder_variant_name. // In that case keep variant_index empty and let the downstream size checks produce a useful error. if (!variant_index.empty()) - variant_index[0] = 0; + // This config's one value belongs to the extruder of the base's first variant. + variant_index = map_variant_indices(target_extruder_variants, target_extruder_ids, {}, + target_extruder_ids.empty() ? std::vector() : std::vector{target_extruder_ids[0]}); } else if ((cur_extruder_ids.size() > 0) && cur_variant_count != cur_extruder_ids.size()){ //should not happen @@ -11538,18 +11544,7 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi %extruder_variant_name %target_variant_count %extruder_id_name %target_extruder_ids.size(); } else { - for (int i = 0; i < target_variant_count; i++) - { - for (int j = 0; j < cur_variant_count; j++) - { - if ((target_extruder_variants[i] == cur_extruder_variants[j]) - &&(target_extruder_ids.empty() || (target_extruder_ids[i] == cur_extruder_ids[j]))) - { - variant_index[i] = j; - break; - } - } - } + variant_index = map_variant_indices(target_extruder_variants, target_extruder_ids, cur_extruder_variants, cur_extruder_ids); } for (auto& opt : keys) { @@ -11574,6 +11569,13 @@ void DynamicPrintConfig::update_non_diff_values_to_base_config(DynamicPrintConfi if (cur_variant_count > target_variant_count) continue; + // The variant lists are the base's layout itself, which every other value is + // carried onto: a variant this config lacks keeps its own name and id. + if (opt == extruder_id_name || opt == extruder_variant_name) { + opt_src->set(opt_target); + continue; + } + int stride = 1; if (key_set2.find(opt) != key_set2.end()) stride = 2; diff --git a/tests/libslic3r/test_config.cpp b/tests/libslic3r/test_config.cpp index 553e94b1c0..738e8539d2 100644 --- a/tests/libslic3r/test_config.cpp +++ b/tests/libslic3r/test_config.cpp @@ -538,6 +538,110 @@ SCENARIO("update_diff_values_to_child_config keeps a child's values on variants } } +SCENARIO("update_non_diff_values_to_base_config keeps a project's changed values on variants it does not list", + "[Config][Variant]") { + std::set no_keys; + auto variants = [](std::initializer_list names) { return new Slic3r::ConfigOptionStrings(names); }; + + GIVEN("A filament base with three variants") { + Slic3r::DynamicPrintConfig base; + base.set_key_value("filament_extruder_variant", + variants({"Direct Drive Standard", "Bowden Standard", "Direct Drive High Flow"})); + base.set_deserialize_strict("nozzle_temperature", "220,220,220"); + + WHEN("the project was saved when the base had only its first variant") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("filament_extruder_variant", variants({"Direct Drive Standard"})); + project.set_deserialize_strict("nozzle_temperature", "199"); + + AND_WHEN("the project lists the value as changed") { + project.update_non_diff_values_to_base_config(base, project.keys(), {"nozzle_temperature"}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("the project's value applies to every variant") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "199,199,199"); + } + } + AND_WHEN("the project does not list the value as changed") { + project.update_non_diff_values_to_base_config(base, project.keys(), {}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("the base's values replace it") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "220,220,220"); + } + } + } + WHEN("the project lists every variant, in another order") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("filament_extruder_variant", + variants({"Bowden Standard", "Direct Drive High Flow", "Direct Drive Standard"})); + project.set_deserialize_strict("nozzle_temperature", "190,205,199"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"nozzle_temperature"}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("each variant keeps its own value") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "199,190,205"); + } + } + WHEN("the project lists no variants") { + Slic3r::DynamicPrintConfig project; + project.set_deserialize_strict("nozzle_temperature", "199"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"nozzle_temperature"}, "", "filament_extruder_variant", + Slic3r::filament_options_with_variant, no_keys); + THEN("the project's value applies to every variant") { + REQUIRE(project.opt_serialize("nozzle_temperature") == "199,199,199"); + } + } + } + + GIVEN("A two-extruder printer base with two variants per extruder") { + Slic3r::DynamicPrintConfig base; + base.set_key_value("printer_extruder_variant", + variants({"Direct Drive Standard", "Direct Drive High Flow", "Direct Drive Standard", "Direct Drive High Flow"})); + base.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 1, 2, 2})); + base.set_deserialize_strict("retraction_length", "0.8,0.8,0.8,0.8"); + + WHEN("the project lists only the Standard variant of each extruder") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("printer_extruder_variant", variants({"Direct Drive Standard", "Direct Drive Standard"})); + project.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2})); + project.set_deserialize_strict("retraction_length", "1.1,2.2"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"retraction_length"}, "printer_extruder_id", "printer_extruder_variant", + Slic3r::printer_options_with_variant_1, + Slic3r::printer_options_with_variant_2); + THEN("each extruder's High Flow variant takes that extruder's value") { + REQUIRE(project.opt_serialize("retraction_length") == "1.1,1.1,2.2,2.2"); + } + } + WHEN("the project lists only the Standard variant of each extruder, and the variant lists as changed") { + Slic3r::DynamicPrintConfig project; + project.set_key_value("printer_extruder_variant", variants({"Direct Drive Standard", "Direct Drive Standard"})); + project.set_key_value("printer_extruder_id", new Slic3r::ConfigOptionInts({1, 2})); + project.set_deserialize_strict("machine_max_speed_x", "300,100,400,150"); + base.set_deserialize_strict("machine_max_speed_x", "500,200,500,200,500,200,500,200"); + project.update_non_diff_values_to_base_config(base, project.keys(), + {"machine_max_speed_x", "printer_extruder_id", "printer_extruder_variant"}, + "printer_extruder_id", "printer_extruder_variant", + Slic3r::printer_options_with_variant_1, + Slic3r::printer_options_with_variant_2); + THEN("the variant lists are the base's") { + REQUIRE(project.opt_serialize("printer_extruder_variant") == base.opt_serialize("printer_extruder_variant")); + REQUIRE(project.opt_serialize("printer_extruder_id") == "1,1,2,2"); + } + THEN("each extruder's High Flow variant takes that extruder's pair of limits") { + REQUIRE(project.opt_serialize("machine_max_speed_x") == "300,100,300,100,400,150,400,150"); + } + } + WHEN("the project lists no variants") { + Slic3r::DynamicPrintConfig project; + project.set_deserialize_strict("retraction_length", "1.1"); + project.update_non_diff_values_to_base_config(base, project.keys(), {"retraction_length"}, "printer_extruder_id", "printer_extruder_variant", + Slic3r::printer_options_with_variant_1, + Slic3r::printer_options_with_variant_2); + THEN("only the first extruder's variants take the project's value") { + REQUIRE(project.opt_serialize("retraction_length") == "1.1,1.1,0.8,0.8"); + } + } + } +} + // SCENARIO("DynamicPrintConfig JSON serialization", "[Config]") { // WHEN("DynamicPrintConfig is serialized and deserialized") { // auto now = std::chrono::high_resolution_clock::now(); diff --git a/tests/libslic3r/test_preset_bundle_loading.cpp b/tests/libslic3r/test_preset_bundle_loading.cpp index 7dfba69cbd..e2ff2a2322 100644 --- a/tests/libslic3r/test_preset_bundle_loading.cpp +++ b/tests/libslic3r/test_preset_bundle_loading.cpp @@ -6228,8 +6228,9 @@ TEST_CASE("A per-variant project value maps onto its base preset's variant layou base_finder(&base, calls)); CHECK(config.option("print_extruder_variant")->values == std::vector{"Direct Drive Standard", "Direct Drive High Flow"}); - // The listed key keeps the project's Standard value and takes High Flow from the base. - check_double_vector(config.option("outer_wall_speed")->values, {100., 300.}); + // The listed key keeps the project's Standard value, and High Flow, which the project does not + // list, takes it too, as a user preset's value does. + check_double_vector(config.option("outer_wall_speed")->values, {100., 100.}); check_double_vector(config.option("inner_wall_speed")->values, {250., 350.}); } From ff8aebe76f0c700305e9fea04fa15ace5bd4b321 Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 15:52:18 +0800 Subject: [PATCH 18/22] Allow Unsigned Executable Memory in the macOS Entitlements (#16203) The Bambu network plug-in's code protector rewrites one page of its own signed __TEXT after loading. The hardened runtime tolerates that until the page is evicted; the next read of it then kills OrcaSlicer with CODESIGNING Invalid Page. Bambu Studio signs with allow-unsigned-executable-memory for this reason; with it added, the same build survives critical memory pressure that killed it in 30 s without. --- scripts/disable_validation.entitlements | 5 +++++ src/dev-utils/platform/osx/entitlements.plist | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/scripts/disable_validation.entitlements b/scripts/disable_validation.entitlements index 123d12a53e..af12034ce0 100644 --- a/scripts/disable_validation.entitlements +++ b/scripts/disable_validation.entitlements @@ -4,5 +4,10 @@ com.apple.security.cs.disable-library-validation + + com.apple.security.cs.allow-unsigned-executable-memory + diff --git a/src/dev-utils/platform/osx/entitlements.plist b/src/dev-utils/platform/osx/entitlements.plist index 59274f955f..5ba7ca02e3 100644 --- a/src/dev-utils/platform/osx/entitlements.plist +++ b/src/dev-utils/platform/osx/entitlements.plist @@ -5,5 +5,10 @@ com.apple.security.cs.disable-library-validation + + com.apple.security.cs.allow-unsigned-executable-memory + From f9ddb23804e3a03cfd300fbeb909dc7f276e9eaf Mon Sep 17 00:00:00 2001 From: HanifKoh <76276251+HanifKoh@users.noreply.github.com> Date: Wed, 7 Oct 2026 15:54:53 +0800 Subject: [PATCH 19/22] Keep Each Filament's Device Drying Values When the CLI Merges Filaments (#16157) The device drying options hold several values per filament, as many as the filament preset gives, and a project stores them as the filaments' values one after another. The CLI filament merge wrote them like an option with one value per filament, putting each preset's first value at the filament's own index, so a project with three filaments whose preset gives "1", "0" was exported with 1;1;1;0;1;0 where the GUI writes 1;0;1;0;1;0. The merge now leaves these options out of the per-filament pass and rebuilds them afterwards from every filament's values in slot order. Without a fixed number of values per filament one slot cannot be replaced in place, so the stored values are kept when any slot has no config to rebuild from. --- src/OrcaSlicer.cpp | 11 ++++++++ src/libslic3r/PrintConfig.cpp | 16 +++++++++++ src/libslic3r/PrintConfig.hpp | 5 ++++ .../test_config_variant_expansion.cpp | 27 +++++++++++++++++++ 4 files changed, 59 insertions(+) diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index a2e4e20374..7104d1bbcb 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -3618,6 +3618,9 @@ int CLI::run(int argc, char **argv) { if (opt_key == "compatible_prints" || opt_key == "compatible_printers" || opt_key == "model_id" || opt_key == "dev_model_name" || opt_key == "filament_settings_id") continue; + // rebuilt from every filament after this loop + if (filament_dev_options.find(opt_key) != filament_dev_options.end()) + continue; ConfigOption *opt = m_print_config.option(opt_key, true); if (opt == nullptr) { // opt_key does not exist in this ConfigBase and it cannot be created, because it is not defined by this->def(). @@ -3681,6 +3684,14 @@ int CLI::run(int argc, char **argv) } } + // The stored values cannot be told apart per filament, so they are kept as they are unless every slot has a config. + std::vector filament_configs(filament_count, nullptr); + for (size_t index = 0; index < load_filaments_config.size(); index++) + if (load_filaments_index[index] >= 1 && load_filaments_index[index] <= filament_count) + filament_configs[load_filaments_index[index] - 1] = &load_filaments_config[index]; + if (std::find(filament_configs.begin(), filament_configs.end(), nullptr) == filament_configs.end()) + set_filament_dev_options(m_print_config, filament_configs); + if (m_print_config.option("filament_extruder_variant")) { std::vector& filament_self_indice = m_print_config.option("filament_self_index", true)->values; int index_size = m_print_config.option("filament_extruder_variant")->size(); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index c9bd957ab1..59a01bc5ff 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -10822,6 +10822,22 @@ void normalize_filament_values_to_variants(DynamicPrintConfig &config) } } +void set_filament_dev_options(DynamicPrintConfig &config, const std::vector &filament_configs) +{ + for (const std::string &key : filament_dev_options) { + if (std::none_of(filament_configs.begin(), filament_configs.end(), [&key](const DynamicPrintConfig *filament) { return filament->has(key); })) + continue; + const ConfigOption *default_value = print_config_def.get(key)->default_value.get(); + auto *dst = static_cast(config.option(key, true)); + dst->clear(); + for (const DynamicPrintConfig *filament : filament_configs) { + const auto *src = static_cast(filament->has(key) ? filament->option(key) : default_value); + if (!src->empty()) + dst->append(src); + } + } +} + //used for object/region config //use the smallest of multiple to single diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index acf6bd5335..beff23933a 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -928,6 +928,11 @@ void normalize_filament_values_to_variants(DynamicPrintConfig &config); extern std::set filament_dev_options; +// Orca: a filament_dev_options option holds several values per filament, and how many is up to the +// filament preset, so one filament's values cannot be replaced in place. This rebuilds each option from +// filament_configs, one config per filament in slot order, as the filaments' values one after another. +void set_filament_dev_options(DynamicPrintConfig &config, const std::vector &filament_configs); + extern void update_static_print_config_from_dynamic(ConfigBase& config, const DynamicPrintConfig& dest_config, std::vector variant_index, std::set& key_set1, int stride = 1); extern void compute_filament_override_value(const std::string& opt_key, const ConfigOption *opt_old_machine, const ConfigOption *opt_new_machine, const ConfigOption *opt_new_filament, const DynamicPrintConfig& new_full_config, t_config_option_keys& diff_keys, DynamicPrintConfig& filament_overrides, std::vector& f_map_indices); diff --git a/tests/libslic3r/test_config_variant_expansion.cpp b/tests/libslic3r/test_config_variant_expansion.cpp index 240a6e25fa..0df6eb976f 100644 --- a/tests/libslic3r/test_config_variant_expansion.cpp +++ b/tests/libslic3r/test_config_variant_expansion.cpp @@ -799,3 +799,30 @@ TEST_CASE("A per-variant filament option read with a single value gives it to ev config.load_from_ini_string("pressure_advance = 0.021", ForwardCompatibilitySubstitutionRule::Disable); REQUIRE(config.option("pressure_advance")->values == std::vector({0.021, 0.021, 0.021})); } + +// The device drying options hold several values per filament, as many as each filament preset gives. +TEST_CASE("The device drying options are rebuilt as each filament's values in slot order", "[Config]") +{ + DynamicPrintConfig two_values, one_value, no_value; + two_values.option("filament_dev_ams_drying_ams_limitations", true)->values = {"1", "0"}; + two_values.option("filament_dev_ams_drying_temperature", true)->values = {45., 45., 55., 55.}; + one_value.option("filament_dev_ams_drying_ams_limitations", true)->values = {"1"}; + one_value.option("filament_dev_ams_drying_temperature", true)->values = {65., 65., 75., 75.}; + + // values a project stored for three other filaments + DynamicPrintConfig config; + config.option("filament_dev_ams_drying_ams_limitations", true)->values = {"0", "0", "0"}; + config.option("filament_dev_chamber_drying_time", true)->values = {12., 8., 12.}; + + set_filament_dev_options(config, {&two_values, &one_value, &two_values}); + REQUIRE(config.option("filament_dev_ams_drying_ams_limitations")->values == + std::vector({"1", "0", "1", "1", "0"})); + REQUIRE(config.option("filament_dev_ams_drying_temperature")->values == + std::vector({45., 45., 55., 55., 65., 65., 75., 75., 45., 45., 55., 55.})); + // an option no filament defines keeps the stored values + REQUIRE(config.option("filament_dev_chamber_drying_time")->values == std::vector({12., 8., 12.})); + + // a filament without the option takes the option's default + set_filament_dev_options(config, {&two_values, &no_value}); + REQUIRE(config.option("filament_dev_ams_drying_ams_limitations")->values == std::vector({"1", "0", ""})); +} From a38e6c61f228580fef12b960f189525a7c711c31 Mon Sep 17 00:00:00 2001 From: yw4z Date: Wed, 7 Oct 2026 12:57:28 +0300 Subject: [PATCH 20/22] Show dummy image for printers without cover on printer selectiondialog (#16235) init --- resources/web/guide/21/common.js | 2 +- resources/web/guide/img/printer-dummy.png | Bin 0 -> 17611 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 resources/web/guide/img/printer-dummy.png diff --git a/resources/web/guide/21/common.js b/resources/web/guide/21/common.js index 9a3c76c248..d0cc510540 100644 --- a/resources/web/guide/21/common.js +++ b/resources/web/guide/21/common.js @@ -311,7 +311,7 @@ function CreatePrinterBlock(OneModel) return '
'+ '
'+ - ' '+ + ' '+ '
'+ '
?
'+ '
'+ diff --git a/resources/web/guide/img/printer-dummy.png b/resources/web/guide/img/printer-dummy.png new file mode 100644 index 0000000000000000000000000000000000000000..279f80a827c8073eab6c6ea576a4d42c103824b1 GIT binary patch literal 17611 zcmb`v1yohr|1U}j8>FR_+BDK#(%lUr2-3X)Hz*C#BHbbl(kLY$CEXz1-604_2vTqE zbI$MF``-Bf-?;DI#~2(@)>?bcx#s-NPt6mqsjh&7^#}_I2?<9@QC1uLd4%|epo9O4 z>+QyaKQLVspSdC--G6}iMn?LOPKJbpo?xeI;AWtvDq`Ub<1n*yHn-yNfVqIHk&r|s zJY38y9IV`+=2kX#PGYo&jV-iLJ4-Rzr~GPMYA!NXwswkMa4Q`zbzKWD2Mb|KS_yHe zsD}u60L;qG4C(=MbaEB(5TpI;xgy|a#6NS=LjStN%|VP-3h{wZ12s*kj5FK{%FV^W z#csjH#RU}<=CI`9vf>jE;N@b2@^JC+b8_==atX6@@rZD9i}3J5|M{W?p9r_K7SWcK z|L60--^6Hb-P~M6I62+j-8tNOIh^4(oZP~~!kk<@oIE`2;0ktEPbW7s4|XS4y8k>u z*2>iaZs+1==j;SUJkiYD`IVa(EoklE-GI6L`&cK}e})PS8mEVu3nw=R7ouDLxlm2* z|NT-J?BA#{)Te&*Ff?HUD%jy2}QLb)suR#<4>Foc)&2q1; zoZSAs-O}RUdtF|^9se38OAAgbM=Kb(%oX&C``>oD*gCs8yV^ScH-qr+um2qi7ZDk_ zm6@9}T-Vvz@jq``^FL34@(6Npb3vJ(+BsP|ySqL{^yr^EtYppHti))+I~QQ*=3?g( z(BM~q{NFAGlg`r2&Fp{WVl_1p zB_~%mGbalxC0Q|A&?pW&J4+FBE*>5WYhGS<3o9!wc42-#Zgz7sOFnipegR=#E^7e+ zEli}f);g%8R=9cG{;^yL!krk8@;Nj)r=8=~B z&%GLOJFwEs9RK&8VQC>^?F@&Rfhl1JGqbVcbaAqwh5q|$L}Z*Do#9~M!07TKW@NlxoC}|LzmuFaPc|R!(4`;9wuQ>FAt6LK0h2l9kf+NI&rXt@GS2*(!d? zCO-CkCpoe-$|^(T^S=2K{bF6cz1_@==-u$y#qf;O<#XqmsKpnry)CS3y$h@hOG+p7 zCinCQl7gEg4KOi-e=~9`#V?TysGoZe>IlS3qKx@6t%aar_IamzF1fdO4~q#pd3vVG zNlN0Unuh&BgFqlll+UL~Bugi&Xo>Yp^=iL-`6!U88g5j^XKUrY$Rz6 zgyBjYDV&dq-Z6yBniF7!oPYiLRWnOO3X(l)n;X*_7reQ-`L({j{>$j-DCL6(59H+Y zxcfHYl|mG_D)fY&%y9H`O1~C~@0;-O1t-Df_2V}qYypxh7&*jPA>!iVel+6ZCWV^J zBvw4BTJ(g^?x6%cnV43@7lWb|tejj5$;im$Yh;Np3JMCQ&=X;$@IM;zFfm!m*x1;x z%hxW(K)&?(md41{`}1|9r&FDgW%cX^Xh54OR}l`n459x1<>jSn;dtL~uVyxmlnC-S zDlAEll9cnKrJTy<7~>Qz*Ik5eHCu4e;zGWDQZx_ohKTX;=`PI8dAa%dnPem<7qGLl z!-fV2DH4_Qw|;w?qzo{)2vKNP&zA8$iVBAc=({EKeXN>4fTs*}b^jRNK9O>|->aHn zRIJNE%T_22-|jYMm*NW<;Z`$^=*soDI9l!d_U&87qbTdo4Gj(45)v)W)xXOj%^B*2 zz4kRMlGb^nMcrmRsV<#QC~&!@;R0zm=H6ZAm6*ZSWpiF-8|IZW{p-g~XCZ^n0t<_=z`&N@aH%E0&Q<0usrf4;usmSDt(B*#$}652rprQu?|(Xr2=_+O=c z*+;Q(XpXkbU0f>G_9jcIx3{KE74`KR*aVYkTkIQN7`2`4jb_(GY^liJHK1*ZZv+KoM3=?aYG!|5&q|f zu4)6)$4(MKXeM+%r<*K_Y}PQoyRpLCx_)c`MvO6`FPV%+ID>(y=72vC-yF-<08ei7oi?Ewb=*JMgr2}~NdB2#_$-@Nw_bD?Ksq{SG~kk~r&62=Xa35=zWIJ%bJ*&l*{Km1oM7s#6)j{b`KLV!=+i0MC|SD zAIbP~jABougGolIpshW|7SXkb^BHEumh6$Cp3+cJ5nDWI@A~J@ALU@_90@_eI-Bk9 z8J~7{ch_^8-}TDqJ|I)W1gq2&1DE3K(vU?q`$x-(Ha1laLB4?o+ zAjArxYH|Vt+H-Nsnrf&lD#cUdfFymGlarGHzOK%^e0|i_zxOURdpj3R+Lvt*+{1ZH z2g7z0NZW|u{B}{^`1-)!&ery8Eme(p4Dtq&`%nklNZ}9a=7%_#nLTPVw{8YfIPXM-g*}_f%J%#66k^m1K7Ld^n6Ep; zoA~yVSTdeDWgyDAeD%LJYPdq^;)Tb#8|=2H)&5AOOYy1ilKH%v+>K9FYMqg z9fEbs^mDnz-w{-Z-@S2k%j;*5v&#^=+}HQM!8iMdD|l`%dL(YC9qNPf9#c!lq^GCn z1O^61tE6z;Y@eQNVoBnKkb$saeyD=+W-1kr8nPWsQ zrIyl4ety0seT**4u zIOrR+kgI+_&QHpvT;gvy<(uU-B``^)d z_$#{8Jo}_C5=Y{4)4C@nCT1+@PO~Z>7E47VG#P>h$JqC2FRqQ^SqOi?T z2%-P^tWC??S1lDq^jso#vb3W{PhXgViSh(|L9aS6p0SbStuA)H)7E_Ggc04@*?G^J zlrUX*RK9md+ORKvJdh-Kg9{x$qKmZ#X4xy{wBP*L;*DAQoH2ZuY+ZGknh5z~2%Fz^Lm&K^ zS_2b_3!Nqnd(N>OOHTJ4c6WR8l$@MgV|!~Wna*hFot7+X0BX+K{F||;p7qtyS?iW% z&b5=v+nQL3d9>y$#{y83hP;A;3YEBz z2MaH+E7FyRJ~pjAW|O>2?0rK}u%Er`tEh`Ahml9gPcAGxCn+!nvOy-y*;ztcU;j0p zecf-&n%{@Zca5Aa*T0-c4}FhT+Lo)$@hjC$-*COYZ$F=!nwq!6_aQa4PjYsMqO^JJ?+eCa0soV1|G-l>GVgXED&6nBpC1fn>o0LdVBrV`GfNnPOMYHp7`W zbGCfwKK;;-p3~c8Y%&Y^bFr*&a!3 z0YzhkJcf3@QE-=*4#d?~is+*CP9c{93tH3J*_q#dwu}q~e566_#YSJki=6Pg)s8Ug zZv(DG#Kf=2u+eA1Ac?SsB0h?w6>DK+#3ir1-1%x|#-Pp1UxJR#LY9rhd$qFb9SuIp zgJ2v}|HSzCTxSP|C(&XDUVcxRiA1z@beOWYL(LP3=@4xx{aLcNxA$axe0=A9zwzOr z1K$U&xAJBBrT_e%bz^JmoFz%wTSH?w^X%3MY_uQe52D9^oINfhLq@a|+2jR)pJE9K z3G*wmRZEV1F+D*!s5D&2Qbn<;sk6>?^PUy*hQo*9UFPq}XGR})y(2)hjgpX%aH}%j z9NzKdi_D`zYgZIjc|^Bfzd@$1iDxYT?d~a>iL&0_ivzqQV>;1{5CKM(6^@GLHM#oC zyHJ;fbZve86;_D35=+ttz!=0hqCMKWupj{)NC12N0`r58^ToHatz!?9$i9V23xx>j z9IjUC)ZuM!P*3!qM}y_h$K3GUfX?y^ z*lJCGY8I6znOcD61q1HGUL!*R;IS`2@^)bJb_O^>-@ssofh6L<;l}qmbI~a!b;vq@ z)E2E0b%TnWoV6XN?Z+9sg7$uhbfI=}`fz{$qgFIYfW_t)Sm|c4@KJbMH{oI`Dk{hR z7ai2M6s4r%8=z}iEJ^0~s?A?56t!&rzM93O78f0#oqeXGt28u@n6 z&KTgM=;VoV^~2$Co+sSgFUXu|W$)%MhE!E+ z!f@I1GeR>nGaA$lF`tX0L-&KZ$=cEBU_H|95E-y7R2r0-_$+V2j~g2r_CBPg#aP?I~N252IIj6ItB(S!BRnCVT@VQ@;))a z6%4>t+(2(ps!{7(_P`;9!3Xb$tT~@#s4MyV`&-%B**)ovI1EypiC9xqR{ns)aXfSI zI(*Vz?}KWAtVr=k0CGda!raZ0I)*XPPy~~7$4YfeT1%qtg7yKKiujl?ydB}-=y;tt zWPMefCHLAh;2Xh;!vgf^`5}3gg!g&bxBUD~NY=3X@uiOhW)>Yaw}xr(uvfGA!`VfE ztukw_aZ?7)`ZwVZZ~=aA^BLTPV>$|u$1AgxO#vQx*w)r&tX}wlMmTL?lf$BA$hz9M zCx-eiu**Cg>`4OW#TT>1#l=2lgHCl%j&9#H0gM%VM0o|rr|>rM!7CL24{whCLJ}b- zE+&?-JUKa8QBje-RBbaHw6L&Xv+RF&fuM|I6V7DgOvCFj#fl^07$%{N1b{ zI6}9D85#U(`Ui1$SC^+S#dq(JV(0slfPdg9z~NQ;94SVCZLm~Kn;dLca(2hX##XeN zSN_>Oyz&tjfT)HX&ZJqq$V95DHYh`S_L99fy)ZvNik_Z+kdc8wjWtOb^+Z_UhX`gZ zNpLHhK1JG4cYlayve9|lxrgWsQ@J-@|EkNicJV|Y9ca~_?{^vwj_-HkEgJY$GtTCmgYRfOnwQ)uv(@k!-(C`vJ=_F}LotBG$3}HdzR7@{s3rx+G6#Mmdu3w8 z$B&mC94xy4z`BH7(NGzTPUZVo>niCmVe`z^-cES^^SjYJ1^>U$6$KgDOvn*YK12C5 zc`q3#3gnBTZwxta^Tl_V4~1weJ&~p}5)w{O?z+Ui01irM*!sHSAdeZ@uq6p2&rR0M zl4zqQI6*6jH=rmJvaj)4I{bYies_Ix7mmj(OQDEA`e&`HOO6kZsPQ=m&Bu4K`k%){ zk#_TuHz~!l?&h`vG~=nZqh+VQXFPclpOC<0l0wmeJlf;%`Pp!jbVC3bgrt6^C zeT+t_!xu5nZ;MM$7ah8O2#TG|$(t_o%Y?0frKKhN{rtzf`3WV9==!iS^9iibxld6; z)-C!^apHPLMl^SOdwbP^Gy;&!79>R46%ai|Ev?b&iwlp$A_11T^QjH8NiG_>`Y6KB z(34M~P|h#S&o|B=ydH<^FiC?Ui}vDQ+)|t_Jz$=Nb$ULyegX-Y#w_FV5%b`d1RH_xjpr zYG=n5lgQx|hg*ogrv+4$+*AzUWa5L1vIjU3V^ahMY}LA=K<*vX5VO~I+^-p zM9Ra%6Dp}HLdOCt_4rfEfOmEP-21G-H;$*9H|P8P0|C}x z(?^#CO;o|HIXyi3&nC>Y0?ovaE{@lA#IrOmF1NGpP(HmCbY8mNzrDGlrfZYCQ&mz@ z8pwF!E-pXwu*s_hXU9@H5VMchGP3eeHil=fz88O-7MHn3(#dl8g^i{p{v&*pFl0^Z zwi2>3HIwJh2U!5&5BW9v#eVFl9eWq%5^MaEE8>AeRHzvs!=mIjI(WAD(=fr_f?gdjhEhA4uc>>fJL z*M0)9rI5OmvX`)oDRi0mRftHax8{*(4K z4~K?^dI|~(;OZG7XJQ3P6}i~5y_EvswbCF+*rfd#wxZX`*3hsVZQT7&J~Mabc*Wzp zg!qA(K*4xAm@FSSgG%G_o)&DHe?VJW3=IqvGv2>ve)AROybctGIe;yxfBpLPM=?kg z8C;0ke!DWtfriGXNEq=KrJyhmHg6@1$1n1VO)Wl$LUqB1(C|GP+PFN~ zzEdinW>N!kA{!f;$KVNn@Ene=}mERIO=mqHXxr>Aai z^z1rYF385*qU9qFsyGx(Z+Y-h6p&&am6eo6m%hGSALi1(=WWiBav#P=9(wH3Ra8=9 z?*vE;$(}32jA1OB8yeDgVo=$yS}-v&PbzBKj`&J!1e}0~ScA|mX`CGc@r9({SWW_6 z#kqdbNtM`9_~lw>i&k{pIZzWYa>OM9N5JM0h(v9>A5Jad=ObS@&H(06Q*A-P*3UGa zQM6GU=@p2KukTG1(7L~{KK*=6RI{hc8)LdyO7_xl$c-38m7 zm?pMm@kJ1=%LOI}NtqScHyVL(jh1td#sv)}|05V)YH438v>Xh~oc~>_8d=0})aXIQ z$?06*BZA!KO~ZnT-60tJvN;%Sw{HR^P*GZ!kgPK#=9gDr@2X33AB!r!(pzPe7FLKS zChh+@msYiga03}_{>Rxbz>_fqb*W;u!y_V2)|WN2$fYiV@I4~T_#Ww1S62%IadN!Sf1NyzZ_I-orGLeV|zo}fG@13wIqzf@4^ab4deDR1UV=NJI$MglxHtg~16!5EN$ zI*6;QYwD*@pTaxKm$J?JP<8Yyp)+h(fBLx#O~dwUBn9DjW5)$F)H z1VndZKrAG80A`H!mI7^5%Gc(lqO-m?iXpwC)(H^ic^DpbW+kW(fZQ&X6&2Zu~8Pf@y{jAH^93$UfHyLH#dlA}dScVpM_ph6PxcEu;Pzf~dv1 z_J6}InS{Veom^z@uHeeOv8MGOgq3;KQ!jBqe_$l*mSj%iBOo0pNv7BP2VuCkdA{GE8 z77lE#t#4oWe0$19LKjznQCzG?9?n-br>~7N54zC81m3*@}v&-Dt@F< z0p1@$INy7m(4Sa&c)_iQ0f0@Wd;k8KVf_5LYDsZ%{R=(4SJXMItXKiRk|d!cfcfoj zh5?p%b1TF`k4HaNgzXtW>!_Zdnfcwd{yC)YnJCq83=b*dJ=a&+2Q4U8+?%eIa-&~? zEMZHpxFd;I0IydeQ{1=ViI|x0uajYkJBhx&K3*VozGVdRju0>lt)H6iK%!;H$ci?{SxlD@A>CQ=tgJ!nD>ZvD|YGBWZVF-OtEB`#KiN`bTF zCB0W#idw=$6=Rb)u-OgVn((^G+9>&TW!U`safK@!t|>t0feOgZTi~jnf{o7ttg-rg z_wIo?{(0poZY7P1zU!ylU}~XBkW}?-PO5h!)PMl6cr<& zWAy^++XQG=Ps`1L^IiJDrWeQauSWwx7D+U@(+UwGKq`+*-P z%_|jwwmMkGET;+-5Y}^*=H_NSUtizG(Pa1inaTmM`R+r`>Is_2XB=xug(JZDzF=l& zKfuQd`3aZ{mVP2_0j47tnJ)er$RkkC0f_1@Bh!IX|NPsQxN+c7$FE;Jj^PW1>KP4* zDJj!;Yh4k4HaD%lX2>#_$G67by?XU(k{{d{B>#JVwpy?jHeXA-$MkleK3O`aBA|&c zN6SdwZRnkJCq)48%Eu3Zd-vMfn(cB5Pm?tB=o4A7IHI} z*a-1TJlipnkDzPFF(7yc?4GJvu)jZk;eT_soWth^o^%La!ZF{(wp_*K(bdiK5NR`U zP^#P$t?(Pt3Dp>N0`*IWs2@IjEbGtHx_$Bt82iXf8Z+1CT?M_cHyUL7ejQ@k5h5rW z>grn@Y;5#KY$PvVzC5l5ISXpjKO}o6v^&pGA*eUp#N#le0_wCE*#Ti0V+KTA>s&BAN-l!^iMhwz<6EH{pUcS`g1zQ=HkdVRH^z>70;NaH-eb}L5Yw_L5 z^RtC#1mZS3VC(9+y1H`j?CE(jVtMy#b08E5vD4p&hBirnePYk|0dtTPYcoQ%LI4{F zhqwc>{NoG@2y(0xB5%Pqd_PP%->@@RQ%~>A6tEtE91b*}K7Gotpg5c^d~!!msHE6# z@AQ$SSaNJ?YKl%EEvf~G1KR+r3W81L5@2m=U44D=09nGA4tFJb!g}ryQ{of&18z<{ zF|gWE2#EA+fc5+h)D2^Vk9E%tzp@=4QG1~d-Y?=2BDjvd@3^XLG-0rTfjtuCXy~o{6Vqf`Pt6z#gjYSj`?9 zxRKi0Jh@0QGf^ipOp7GtG?{qQyJ4pGOTl0ikpubZ>+j#cGXjdKW>Fr|3_BV&drKO8=KO7nDYWji%fEaT zlcpk~aM^F5px?g1^e>-xF#V_iIx-20xGR9BvvP8B#vt9qM?+&qRk}4_fU+_Ka$NrA zCg00ww6`{yxzW&2Kwjl?LX_s(mpW05ClzQ#<4qJgNEUuvzb7ViIUW=d$V-5KozoMSyf}Bt&1SkLq-KQ8p^L2OJM%+%Q*Jpo&x)ut}R{gW|TyO3D}#R@}^?Kj>+{)*SG`y0n6hoXsA)4ZnDghaqGrsF)=kbz&aCmTV z0|ys3nYRGNw5i~srTO5mQH%2Xj~D0Pc9qefy9=6q6&xI>wAZ2W#e_$dEgRjH zQ-|h~&=)r`os$LKHP0FgzIG;#FmHh0H2?l;0n99P-TM^`X5W+Aqqx)K4G?-9y@rCk zJe=^s1GOF7JnHph4`%*Z5YFPW#*7p^*&Q!DJ2*H91N5K}?9A0*v7BG^LgQ?eRaMh_ zjth#BpaMJ-H#axLk>S4wz;}QzhnPtMZSp#-vwa8|!~X3B+xW6VJWeTLLmt^lFxPAP z)JKEt?TeXMeeAj$k|`~*40u;<3&8!m1@FBO*gSQl#KdP%=Qg(|00Q<&_r$6fsz@<| z*Xhe?`&rjug8-0{a)3G|n%Y3#s1z(pOt0QJXudzX5pUB|;4n44r{`Kyr7vb=WE=yr zy`P=o52gimLQZOnktRB?(7cj|$HoYWgytVUIBbTJ=qtUOIqmeeEMj*icL^1w2=S+A z<4qE!!b5kp$c&ATQ`C_`o&ZUgkRlX8ToyP4d#gYiE)r*roe!bDnnJkg2&v^IDqju@u{qa=76D*QDxhRPekfr+F-PFBZ2?(3?w;NSUiW3k)JNC#OFOosV^D zjJ_ewt~(GSORcP|*jL|I0*#yyyWAU0@EWjpQwzDQyq1&eT6g(Ex)oZ5>+xgilLoNo z;sI!6a&cEtQcATBd0Z6!8`{O%*`5K+-Fu8nFTf6Gy%A5dy%A zkG8j?|n{;Lfv z7qn%x;<;KPb02G%H(18rAbJ4W=8H4fiyWrPC^K=?zpUVg#Otrc8upc%H~!cUE=1vM zY)rW{&@;%h{3B6+H54R)WbxfiO-&oMi`_u3iI#Rhq%OS`J&0ztKZ#XB>LT(+3q)A^ zZ<*&>iK0G!{CFL1i$=puXot@q85OnJYguK9-@WRx|FUthJk0|b(Lv80Qav;#YvWc; zu=Zl)6ghCCDJ0>a^wUt|Y3X}}x#s^Ic^7%Edka0SF%(0X!>mAu^?ggflO+SkT0KQH z3Z-Rv*zbJ*nX!@4JVE2)cffRf(O(fS@#>?!X`JMo0xHXJ-t6sQDsM})^{;O@(B%08 zlJnD3U7(~}AIwy)-y6i>QX%bZ*L3XHGH0Myz#LpZHr-&9hT{P)8s?CpPs)mHj;Oy^d4+d?y1g7TZw7-E2ngv7>Pd~p~A$?E!n1;s2 zQmw5Oc)dXl>VreG2Qm@z%#^=B$kKVFM^h~6*@bAUfP7_#i|VydhB|V;G>8j&AHM?I zTOQE4z2j!!{fqsRzq=wxy@9?`+R*TagH=A@J9BU{NQvx%3=KQj#iJbhu=8H4hIw(> z21!vX!xUq4n7m%U)=x-E;@1c0EHLSTZwVxV=Fv-$3~kjW1y`hYCl;BgpR6MEf+IAS zjc?`MM2xioypjRud>Hb-{1JJ+t&D?*M+%rjR(e{RN^f6ZYDsx{OTnnE$?TFWVQpmV z%!45S5x{h>$xCm4#|=FVDLVlI=^2plTmizl4qNd({=xO+NgDEK$HGE-K}pFT0UCz^ zLs(c?T^?JIi#sCQgz)nTo0!m#i(}JCqR^z_^wpY1-QpBAFbIKWhjp)7TxX!{h%`=b zw=&ka6$j6cip*y~1Rl4qc@_~7p`_SJ33e8DF#8Y4Pvgz*ntvJ!T=BOAv17WOEiNu@ z0=VuCVA>DnS8`sQ7s&)QIQxZ| z@0yA^A~o^0Hh^q?2K;Yc&>ifzR3jV5z?9O_MfH);OO}e?(?F8$_=42Kl1s4j)e3u5 zFtJ_1Eq9-iC72+cNf75L7Gzk>C=3grJ9DW{&gByiW z^)@&!fBOMmn3@OG{wpmVIl>>OyW=TX_wT=G`XRi^?;B(*3wa4iv;)z3&7UYh92JFJ z9%njQ>wC`E!Zbh(ZTLBWMu*^rEJh|Kjjo=aA3*sFTIv8MdEyt8)N8O+Iwo#`ulT(m zKgf?S0R7-`I|~X5n%8AX+5{ig@|cCi>-#%e$A^wq=lOOa1Zg%?8ey`&#w`GXvt-ms~EIAZFex+sktTKLRc-RKSv|%#LxUGizv~iOA8a76|N#2ij zZ|Z>9Cjhvd$JyRwmMOWE^8@AxD)RPcWnWaoSAo8N4pboVPL?Qi4u@MaCmCJ<7QLbHjMaFUA(CbnG6{DF0ZEbXwoZQN>A^*fSOCp^_` zwR$PH{fG+t@jV(A`Z_KdxP1%E^b4kwhoT9ncyDnFfUyvXNTq;$4tg6}yg}rcx+Gl` z`7D@9-5{*20z79%4wI&fmeiXCv)emu-ukR|4!?F6}a0G{ zHMe>-oA7dTYen{enAa|toaKD253cQoUjokZl21u7UwayW#BxO3P`(OTTJ{{(IgZ3r zFHS;F8uRovaKWHv6~+g0P57c{5q6depXMNaLqJ+v$E2_vJ?U3QCVyD6EmR`Yf}>e= zfJo`v*BIXG>grkqbzCCYA#B{5wgj_DKTblYGy)H!s?CiyYR&;e-^p_9m58w^ghVk^ zFAb}&QsKVA8Wc@_E15(}Qm`qL7%<;&BpDT0R{QOBWcx}?Oav-6&!zSGRvY$_U#6>b>Be?9xms&dz`FxwU z4R*XNa8#hl9QGgrie`clTVKGN3kqUF>BE^(8eu}aiNwav;^N2Hoh;^4wFKf8lLhv3 zeD$a`umw?CH_?vfFI$VDLuX_A8QRFLCN(dsxo3@GpdCoQzN2j>K~#sWJH zii^ic&*#1RdpQcao3po6E(4!xO$pR7JET>-EXC%B1PDG!t}aPtS}Y7N*z7baSJ#kwrUxz!tk;rJtD z&XXpt07SF^wSx-=b3NS|{Sn7CgT3?f=jT9nyt3f_fq}!yS`doV3Ko2}JeE0D+NTE2 z7L@EcXpV=zQ>OX zVr^+UmF)=GYNoo8p07T8_H6MjA(%`G0@dZ7bjUfl@I@e2l2paM#mfisF6@DtF$D5ij zUntrKnds4fAI!Uxc0k&5^y2W}uQYEIlri_Lte9f<8`|m(4h)dXm9E*pZpi_GVB|Iy zu18TNV576J)l2NN{A|$^Z46)|W~06wBG@`vS1??5MeX=;w%DNx1*g3HLrd3whP zRiUT5yK1!Lq78%EhxF&CcOc-(jR$npLPKIasDlZpW=)`yHl_)yc;+D@xZ`9X(D?=` zQ#x5vT~%cr`%zg%CE~q)7dstSKh~;HR0dSQtj5p^VccUsraxV?)x*w&QDB0-z*Q*S ziX)|Q|JZ}x==e7TvJ?zlp=@U6Yf9LLIM^RWKG_%)Z8F=1k7^5oNAbp(~^XMK&=G`JyDVc z1guWbf5GK+b9bKxM*>#Z7Gz!WV8G~o)OTJho)r^S9J}KI$jbr<3yF0FE4Ud~(o&F- z*6;cQLFF@~jXS>_=qcT%TyM>$-}y}gnvx0t!Naer*&6%{-MO6~-mI3EfBSORo-p#S` zQ82q~vjQf{CoG%_4ryqC(>ShXS!=Hw2lO9Cl43ikwafuMC+)j z;h@LNBc_KO(0!Ubj&o_^A^UD3Aubh&NsT(815}>?{VrQ0GHGr3z}DvM>}(8-xmh-n zi1hQI+y-NmDQ-v&C2kLHgGN$Sbk3FT(=v;lN@m*>y48y-sbbwnqo*cBOD%+5|&>E|Y4n%keFG<>)=>hu?~A z1Jj1KrlaMa4F!R7KpjD|zr-!H%rTGJmug`~pxt#6ZHbVwZV+_}0a>1aO0HFGaG1~o zgqABaGc%2kHW2a*u-dDVZEJTH$Hb20+d!mtv|ZktOGj-D*&Q=&s35pdd&GcGVqK>b1SV#9(_ zqT*SHt{SxlrAEqOayq0Tjt_tg>t~=I!GO6$Q(c<_k~k=)Y*-WwE0|pr5#aEgw@cyp z!-{CkM-k?x;I80}L=0Z(Uqy?qA*cZEy2gF{fJNs({wTQB46WOMNZ5i+89W}VFMm)e zge)S^m%r>;F?M})rmkYh1~)H>6>Ax+q_ni7doC26#wGX-RfMz}i!3cpfwR&?2_?wk zUxNF99jj*5mwFPiJNH^QN-kXPujgway@fCf_IR+QqCe5IR;21l*JTE=WpKt&^VU34 zj$3ZbAaO`L)J$Ic#fxR!`sY6vfYO5piY;vQ!}AFcz2M|}5~ej@5EjNO1LtLZ{ReNj|O1oqly)OjYS^lvza=JsO zk@$0@Tn^+Ltzf?W{J<&;G~h248~M2g5D7XB{<_zIm&`(IqYbVTyz{!zn21dnmn|g z0PM;}gypNJrx%5wH*qY^li&z}W5_~cCTFBx+Gl4A;xO!_XY&PB8>Rhf+!K-Dc;NI0 zhA>m~(RKhV`+-hB1q}Zj^+KK1!;S6jmd@A;#Tvx0fHNefa+cs!B+ccIje;VWj1voC zI2&XD98o6Te90F*5-iX7kVbrq85r05tEj^P6;vPfigmjYNfICj4+q&$DzNZ@62A(u zKa*7iBO)h_v-%a-^?-BG=)< Date: Wed, 7 Oct 2026 18:42:09 +0800 Subject: [PATCH 21/22] Fill a new extruder's machine limits the same way as its other settings --- .../references/extruder-variants.md | 11 ++- src/libslic3r/PrintConfig.cpp | 94 ++++++++++--------- src/slic3r/GUI/Tab.cpp | 12 +-- .../test_config_variant_expansion.cpp | 10 +- 4 files changed, 64 insertions(+), 63 deletions(-) diff --git a/.claude/skills/orca-profiles/references/extruder-variants.md b/.claude/skills/orca-profiles/references/extruder-variants.md index 5059fd5c6b..633443cbab 100644 --- a/.claude/skills/orca-profiles/references/extruder-variants.md +++ b/.claude/skills/orca-profiles/references/extruder-variants.md @@ -105,11 +105,12 @@ Rules: `single_extruder_multi_material` off, and in the app when the printer tab loads a printer with a different number of extruders, the pair is rebuilt from `extruder_variant_list` (one `Direct Drive Standard` per extruder when the list is absent) and the variant arrays are resized to - the rebuilt pair, padded with their first value or cut. The resize skips the `machine_max_*` limits - and `hotend_heating_rate` / `hotend_cooling_rate`: they keep their width, and an extruder beyond it - reads their first value, so extruder 2 and up of a list-less printer take extruder 1's normal limit - as their silent one too. With the three in agreement that changes nothing; a pair written without - the list is replaced. A listed variant the pair lacks is a menu choice that reads variant index 0. + the rebuilt pair, padded with their first value or cut. The `machine_max_*` limits are padded the + same way, so extruder 2 and up of a list-less printer take extruder 1's normal limit as their + silent one too. The resize skips `hotend_heating_rate` / `hotend_cooling_rate`: they keep their + width, and an extruder beyond it reads their first value. With the three in agreement that changes + nothing; a pair written without the list is replaced. A listed variant the pair lacks is a menu + choice that reads variant index 0. - The pair without `extruder_variant_list` slices, but the sidebar offers no variant switch and the app cannot add variants to a list-less process: nothing is lost while every extruder has exactly one variant, and every further variant is unreachable. diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 21e1b0fbc3..cd60a8f471 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -10030,48 +10030,13 @@ static void extend_extruder_variant(DynamicPrintConfig& config, const unsigned i printer_extruder_variant_opt->values.insert(printer_extruder_variant_opt->values.end(), variants_list.begin(), variants_list.end()); } } -} -// Options in printer_options_with_variant_2 are stored as (normal,silent) pairs per printer variant. -// Some legacy presets/projects carry a variant list but still store only one pair; normalize to avoid crashes. -static void normalize_stride2_floats(ConfigOptionFloats &opt, size_t expected_size) -{ - auto &v = opt.values; - if (expected_size == 0) { - v.clear(); - return; - } - if (v.empty()) { - // Fallback: keep behavior predictable instead of crashing. This should be rare. - v.resize(expected_size, 0.0); - return; - } - - const double first = v[0]; - const double second = (v.size() >= 2) ? v[1] : first; - - // Ensure we have at least one (normal,silent) pair to replicate. - if (v.size() < 2) { - v.resize(2, first); - v[1] = second; - } - // Keep pair alignment if some legacy preset produced odd length. - if (v.size() % 2 != 0) - v.push_back(second); - - if (v.size() > expected_size) { - v.resize(expected_size); - return; - } - - const size_t have_variants = v.size() / 2; - const size_t want_variants = expected_size / 2; - v.resize(expected_size); - for (size_t vi = have_variants; vi < want_variants; ++vi) { - v[vi * 2] = first; - if (vi * 2 + 1 < v.size()) - v[vi * 2 + 1] = second; - } + // 3. Size the machine limits to the rebuilt variants, padded with their first value like the other variant keys. + // They are not extruder option keys, so the resize loop in set_num_extruders skips them. + const auto &defaults = FullPrintConfig::defaults(); + for (const std::string &key : printer_options_with_variant_2) + if (auto *opt = config.option(key)) + opt->resize(config.get_parameter_size(key, num_extruders), defaults.option(key)); } void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders) @@ -10091,11 +10056,6 @@ void DynamicPrintConfig::set_num_extruders(unsigned int num_extruders) static_cast(opt)->resize(get_parameter_size(key, num_extruders), defaults.option(key)); } } - // Orca: machine limits are not extruder option keys and need a pair-aware resize, so that every - // printer variant has its own (normal, silent) pair to edit. - for (const std::string &key : printer_options_with_variant_2) - if (auto *opt = this->option(key)) - normalize_stride2_floats(*opt, get_parameter_size(key, num_extruders)); } // BBS @@ -11509,6 +11469,48 @@ void DynamicPrintConfig::update_filament_config_values_for_multiple_extruders(Dy } namespace { +// Options in printer_options_with_variant_2 are stored as (normal,silent) pairs per printer variant. +// Some legacy presets/projects carry a variant list but still store only one pair; normalize to avoid crashes. +static void normalize_stride2_floats(ConfigOptionFloats &opt, size_t expected_size) +{ + auto &v = opt.values; + if (expected_size == 0) { + v.clear(); + return; + } + if (v.empty()) { + // Fallback: keep behavior predictable instead of crashing. This should be rare. + v.resize(expected_size, 0.0); + return; + } + + const double first = v[0]; + const double second = (v.size() >= 2) ? v[1] : first; + + // Ensure we have at least one (normal,silent) pair to replicate. + if (v.size() < 2) { + v.resize(2, first); + v[1] = second; + } + // Keep pair alignment if some legacy preset produced odd length. + if (v.size() % 2 != 0) + v.push_back(second); + + if (v.size() > expected_size) { + v.resize(expected_size); + return; + } + + const size_t have_variants = v.size() / 2; + const size_t want_variants = expected_size / 2; + v.resize(expected_size); + for (size_t vi = have_variants; vi < want_variants; ++vi) { + v[vi * 2] = first; + if (vi * 2 + 1 < v.size()) + v[vi * 2 + 1] = second; + } +} + static void log_normalize_legacy_vector_size(const char *fn, const std::string &key, int stride, size_t src_size, size_t dest_size, size_t expected_size, size_t restore_n, int cur_variant_count, int target_variant_count, size_t cur_ids, size_t target_ids, const ConfigOption *opt_src, const ConfigOption *opt_target) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 93fc22ae53..5e5761c6fe 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1161,9 +1161,8 @@ std::string Tab::options_list_storage_key(const std::string& opt_key) const // Orca: deep_diff() flags every vector entry at or past the reference vector's length as changed, // whatever its value (e.g. the values of an extruder added by raising the extruder count). A vector -// grows by copying its first entry (ConfigOptionVector::resize), and machine limits by copying their -// first (normal, silent) pair (set_num_extruders), so such an entry only counts as changed when it -// differs from the reference entry it was copied from, as before Orca's deep_diff() change. +// grows by copying its first entry (ConfigOptionVector::resize), so such an entry only counts as +// changed when it differs from the reference's first entry, as before Orca's deep_diff() change. // The change of the count itself shows on "extruders_count". static void drop_unchanged_added_entries(std::vector &options, const DynamicPrintConfig ¤t, const Preset *reference) { @@ -1172,7 +1171,7 @@ static void drop_unchanged_added_entries(std::vector &options, cons // deep_diff() lists a key's entries one after another, so serialize each key's vectors once. std::string serialized_key; std::vector cur_values; - std::vector ref_values; + std::string ref_first; options.erase(std::remove_if(options.begin(), options.end(), [&](const std::string &opt) { const auto pos = opt.find('#'); if (pos == std::string::npos) @@ -1186,10 +1185,9 @@ static void drop_unchanged_added_entries(std::vector &options, cons if (key != serialized_key) { serialized_key = key; cur_values = cur->vserialize(); - ref_values = ref->vserialize(); + ref_first = ref->vserialize().front(); } - const size_t copied_from = printer_options_with_variant_2.count(key) > 0 && idx % 2 < ref_values.size() ? idx % 2 : 0; - return cur_values[idx] == ref_values[copied_from]; + return cur_values[idx] == ref_first; }), options.end()); } diff --git a/tests/libslic3r/test_config_variant_expansion.cpp b/tests/libslic3r/test_config_variant_expansion.cpp index 95e94fa117..40fdce384a 100644 --- a/tests/libslic3r/test_config_variant_expansion.cpp +++ b/tests/libslic3r/test_config_variant_expansion.cpp @@ -807,11 +807,11 @@ TEST_CASE("set_num_extruders gives every printer variant its own pair of machine DynamicPrintConfig config = DynamicPrintConfig::full_print_config(); auto speed_x = [&config]() { return config.option("machine_max_speed_x")->values; }; - SECTION("a single pair is copied to every extruder") { + SECTION("a new extruder's pair is padded with the first value, like the other variant keys") { config.option("machine_max_speed_x")->values = {500., 200.}; config.set_num_extruders(3); REQUIRE(config.option("printer_extruder_variant")->size() == 3); - REQUIRE(speed_x() == std::vector({500., 200., 500., 200., 500., 200.})); + REQUIRE(speed_x() == std::vector({500., 200., 500., 500., 500., 500.})); } SECTION("per-extruder pairs are kept, and removing an extruder removes its pair") { @@ -822,8 +822,8 @@ TEST_CASE("set_num_extruders gives every printer variant its own pair of machine REQUIRE(speed_x() == std::vector({500., 200., 400., 150.})); } - SECTION("a printer with nozzle variants gets a pair per variant column") { - // 2 extruders x 2 variants = 4 columns + SECTION("a printer with nozzle variants gets a pair per variant") { + // 2 extruders x 2 variants each = 4 variants config.option("extruder_variant_list", true)->values = {"Direct Drive Standard,Direct Drive High Flow", "Direct Drive Standard,Direct Drive High Flow"}; const std::vector per_variant = {500., 200., 510., 210., 520., 220., 530., 230.}; @@ -833,7 +833,7 @@ TEST_CASE("set_num_extruders gives every printer variant its own pair of machine config.option("machine_max_speed_x")->values = {500., 200.}; config.set_num_extruders(2); - REQUIRE(speed_x() == std::vector({500., 200., 500., 200., 500., 200., 500., 200.})); + REQUIRE(speed_x() == std::vector({500., 200., 500., 500., 500., 500., 500., 500.})); } } From e027f8b225edd3b05496f8c2e9e67f8352ebb9b3 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Wed, 7 Oct 2026 21:19:31 +0800 Subject: [PATCH 22/22] Remove the CAD Primitive and Sketch gizmos from Prepare --- localization/i18n/list.txt | 2 - .../images/toolbar_modifier_cube_dark.svg | 4 - resources/images/toolbar_sketch.svg | 8 - resources/images/toolbar_sketch_dark.svg | 8 - src/libslic3r/CAD/CadDocument.cpp | 1 + src/libslic3r/CAD/GeometryEngine.cpp | 39 +- src/libslic3r/CAD/GeometryEngine.hpp | 41 -- src/libslic3r/CAD/SketchEngine.hpp | 25 - src/slic3r/CMakeLists.txt | 5 - src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp | 206 -------- src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp | 48 -- src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp | 488 ------------------ src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp | 81 --- src/slic3r/GUI/Gizmos/GLGizmosManager.cpp | 23 +- src/slic3r/GUI/Gizmos/GLGizmosManager.hpp | 6 - 15 files changed, 3 insertions(+), 982 deletions(-) delete mode 100644 resources/images/toolbar_modifier_cube_dark.svg delete mode 100644 resources/images/toolbar_sketch.svg delete mode 100644 resources/images/toolbar_sketch_dark.svg delete mode 100644 src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp delete mode 100644 src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp delete mode 100644 src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp delete mode 100644 src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp diff --git a/localization/i18n/list.txt b/localization/i18n/list.txt index 981e7a040a..b1ebb54f5e 100644 --- a/localization/i18n/list.txt +++ b/localization/i18n/list.txt @@ -295,8 +295,6 @@ src/slic3r/GUI/CAD/DesignSketchTool.cpp src/slic3r/GUI/CAD/SketchInlineEditor.cpp src/slic3r/GUI/CAD/DesignOffer.hpp src/slic3r/GUI/CAD/DesignTextDialog.cpp -src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp -src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp src/slic3r/GUI/KeyChord.cpp src/slic3r/GUI/Shortcuts.cpp src/libslic3r/CAD/CadDocument.cpp diff --git a/resources/images/toolbar_modifier_cube_dark.svg b/resources/images/toolbar_modifier_cube_dark.svg deleted file mode 100644 index 7e20cd0dd5..0000000000 --- a/resources/images/toolbar_modifier_cube_dark.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/resources/images/toolbar_sketch.svg b/resources/images/toolbar_sketch.svg deleted file mode 100644 index 351b3e7924..0000000000 --- a/resources/images/toolbar_sketch.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/resources/images/toolbar_sketch_dark.svg b/resources/images/toolbar_sketch_dark.svg deleted file mode 100644 index e5cf8d6859..0000000000 --- a/resources/images/toolbar_sketch_dark.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/src/libslic3r/CAD/CadDocument.cpp b/src/libslic3r/CAD/CadDocument.cpp index 391ff56a87..cec5a3a74e 100644 --- a/src/libslic3r/CAD/CadDocument.cpp +++ b/src/libslic3r/CAD/CadDocument.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include // multi-body: compound of bodies for display/compat #include #include // outward-normal orientation for face-extrude diff --git a/src/libslic3r/CAD/GeometryEngine.cpp b/src/libslic3r/CAD/GeometryEngine.cpp index 827493fb26..454b37fce2 100644 --- a/src/libslic3r/CAD/GeometryEngine.cpp +++ b/src/libslic3r/CAD/GeometryEngine.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -53,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -244,30 +244,6 @@ TopoDS_Shape GeometryEngine::mesh_to_brep(const indexed_triangle_set& its, return shape; } -// ---- Primitive creation ---- - -TopoDS_Solid GeometryEngine::make_primitive(const PrimitiveParams& params) -{ - switch (params.type) { - case PrimitiveType::Box: - return BRepPrimAPI_MakeBox(gp_Pnt(-params.box_w/2, -params.box_d/2, 0), - params.box_w, params.box_d, params.box_h).Solid(); - case PrimitiveType::Cylinder: - return BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), - params.cyl_radius, params.cyl_height).Solid(); - case PrimitiveType::Sphere: - return BRepPrimAPI_MakeSphere(gp_Pnt(0,0,params.sph_radius), params.sph_radius).Solid(); - case PrimitiveType::Cone: - return BRepPrimAPI_MakeCone(gp_Ax2(gp_Pnt(0,0,0), gp_Dir(0,0,1)), - params.cone_r1, params.cone_r2, params.cone_height).Solid(); - case PrimitiveType::Torus: - return BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(0,0,params.torus_r2), gp_Dir(0,0,1)), - params.torus_r1, params.torus_r2).Solid(); - default: - return BRepPrimAPI_MakeBox(gp_Pnt(-10,-10,0), 20,20,20).Solid(); - } -} - // ---- Face classification ---- FaceGroup GeometryEngine::classify_face(const TopoDS_Face& face, const TopoDS_Shape& /*solid*/) @@ -545,19 +521,6 @@ GeometryEngine::MassProps GeometryEngine::mass_properties(const TopoDS_Shape& sh return p; } -std::string GeometryEngine::primitive_name(PrimitiveType type) -{ - switch (type) { - // TRN Default name of an object created from the box primitive shape. - case PrimitiveType::Box: return _u8L("Box"); - case PrimitiveType::Cylinder: return _u8L("Cylinder"); - case PrimitiveType::Sphere: return _u8L("Sphere"); - case PrimitiveType::Cone: return _u8L("Cone"); - case PrimitiveType::Torus: return _u8L("Torus"); - default: return _u8L("Unknown"); - } -} - // ---- Topology accessors ---- int GeometryEngine::face_count(const TopoDS_Shape& shape) diff --git a/src/libslic3r/CAD/GeometryEngine.hpp b/src/libslic3r/CAD/GeometryEngine.hpp index e7e92c0438..66f00859be 100644 --- a/src/libslic3r/CAD/GeometryEngine.hpp +++ b/src/libslic3r/CAD/GeometryEngine.hpp @@ -4,15 +4,8 @@ #include "libslic3r/Point.hpp" #include "libslic3r/TriangleMesh.hpp" -#include -#include -#include -#include -#include #include #include -#include -#include #include #include #include @@ -20,44 +13,11 @@ namespace Slic3r { -enum class PrimitiveType { Box, Cylinder, Sphere, Cone, Torus, COUNT }; -enum class DressUpType { Fillet, Chamfer }; enum class FaceGroup { Top, Bottom, Lateral, All }; -struct PrimitiveParams { - PrimitiveType type{PrimitiveType::Box}; - double box_w{20}, box_h{20}, box_d{20}; - double cyl_radius{10}, cyl_height{20}; - double sph_radius{10}; - double cone_r1{10}, cone_r2{5}, cone_height{20}; - double torus_r1{10}, torus_r2{3}; - - // Dress-up - bool dressup_enabled{false}; - DressUpType dressup_type{DressUpType::Fillet}; - FaceGroup dressup_faces{FaceGroup::All}; - double dressup_radius{1.0}; // fillet radius - double dressup_chamfer_dist{1.0}; // chamfer distance (symmetric) - - // Mesh quality — the Design tab's own density (CadDocument::linear_deflection), so a - // primitive and the same body modelled in the Design tab reach the screen alike. - double linear_deflection{0.003}; - double angular_deflection{0.5}; - - template - void serialize(Archive& ar) { - ar(type, box_w, box_h, box_d, cyl_radius, cyl_height, sph_radius, - cone_r1, cone_r2, cone_height, torus_r1, torus_r2, - dressup_enabled, dressup_type, dressup_faces, dressup_radius, dressup_chamfer_dist, - linear_deflection, angular_deflection); - } -}; - class GeometryEngine { public: - static TopoDS_Solid make_primitive(const PrimitiveParams& params); - // Read a STEP file into its top-level solids (one TopoDS_Shape per solid; falls back to // the whole shape if it contains no closed solids). Reuses OCCT's STEPControl_Reader, // already linked via Format/STEP.cpp — no new dependency. err is set on failure (empty result). @@ -132,7 +92,6 @@ public: static TriangleMesh tessellate(const TopoDS_Shape& shape, double linear_deflection = 0.003, double angular_deflection = 0.5); - static std::string primitive_name(PrimitiveType type); // Topology accessors for in-viewport face/edge picking (Design tab). Face index is the // TopExp_Explorer(shape, TopAbs_FACE) ordinal — identical to SketchEngine::tessellate's diff --git a/src/libslic3r/CAD/SketchEngine.hpp b/src/libslic3r/CAD/SketchEngine.hpp index 93fbf72cb9..22dade5af0 100644 --- a/src/libslic3r/CAD/SketchEngine.hpp +++ b/src/libslic3r/CAD/SketchEngine.hpp @@ -3,7 +3,6 @@ #include "libslic3r/TriangleMesh.hpp" #include "libslic3r/Point.hpp" -#include "libslic3r/CAD/GeometryEngine.hpp" #include #include @@ -211,30 +210,6 @@ ConstraintPlan plan_entity_constraint(const std::vector& ents, bool solve_sketch_entities(std::vector& entities, const std::vector& constraints); -struct SketchParams { - // Extrude/Revolve - double extrude_len{10}; bool extrude_sym{false}; double extrude_taper{0}; - double revolve_deg{360}; - bool is_pocket{false}; // cut into selected object instead of new - - // Dress-up - bool dressup_enabled{false}; - DressUpType dressup_type{DressUpType::Fillet}; - FaceGroup dressup_faces{FaceGroup::All}; - double dressup_radius{1.0}; - double dressup_chamfer_dist{1.0}; - - // Mesh - double linear_deflection{0.01}; - - template - void serialize(Archive& ar) { - ar(extrude_len, extrude_sym, extrude_taper, revolve_deg, is_pocket, - dressup_enabled, dressup_type, dressup_faces, dressup_radius, dressup_chamfer_dist, - linear_deflection); - } -}; - class SketchEngine { public: diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index e7839ad194..b313c4fe42 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -849,11 +849,6 @@ if (SLIC3R_CAD) GUI/CAD/SketchInlineEditor.hpp GUI/CAD/McpControl.cpp GUI/CAD/McpControl.hpp - GUI/Gizmos/GLGizmoSketch.cpp - GUI/Gizmos/GLGizmoSketch.hpp - # Needs GeometryEngine (make_primitive / apply_fillet / tessellate). - GUI/Gizmos/GLGizmoPrimitive.cpp - GUI/Gizmos/GLGizmoPrimitive.hpp ) endif () diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp deleted file mode 100644 index e74507596e..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include "GLGizmoPrimitive.hpp" -#include "slic3r/GUI/GLCanvas3D.hpp" -#include "slic3r/GUI/ImGuiWrapper.hpp" -#include "slic3r/GUI/Plater.hpp" -#include "slic3r/GUI/NotificationManager.hpp" -#include "libslic3r/Model.hpp" -#include -#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp" -#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp" -#include "libslic3r/CAD/GeometryEngine.hpp" -#include -#include -#include "slic3r/GUI/GUI_App.hpp" -#include -#include -#include - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif -#include -#include "libslic3r/TriangleMesh.hpp" -#include "slic3r/GUI/I18N.hpp" - -namespace Slic3r { -namespace GUI { - -GLGizmoPrimitive::GLGizmoPrimitive(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) - : GLGizmoBase(parent, icon_filename, sprite_id) {} - -bool GLGizmoPrimitive::on_init() { return true; } -std::string GLGizmoPrimitive::on_get_name() const { return _u8L("Primitive"); } -// Part of the experimental CAD feature: built into every CAD build, but offered in the Prepare -// toolbar only when that feature is switched on in Preferences — switched off, Prepare must be -// exactly what it is without it. -bool GLGizmoPrimitive::on_is_activable() const { return wxGetApp().is_enable_cad_feature(); } -bool GLGizmoPrimitive::on_is_selectable() const { return wxGetApp().is_enable_cad_feature(); } -void GLGizmoPrimitive::on_render() {} -void GLGizmoPrimitive::on_set_state() -{ if (m_state == EState::On) { m_params = PrimitiveParams{}; m_preview_dirty = true; } } - -bool GLGizmoPrimitive::on_mouse(const wxMouseEvent&) { return false; } - -CommonGizmosDataID GLGizmoPrimitive::on_get_requirements() const -{ return CommonGizmosDataID(int(CommonGizmosDataID::SelectionInfo) | int(CommonGizmosDataID::InstancesHider)); } - -void GLGizmoPrimitive::on_load(cereal::BinaryInputArchive& ar) -{ ar(m_params); m_preview_dirty = true; } -void GLGizmoPrimitive::on_save(cereal::BinaryOutputArchive& ar) const -{ ar(m_params); } - -void GLGizmoPrimitive::apply_preset(const char*, double w, double h, double d) -{ - m_params.type = PrimitiveType::Box; - m_params.box_w = w; m_params.box_h = h; m_params.box_d = d; - m_preview_dirty = true; -} - -static void gen_mesh_and_add(PrimitiveParams& p, const char* snap_name) -{ - TopoDS_Solid solid = GeometryEngine::make_primitive(p); - TopoDS_Shape shape = solid; - if (p.dressup_enabled) { - if (p.dressup_type == DressUpType::Fillet) - shape = GeometryEngine::apply_fillet(shape, p.dressup_radius, p.dressup_faces); - else - shape = GeometryEngine::apply_chamfer(shape, p.dressup_chamfer_dist, p.dressup_faces); - } - TriangleMesh mesh = GeometryEngine::tessellate(shape, p.linear_deflection, p.angular_deflection); - if (mesh.its.indices.empty()) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::WarningNotificationLevel, _u8L("Empty mesh generated")); - return; - } - wxGetApp().plater()->take_snapshot(snap_name); - ModelObject* mo = wxGetApp().model().add_object(); - std::string name = GeometryEngine::primitive_name(p.type); - if (p.dressup_enabled && p.dressup_type == DressUpType::Fillet) name += " (Fillet)"; - else if (p.dressup_enabled) name += " (Chamfer)"; - mo->name = name; - mo->add_volume(std::move(mesh))->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); -} - -void GLGizmoPrimitive::apply_primitive() { gen_mesh_and_add(m_params, "Add Primitive"); } - -void GLGizmoPrimitive::on_render_input_window(float x, float y, float bottom_limit) -{ - y = std::min(y, bottom_limit - ImGui::GetWindowHeight()); - const float scale = m_parent.get_scale(); - ImGuiWrapper::push_toolbar_style(scale); - GizmoImguiSetNextWIndowPos(x, y, ImGuiCond_Always, 0.0f, 0.0f); - GizmoImguiBegin("Primitive", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse - | ImGuiWindowFlags_NoTitleBar); - - if (ImGui::CollapsingHeader(_u8L("Shape").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - const std::string names_s[] = {_u8L("Box"), _u8L("Cylinder"), _u8L("Sphere"), _u8L("Cone"), _u8L("Torus")}; - const char* names[] = {names_s[0].c_str(), names_s[1].c_str(), names_s[2].c_str(), names_s[3].c_str(), names_s[4].c_str()}; - int cur = (int)m_params.type; - if (ImGui::Combo("##type", &cur, names, (int)PrimitiveType::COUNT)) { - m_params.type = (PrimitiveType)cur; - m_preview_dirty = true; - } - // TRN Primitive gizmo: label in front of the preset cube size buttons - ImGui::TextUnformatted(_u8L("Quick:").c_str()); - ImGui::SameLine(); - if (ImGui::SmallButton("10mm")) apply_preset("10mm cube", 10, 10, 10); - ImGui::SameLine(); - if (ImGui::SmallButton("20mm")) apply_preset("20mm cube", 20, 20, 20); - ImGui::SameLine(); - if (ImGui::SmallButton("50mm")) apply_preset("50mm cube", 50, 50, 50); - } - - ImGui::Separator(); - - if (ImGui::CollapsingHeader(_u8L("Dimensions").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - auto dim = [&](const char* label, double& val, double step=0.5, double fast=5.0) { - ImGui::SetNextItemWidth(130); - if (ImGui::InputDouble(label, &val, step, fast, "%.1f mm")) m_preview_dirty = true; - if (val < 0.5) val = 0.5; - }; - switch (m_params.type) { - case PrimitiveType::Box: - dim(_u8L("Width (X)").c_str(), m_params.box_w); - dim(_u8L("Depth (Y)").c_str(), m_params.box_d); - dim(_u8L("Height (Z)").c_str(), m_params.box_h); - break; - case PrimitiveType::Cylinder: - dim(_u8L("Radius").c_str(), m_params.cyl_radius); - dim(_u8L("Height").c_str(), m_params.cyl_height); - break; - case PrimitiveType::Sphere: - dim(_u8L("Radius").c_str(), m_params.sph_radius); - break; - case PrimitiveType::Cone: - // TRN Primitive gizmo: bottom radius of a cone ("Top R" is the top radius) - dim(_u8L("Bottom R").c_str(), m_params.cone_r1); - dim(_u8L("Top R").c_str(), m_params.cone_r2); - dim(_u8L("Height").c_str(), m_params.cone_height); - break; - case PrimitiveType::Torus: - // TRN Primitive gizmo: major radius of a torus ("Minor R" is the tube radius) - dim(_u8L("Major R").c_str(), m_params.torus_r1); - dim(_u8L("Minor R").c_str(), m_params.torus_r2, 0.1, 1.0); - break; - default: break; - } - } - - ImGui::Separator(); - - if (ImGui::CollapsingHeader(_u8L("Fillet / Chamfer").c_str())) { - ImGui::Checkbox(_u8L("Enable").c_str(), &m_params.dressup_enabled); - if (m_params.dressup_enabled) { - const std::string dn_s[] = {_u8L("Fillet"), _u8L("Chamfer")}; - const char* dn[] = {dn_s[0].c_str(), dn_s[1].c_str()}; - int du = (int)m_params.dressup_type; - ImGui::SetNextItemWidth(100); - if (ImGui::Combo("##dtype", &du, dn, 2)) { m_params.dressup_type = (DressUpType)du; m_preview_dirty = true; } - const std::string fn_s[] = {_u8L("All edges"), _u8L("Top edges"), _u8L("Bottom edges"), _u8L("Lateral edges")}; - const char* fn[] = {fn_s[0].c_str(), fn_s[1].c_str(), fn_s[2].c_str(), fn_s[3].c_str()}; - int fg = (int)m_params.dressup_faces; - ImGui::SetNextItemWidth(140); - if (ImGui::Combo(_u8L("Edges").c_str(), &fg, fn, 4)) { m_params.dressup_faces = (FaceGroup)fg; m_preview_dirty = true; } - if (m_params.dressup_type == DressUpType::Fillet) { - ImGui::SetNextItemWidth(100); - if (ImGui::InputDouble(_u8L("Radius").c_str(), &m_params.dressup_radius, 0.1, 1.0, "%.1f mm")) { - if (m_params.dressup_radius < 0.1) m_params.dressup_radius = 0.1; - m_preview_dirty = true; - } - } else { - ImGui::SetNextItemWidth(100); - if (ImGui::InputDouble(_u8L("Distance").c_str(), &m_params.dressup_chamfer_dist, 0.1, 1.0, "%.1f mm")) { - if (m_params.dressup_chamfer_dist < 0.1) m_params.dressup_chamfer_dist = 0.1; - m_preview_dirty = true; - } - } - } - } - - ImGui::Separator(); - - if (ImGui::CollapsingHeader(_u8L("Quality").c_str())) { - ImGui::SetNextItemWidth(130); - if (ImGui::InputDouble(_u8L("Mesh resolution").c_str(), &m_params.linear_deflection, 0.001, 0.1, "%.3f mm")) { - if (m_params.linear_deflection < 0.001) m_params.linear_deflection = 0.001; - if (m_params.linear_deflection > 1.0) m_params.linear_deflection = 1.0; - m_preview_dirty = true; - } - } - - ImGui::Separator(); - - if (ImGui::Button(_u8L("Add Shape").c_str(), {-1, 28})) - apply_primitive(); - - if (ImGui::Button(_u8L("Close").c_str(), {-1, 0})) - m_parent.reset_all_gizmos(); - - GizmoImguiEnd(); - ImGuiWrapper::pop_toolbar_style(); -} - -} // namespace GUI -} // namespace Slic3r diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp deleted file mode 100644 index eef44a64c4..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef slic3r_GLGizmoPrimitive_hpp_ -#define slic3r_GLGizmoPrimitive_hpp_ - -#include "GLGizmoBase.hpp" -#include "GLGizmosCommon.hpp" -#include "libslic3r/CAD/GeometryEngine.hpp" -#include -#include -#include -#include "libslic3r/TriangleMesh.hpp" - -namespace Slic3r { -namespace GUI { - -class GLGizmoPrimitive : public GLGizmoBase -{ -public: - GLGizmoPrimitive(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); - ~GLGizmoPrimitive() = default; - - bool on_mouse(const wxMouseEvent& mouse_event) override; - -protected: - bool on_init() override; - std::string on_get_name() const override; - bool on_is_activable() const override; - bool on_is_selectable() const override; - void on_render() override; - void on_set_state() override; - CommonGizmosDataID on_get_requirements() const override; - void on_render_input_window(float x, float y, float bottom_limit) override; - - void on_load(cereal::BinaryInputArchive& ar) override; - void on_save(cereal::BinaryOutputArchive& ar) const override; - -private: - void apply_primitive(); - void apply_preset(const char* name, double w, double h, double d); - - PrimitiveParams m_params; - TriangleMesh m_preview_mesh; - bool m_preview_dirty{true}; -}; - -} // namespace GUI -} // namespace Slic3r - -#endif // slic3r_GLGizmoPrimitive_hpp_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp deleted file mode 100644 index 4561a1eac6..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoSketch.cpp +++ /dev/null @@ -1,488 +0,0 @@ -#include "GLGizmoSketch.hpp" -#include "slic3r/GUI/GLCanvas3D.hpp" -#include "slic3r/GUI/ImGuiWrapper.hpp" -#include "slic3r/GUI/Plater.hpp" -#include "slic3r/GUI/NotificationManager.hpp" -#include "slic3r/GUI/format.hpp" -#include "libslic3r/Model.hpp" -#include -#include -#include -#include -#include "slic3r/GUI/Gizmos/GLGizmoBase.hpp" -#include "slic3r/GUI/Gizmos/GLGizmosCommon.hpp" -#include "libslic3r/CAD/SketchEngine.hpp" -#include "libslic3r/Point.hpp" -#include -#include -#include -#include -#include -#include -#include -#include -#include "libslic3r/CAD/GeometryEngine.hpp" -#include -#include "slic3r/GUI/GUI_App.hpp" -#include -#include - -#ifndef IMGUI_DEFINE_MATH_OPERATORS -#define IMGUI_DEFINE_MATH_OPERATORS -#endif -#include -#include "libslic3r/TriangleMesh.hpp" -#include "slic3r/GUI/I18N.hpp" -#include "slic3r/GUI/Selection.hpp" - -namespace Slic3r { -namespace GUI { - -GLGizmoSketch::GLGizmoSketch(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) - : GLGizmoBase(parent, icon_filename, sprite_id) {} - -bool GLGizmoSketch::on_init() { return true; } -std::string GLGizmoSketch::on_get_name() const { return _u8L("Sketch"); } -// Part of the experimental CAD feature: built into every CAD build, but offered in the Prepare -// toolbar only when that feature is switched on in Preferences — switched off, Prepare must be -// exactly what it is without it. -bool GLGizmoSketch::on_is_activable() const { return wxGetApp().is_enable_cad_feature(); } -bool GLGizmoSketch::on_is_selectable() const { return wxGetApp().is_enable_cad_feature(); } -void GLGizmoSketch::on_render() {} -void GLGizmoSketch::on_set_state() { if (m_state == EState::On) clear_all(); } -bool GLGizmoSketch::on_mouse(const wxMouseEvent&) { return false; } - -CommonGizmosDataID GLGizmoSketch::on_get_requirements() const -{ return CommonGizmosDataID(int(CommonGizmosDataID::SelectionInfo)); } - -void GLGizmoSketch::on_load(cereal::BinaryInputArchive& ar) -{ - ar(m_tool, m_profiles, m_plane, m_sp, m_rect_w, m_rect_h, m_circle_r, m_poly_sides, m_poly_r, m_snap_grid, m_grid_step); - m_active_profile = -1; -} - -void GLGizmoSketch::on_save(cereal::BinaryOutputArchive& ar) const -{ - ar(m_tool, m_profiles, m_plane, m_sp, m_rect_w, m_rect_h, m_circle_r, m_poly_sides, m_poly_r, m_snap_grid, m_grid_step); -} - -SketchProfile& GLGizmoSketch::active_profile() -{ - if (m_active_profile < 0 || m_active_profile >= (int)m_profiles.size()) { - m_profiles.emplace_back(); - m_active_profile = (int)m_profiles.size() - 1; - } - return m_profiles[m_active_profile]; -} - -bool GLGizmoSketch::has_closed_profile() const -{ - for (auto& p : m_profiles) if (p.closed && p.points.size() >= 3) return true; - return false; -} - -void GLGizmoSketch::clear_all() -{ - m_profiles.clear(); - m_canvas_points.clear(); - m_active_profile = -1; -} - -void GLGizmoSketch::add_closed_profile() -{ - auto& ap = active_profile(); - if (ap.points.size() >= 3) { - ap.closed = true; - m_active_profile = -1; - } -} - -void GLGizmoSketch::delete_profile(int idx) -{ - if (idx >= 0 && idx < (int)m_profiles.size()) { - m_profiles.erase(m_profiles.begin() + idx); - if (m_active_profile >= (int)m_profiles.size()) m_active_profile = -1; - } -} - -Vec2d GLGizmoSketch::snap(Vec2d pt) const -{ - if (!m_snap_grid) return pt; - double gs = m_grid_step; - return {round(pt.x() / gs) * gs, round(pt.y() / gs) * gs}; -} - -void GLGizmoSketch::build_preset_profile() -{ - auto& ap = active_profile(); - ap.clear(); - auto add = [&](double x, double y) { ap.points.emplace_back(x, y); }; - switch (m_tool) { - case SketchTool::Rectangle: - add(-m_rect_w/2, -m_rect_h/2); add( m_rect_w/2, -m_rect_h/2); - add( m_rect_w/2, m_rect_h/2); add(-m_rect_w/2, m_rect_h/2); - ap.closed = true; m_active_profile = -1; break; - case SketchTool::Circle: - for (int i = 0; i <= m_circle_seg; ++i) { - double a = 2.0*M_PI*i/m_circle_seg; - add(cos(a)*m_circle_r, sin(a)*m_circle_r); - } - ap.closed = true; m_active_profile = -1; break; - case SketchTool::Polygon: - for (int i = 0; i < m_poly_sides; ++i) { - double a = 2.0*M_PI*i/m_poly_sides - M_PI/2; - add(cos(a)*m_poly_r, sin(a)*m_poly_r); - } - ap.closed = true; m_active_profile = -1; break; - default: break; - } -} - -void GLGizmoSketch::handle_canvas_click(ImVec2 pos) -{ - Vec2d pt = snap({pos.x / m_canvas_scale, -pos.y / m_canvas_scale}); - if (m_tool == SketchTool::Line) { - auto& ap = active_profile(); - if (ap.points.size() >= 3 && (pt - ap.points.front()).norm() < m_grid_step) { - ap.points.push_back(ap.points.front()); - ap.closed = true; - m_active_profile = -1; - return; - } - ap.points.push_back(pt); - } -} - -void GLGizmoSketch::draw_canvas() -{ - ImDrawList* dl = ImGui::GetWindowDrawList(); - ImVec2 pos = ImGui::GetCursorScreenPos(); - float w = 280, h = 200; - ImVec2 end(pos.x+w, pos.y+h); - float cx = pos.x+w/2, cy = pos.y+h/2; - auto tc = [&](const ImVec2& p) { return ImVec2(cx+p.x*m_canvas_scale, cy-p.y*m_canvas_scale); }; - - dl->AddRectFilled(pos, end, IM_COL32(28,28,36,255)); - dl->AddRect(pos, end, IM_COL32(55,55,68,255)); - - float gs = m_grid_step; - for (float g = 0; g < w; g += gs * m_canvas_scale) { - ImU32 gc = (int(g/(gs*m_canvas_scale)) % 5 == 0) ? IM_COL32(60,60,75,100) : IM_COL32(45,45,55,60); - dl->AddLine({pos.x+g,pos.y}, {pos.x+g,end.y}, gc); - } - for (float g = 0; g < h; g += gs * m_canvas_scale) { - ImU32 gc = (int(g/(gs*m_canvas_scale)) % 5 == 0) ? IM_COL32(60,60,75,100) : IM_COL32(45,45,55,60); - dl->AddLine({pos.x,pos.y+g}, {end.x,pos.y+g}, gc); - } - - dl->AddLine({cx,pos.y},{cx,end.y}, IM_COL32(70,70,85,180), 1.5f); - dl->AddLine({pos.x,cy},{end.x,cy}, IM_COL32(70,70,85,180), 1.5f); - dl->AddText({end.x-12, cy+2}, IM_COL32(120,120,140,200), "X"); - dl->AddText({cx+4, pos.y+2}, IM_COL32(120,120,140,200), "Y"); - - for (size_t pi = 0; pi < m_profiles.size(); ++pi) { - auto& prof = m_profiles[pi]; - if (prof.points.size() < 2) continue; - std::vector sp; - for (auto& p : prof.points) sp.push_back(tc({(float)p.x(), (float)p.y()})); - if (prof.closed && sp.size() >= 3) { - bool is_outer = (pi == 0); - ImU32 fill = is_outer ? IM_COL32(0,180,90,35) : IM_COL32(180,60,60,35); - ImU32 line = is_outer ? IM_COL32(0,220,100,255) : IM_COL32(220,80,80,255); - dl->AddConvexPolyFilled(sp.data(), (int)sp.size(), fill); - for (size_t i=0; iAddLine(sp[i], sp[(i+1)%sp.size()], line, (pi==0)?2.5f:2.0f); - for (size_t i=0; iAddCircleFilled(sp[i], 3.0f, IM_COL32(255,255,255,255)); - } - } - - auto& ap = active_profile(); - if (!ap.closed && ap.points.size() >= 1) { - std::vector sp; - for (auto& p : ap.points) sp.push_back(tc({(float)p.x(), (float)p.y()})); - for (size_t i=1; iAddLine(sp[i-1], sp[i], IM_COL32(0,200,255,200), 2.0f); - for (auto& s : sp) dl->AddCircleFilled(s, 3.5f, IM_COL32(100,200,255,255)); - ImVec2 mouse = ImGui::GetMousePos(); - if (mouse.x > pos.x && mouse.x < end.x && mouse.y > pos.y && mouse.y < end.y) - dl->AddLine(sp.back(), mouse, IM_COL32(100,160,220,120), 1.5f); - } - - ImGui::InvisibleButton("canvas", ImVec2(w,h)); - if (ImGui::IsItemHovered()) { - ImVec2 m = ImGui::GetMousePos(); - Vec2d sk({(m.x-cx)/m_canvas_scale, -(m.y-cy)/m_canvas_scale}); - if (m_snap_grid) sk = snap(sk); - auto txt = wxString::Format("X:%.1f Y:%.1f", sk.x(), sk.y()).ToStdString(); - dl->AddText({pos.x+4, end.y-16}, IM_COL32(160,160,180,200), txt.c_str()); - if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) - handle_canvas_click({(m.x-cx)/m_canvas_scale, -(m.y-cy)/m_canvas_scale}); - if (ImGui::IsMouseClicked(ImGuiMouseButton_Right)) { - auto& ap2 = active_profile(); - if (ap2.points.size() >= 3) { - ap2.points.push_back(ap2.points.front()); - ap2.closed = true; - m_active_profile = -1; - } - } - } -} - -TopoDS_Shape GLGizmoSketch::build_combined_shape() -{ - if (m_profiles.empty() || !m_profiles[0].closed) - throw std::runtime_error(_u8L("No outer profile")); - - TopoDS_Wire outer_wire = m_profiles[0].to_occt_wire(m_plane); - BRepBuilderAPI_MakeFace face_maker(outer_wire); - if (!face_maker.IsDone()) throw std::runtime_error(_u8L("Failed to make outer face")); - - for (size_t i = 1; i < m_profiles.size(); ++i) { - if (!m_profiles[i].closed) continue; - TopoDS_Wire inner = m_profiles[i].to_occt_wire(m_plane); - face_maker.Add(inner); - } - face_maker.Build(); - if (!face_maker.IsDone()) throw std::runtime_error(_u8L("Failed to build face with holes")); - - TopoDS_Face face = face_maker.Face(); - - TopoDS_Shape shape; - if (m_sp.revolve_deg < 360.0 && m_sp.revolve_deg > 0.0) { - gp_Pnt o(m_plane.origin.x(), m_plane.origin.y(), m_plane.origin.z()); - gp_Dir xd(m_plane.x_axis.x(), m_plane.x_axis.y(), m_plane.x_axis.z()); - gp_Ax1 axis(o, xd); - BRepPrimAPI_MakeRevol rev(face, axis, m_sp.revolve_deg * M_PI / 180.0); - if (!rev.IsDone()) throw std::runtime_error(_u8L("Revolve failed")); - shape = rev.Shape(); - } else { - shape = SketchEngine::make_extrude_face(face, m_plane, m_sp.extrude_len, m_sp.extrude_sym); - } - - if (m_sp.dressup_enabled) { - if (m_sp.dressup_type == DressUpType::Fillet) - shape = GeometryEngine::apply_fillet(shape, m_sp.dressup_radius, m_sp.dressup_faces); - else - shape = GeometryEngine::apply_chamfer(shape, m_sp.dressup_chamfer_dist, m_sp.dressup_faces); - } - return shape; -} - -void GLGizmoSketch::on_render_input_window(float x, float y, float bottom_limit) -{ - y = std::min(y, bottom_limit - ImGui::GetWindowHeight()); - const float scale = m_parent.get_scale(); - ImGuiWrapper::push_toolbar_style(scale); - GizmoImguiSetNextWIndowPos(x, y, ImGuiCond_Always, 0.0f, 0.0f); - GizmoImguiBegin("Sketch", ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove - | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse - | ImGuiWindowFlags_NoTitleBar); - - if (ImGui::CollapsingHeader(_u8L("Profile").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - const std::string names_s[] = {_u8L("Line"), _u8L("Rectangle"), _u8L("Circle"), _u8L("Polygon")}; - const char* names[] = {names_s[0].c_str(), names_s[1].c_str(), names_s[2].c_str(), names_s[3].c_str()}; - int cur = (int)m_tool; - if (ImGui::Combo("##shape", &cur, names, (int)SketchTool::COUNT)) { - m_tool = (SketchTool)cur; - if (m_tool != SketchTool::Line) build_preset_profile(); - } - ImGui::SameLine(); - if (m_imgui->button("+##newprofile")) m_active_profile = -1; - if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _u8L("Start new profile (for holes)").c_str()); - - if (m_tool == SketchTool::Rectangle) { - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble(_u8L("Width").c_str(), &m_rect_w,1,10,"%.0f")) build_preset_profile(); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble(_u8L("Height").c_str(), &m_rect_h,1,10,"%.0f")) build_preset_profile(); - } else if (m_tool == SketchTool::Circle) { - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble(_u8L("Radius").c_str(), &m_circle_r,1,5,"%.0f")) build_preset_profile(); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); if (ImGui::SliderInt(_u8L("Segments").c_str(), &m_circle_seg,8,64)) build_preset_profile(); - } else if (m_tool == SketchTool::Polygon) { - ImGui::SetNextItemWidth(80); if (ImGui::SliderInt(_u8L("Sides").c_str(), &m_poly_sides,3,12)) build_preset_profile(); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); if (ImGui::InputDouble((_u8L("Radius") + "##poly").c_str(), &m_poly_r,1,5,"%.0f")) build_preset_profile(); - } else { - ImGui::Text("%s", _u8L("Click on canvas to draw").c_str()); - } - - ImGui::Checkbox(_u8L("Snap to grid").c_str(), &m_snap_grid); - ImGui::SameLine(); - ImGui::SetNextItemWidth(80); ImGui::InputFloat(_u8L("Grid step").c_str(), &m_grid_step, 1, 5, "%.0f mm"); - - draw_canvas(); - - if (!m_profiles.empty()) { - ImGui::Text("%s: %zu", _u8L("Profiles").c_str(), m_profiles.size()); - for (int i = 0; i < (int)m_profiles.size(); ++i) { - auto& p = m_profiles[i]; - ImGui::PushID(i); - bool outer = (i == 0); - ImVec4 col = outer ? ImVec4(0,1,0,1) : ImVec4(1,0.3f,0.3f,1); - const std::string label = outer ? _u8L("Outer") : _u8L("Hole"); - const std::string state = p.closed ? _u8L("closed") : std::string(); - // TRN Sketch gizmo profile list: "Outer" or "Hole", profile number, point count, "closed" or nothing - ImGui::TextColored(col, "%s", GUI::format(_u8L("%1% %2%: %3% points %4%"), label, i + 1, p.points.size(), state).c_str()); - ImGui::SameLine(); - if (ImGui::SmallButton("X")) delete_profile(i); - ImGui::PopID(); - } - } - } - - ImGui::Separator(); - - bool is_revolve = false; - bool has_sel = false; - - if (ImGui::CollapsingHeader(_u8L("Operation").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { - static int pi = 0; - const std::string plane_names[] = {_u8L("XY (Top)"), _u8L("XZ (Front)"), _u8L("YZ (Side)")}; - const char* planes[] = {plane_names[0].c_str(), plane_names[1].c_str(), plane_names[2].c_str()}; - if (ImGui::Combo(_u8L("Plane").c_str(), &pi, planes, 3)) - m_plane = (pi==0) ? SketchPlane::XY() : (pi==1) ? SketchPlane::XZ() : SketchPlane::YZ(); - - is_revolve = (m_sp.revolve_deg > 0 && m_sp.revolve_deg < 360); - ImGui::SetNextItemWidth(100); - if (ImGui::InputDouble(_u8L("Revolve deg").c_str(), &m_sp.revolve_deg, 15, 90, "%.0f")) { - if (m_sp.revolve_deg > 360) m_sp.revolve_deg = 360; - if (m_sp.revolve_deg < 0) m_sp.revolve_deg = 0; - } - if (ImGui::IsItemHovered()) ImGui::SetTooltip("%s", _u8L("Set to 0 for extrude, >0 for revolve").c_str()); - - if (!is_revolve) { - ImGui::SetNextItemWidth(100); - ImGui::InputDouble(_u8L("Length").c_str(), &m_sp.extrude_len, 0.5, 5, "%.1f mm"); - ImGui::SameLine(); - ImGui::Checkbox(_u8L("Symmetric").c_str(), &m_sp.extrude_sym); - } - - has_sel = !m_parent.get_selection().is_empty(); - if (has_sel) { - if (ImGui::Checkbox(_u8L("Pocket (cut)").c_str(), &m_sp.is_pocket)) - if (m_sp.is_pocket) m_sp.dressup_enabled = false; - } else m_sp.is_pocket = false; - } - - ImGui::Separator(); - - if (!m_sp.is_pocket && ImGui::CollapsingHeader(_u8L("Fillet / Chamfer").c_str())) { - ImGui::Checkbox(_u8L("Enable").c_str(), &m_sp.dressup_enabled); - if (m_sp.dressup_enabled) { - const std::string dn_s[] = {_u8L("Fillet"), _u8L("Chamfer")}; - const char* dn[] = {dn_s[0].c_str(), dn_s[1].c_str()}; - int du = (int)m_sp.dressup_type; - ImGui::SetNextItemWidth(100); - if (ImGui::Combo("##dtype", &du, dn, 2)) m_sp.dressup_type = (DressUpType)du; - const std::string fn_s[] = {_u8L("All edges"), _u8L("Top edges"), _u8L("Bottom edges"), _u8L("Lateral edges")}; - const char* fn[] = {fn_s[0].c_str(), fn_s[1].c_str(), fn_s[2].c_str(), fn_s[3].c_str()}; - int fg = (int)m_sp.dressup_faces; - ImGui::SetNextItemWidth(140); - ImGui::Combo(_u8L("Edges").c_str(), &fg, fn, 4); m_sp.dressup_faces = (FaceGroup)fg; - ImGui::SetNextItemWidth(100); - if (m_sp.dressup_type == DressUpType::Fillet) - ImGui::InputDouble(_u8L("Radius").c_str(), &m_sp.dressup_radius, 0.1, 1, "%.1f mm"); - else - ImGui::InputDouble(_u8L("Distance").c_str(), &m_sp.dressup_chamfer_dist, 0.1, 1, "%.1f mm"); - } - } - - ImGui::Separator(); - - bool ok = has_closed_profile(); - if (ok) ImGui::TextColored({0,1,0,1}, "%s", wxString::Format(_L_PLURAL("%zu closed profile", "%zu closed profiles", - unsigned(m_profiles.size())), m_profiles.size()).ToUTF8().data()); - else ImGui::TextColored({0.6f,0.6f,0.6f,1}, "%s", _u8L("Draw a closed profile to enable").c_str()); - - auto btn = [&](const char* label, bool enabled) { - if (!enabled) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled,true); ImGui::PushStyleColor(ImGuiCol_Button,{0.25f,0.25f,0.25f,1}); } - bool clicked = ImGui::Button(label, {-1,0}); - if (!enabled) { ImGui::PopStyleColor(); ImGui::PopItemFlag(); } - return clicked && enabled; - }; - - if (m_sp.is_pocket && has_sel) { - if (btn(_u8L("Pocket (cut)").c_str(), ok)) apply_pocket(); - } else if (is_revolve) { - if (btn(_u8L("Revolve").c_str(), ok)) apply_revolve(); - } else { - if (btn(_u8L_CONTEXT("Extrude", "Design").c_str(), ok)) apply_extrude(); - } - - if (ImGui::Button(_u8L("Clear all").c_str(), {-1,0})) clear_all(); - if (ImGui::Button(_u8L("Close").c_str(), {-1,0})) m_parent.reset_all_gizmos(); - - GizmoImguiEnd(); - ImGuiWrapper::pop_toolbar_style(); -} - -void GLGizmoSketch::apply_extrude() -{ - try { - TopoDS_Shape shape = build_combined_shape(); - TriangleMesh mesh = SketchEngine::tessellate(shape, m_sp.linear_deflection); - if (mesh.its.indices.empty()) throw std::runtime_error(_u8L("Empty result")); - wxGetApp().plater()->take_snapshot("Sketch Extrude"); - ModelObject* mo = wxGetApp().model().add_object(); - mo->name = "Extrusion"; - mo->add_volume(std::move(mesh))->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); - clear_all(); - } catch (const std::exception& e) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::ErrorNotificationLevel, GUI::format(_u8L("Extrude: %1%"), e.what())); - } -} - -void GLGizmoSketch::apply_revolve() -{ - try { - TopoDS_Shape shape = build_combined_shape(); - TriangleMesh mesh = SketchEngine::tessellate(shape, m_sp.linear_deflection); - if (mesh.its.indices.empty()) throw std::runtime_error(_u8L("Empty result")); - wxGetApp().plater()->take_snapshot("Sketch Revolve"); - ModelObject* mo = wxGetApp().model().add_object(); - mo->name = "Revolve"; - mo->add_volume(std::move(mesh))->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); - clear_all(); - } catch (const std::exception& e) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::ErrorNotificationLevel, GUI::format(_u8L("Revolve: %1%"), e.what())); - } -} - -void GLGizmoSketch::apply_pocket() -{ - try { - Selection& sel = m_parent.get_selection(); - int obj_idx = sel.get_object_idx(); - if (obj_idx < 0) throw std::runtime_error(_u8L("No object selected")); - ModelObject* mo = wxGetApp().model().objects[obj_idx]; - - TopoDS_Wire outer = m_profiles[0].to_occt_wire(m_plane); - BRepBuilderAPI_MakeFace fm(outer); - if (!fm.IsDone()) throw std::runtime_error(_u8L("Face failed")); - for (size_t i = 1; i < m_profiles.size(); ++i) - if (m_profiles[i].closed) fm.Add(m_profiles[i].to_occt_wire(m_plane)); - fm.Build(); - if (!fm.IsDone()) throw std::runtime_error(_u8L("Face with holes failed")); - - TopoDS_Shape tool = SketchEngine::make_extrude_face(fm.Face(), m_plane, m_sp.extrude_len + 5.0, false); - TriangleMesh tool_mesh = SketchEngine::tessellate(tool, m_sp.linear_deflection); - if (tool_mesh.its.indices.empty()) throw std::runtime_error(_u8L("Tool mesh empty")); - - wxGetApp().plater()->take_snapshot("Sketch Pocket"); - mo->add_volume(std::move(tool_mesh), ModelVolumeType::NEGATIVE_VOLUME)->set_new_unique_id(); - mo->ensure_on_bed(); - wxGetApp().plater()->update(); - clear_all(); - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::RegularNotificationLevel, _u8L("Pocket added (negative volume)").c_str()); - } catch (const std::exception& e) { - wxGetApp().notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::ErrorNotificationLevel, GUI::format(_u8L("Pocket: %1%"), e.what())); - } -} - -} // namespace GUI -} // namespace Slic3r diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp b/src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp deleted file mode 100644 index 257fac8c6d..0000000000 --- a/src/slic3r/GUI/Gizmos/GLGizmoSketch.hpp +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef slic3r_GLGizmoSketch_hpp_ -#define slic3r_GLGizmoSketch_hpp_ - -#include "GLGizmoBase.hpp" -#include "GLGizmosCommon.hpp" -#include "libslic3r/CAD/SketchEngine.hpp" -#include -#include -#include -#include -#include -#include -#include "libslic3r/Point.hpp" - -namespace Slic3r { -namespace GUI { - -enum class SketchTool { Line, Rectangle, Circle, Polygon, COUNT }; - -class GLGizmoSketch : public GLGizmoBase -{ -public: - GLGizmoSketch(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id); - - bool on_mouse(const wxMouseEvent& mouse_event) override; - -protected: - bool on_init() override; - std::string on_get_name() const override; - bool on_is_activable() const override; - bool on_is_selectable() const override; - void on_render() override; - void on_set_state() override; - CommonGizmosDataID on_get_requirements() const override; - void on_render_input_window(float x, float y, float bottom_limit) override; - - void on_load(cereal::BinaryInputArchive& ar) override; - void on_save(cereal::BinaryOutputArchive& ar) const override; - -private: - SketchTool m_tool{SketchTool::Line}; - std::vector m_profiles; // multiple profiles (outer + holes) - SketchPlane m_plane{SketchPlane::XY()}; - SketchParams m_sp; - - // Shape presets - double m_rect_w{20}, m_rect_h{15}; - double m_circle_r{10}; int m_circle_seg{32}; - int m_poly_sides{6}; double m_poly_r{10}; - - // Canvas - std::vector m_canvas_points; - Vec2d m_canvas_center{0,0}; - float m_canvas_scale{5.0f}; - bool m_snap_grid{true}; - float m_grid_step{5.0f}; - - // Current profile being drawn - int m_active_profile{-1}; - - SketchProfile& active_profile(); - bool has_closed_profile() const; - - void build_preset_profile(); - void add_closed_profile(); - void delete_profile(int idx); - void clear_all(); - - TopoDS_Shape build_combined_shape(); // all profiles as face with holes - void apply_extrude(); - void apply_revolve(); - void apply_pocket(); - void draw_canvas(); - void handle_canvas_click(ImVec2 pos); - Vec2d snap(Vec2d pt) const; -}; - -} // namespace GUI -} // namespace Slic3r - -#endif // slic3r_GLGizmoSketch_hpp_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index f8c65e9ac9..00bdd13bcb 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -50,10 +50,6 @@ #include #include #include "libslic3r/AppConfig.hpp" -#ifdef SLIC3R_CAD -#include "slic3r/GUI/Gizmos/GLGizmoPrimitive.hpp" -#include "slic3r/GUI/Gizmos/GLGizmoSketch.hpp" -#endif #include "libslic3r/Model.hpp" @@ -217,14 +213,6 @@ void GLGizmosManager::switch_gizmos_icon_filename() case (EType::BrimEars): gizmo->set_icon_filename(m_is_dark ? "toolbar_brimears_dark.svg" : "toolbar_brimears.svg"); break; -#ifdef SLIC3R_CAD - case (EType::Primitive): - gizmo->set_icon_filename(m_is_dark ? "toolbar_modifier_cube_dark.svg" : "toolbar_modifier_cube.svg"); - break; - case (EType::Sketch): - gizmo->set_icon_filename(m_is_dark ? "toolbar_sketch_dark.svg" : "toolbar_sketch.svg"); - break; -#endif } } @@ -270,14 +258,6 @@ bool GLGizmosManager::init() m_gizmos.emplace_back(new GLGizmoAssembly(m_parent, m_is_dark ? "toolbar_assembly_dark.svg" : "toolbar_assembly.svg", EType::Assembly)); m_gizmos.emplace_back(new GLGizmoSimplify(m_parent, "reduce_triangles.svg", EType::Simplify)); m_gizmos.emplace_back(new GLGizmoBrimEars(m_parent, m_is_dark ? "toolbar_brimears_dark.svg" : "toolbar_brimears.svg", EType::BrimEars)); -#ifdef SLIC3R_CAD - // Registered last: Primitive and Sketch are the final entries before Undefined, so - // omitting them leaves every preceding m_gizmos index (indexed by EType) untouched. - if (wxGetApp().is_enable_cad_feature()) { - m_gizmos.emplace_back(new GLGizmoPrimitive(m_parent, m_is_dark ? "toolbar_modifier_cube_dark.svg" : "toolbar_modifier_cube.svg", static_cast(Primitive))); - m_gizmos.emplace_back(new GLGizmoSketch(m_parent, m_is_dark ? "toolbar_sketch_dark.svg" : "toolbar_sketch.svg", static_cast(Sketch))); - } -#endif //m_gizmos.emplace_back(new GLGizmoSlaSupports(m_parent, "sla_supports.svg", sprite_id++)); //m_gizmos.emplace_back(new GLGizmoFaceDetector(m_parent, "face recognition.svg", sprite_id++)); //m_gizmos.emplace_back(new GLGizmoHollow(m_parent, "hollow.svg", sprite_id++)); @@ -1375,8 +1355,7 @@ GLGizmoBase* GLGizmosManager::get_current() const GLGizmoBase* GLGizmosManager::get_gizmo(GLGizmosManager::EType type) const { - // m_gizmos ends before the enum does when the CAD gizmos are not registered. - return type < m_gizmos.size() ? m_gizmos[type].get() : nullptr; + return ((type == Undefined) || m_gizmos.empty()) ? nullptr : m_gizmos[type].get(); } GLGizmosManager::EType GLGizmosManager::get_gizmo_from_name(const std::string& gizmo_name) const diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index 855e26c102..3f53eeaa93 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -102,12 +102,6 @@ public: Assembly, Simplify, BrimEars, -#ifdef SLIC3R_CAD - // Both need the CAD kernel (GeometryEngine); keep them last so that with - // SLIC3R_CAD off the enum matches upstream's numbering exactly. - Primitive, - Sketch, -#endif //SlaSupports, // BBS //FaceRecognition,