From 23b98e2ca56ccd0adb0bca2d12a5a5ee503a5c16 Mon Sep 17 00:00:00 2001 From: Lam Wei Lun Date: Thu, 27 Aug 2026 17:04:27 +0800 Subject: [PATCH] Initial commit for warning popup when required filaments are not selected for mixed filaments --- src/slic3r/GUI/PublishSettingsDialog.cpp | 66 +++++++++++++++++++++++- src/slic3r/GUI/PublishSettingsDialog.hpp | 5 ++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/PublishSettingsDialog.cpp b/src/slic3r/GUI/PublishSettingsDialog.cpp index 262fdbe356..be28ae7499 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.cpp +++ b/src/slic3r/GUI/PublishSettingsDialog.cpp @@ -416,7 +416,24 @@ PublishSettingsDialog::PublishSettingsDialog(wxWindow* parent) auto dlg_btns = new DialogButtons(this, {"OK", "Cancel"}); dlg_btns->GetOK()->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { - // Publish is always allowed: no settings selected means no settings override. + // Publish is always allowed: no settings selected means no settings override. Warn only + // when an enabled mixed filament would ship without the identity of one of its + // components; "Proceed" accepts that and publishes anyway. + if (const std::vector missing = unpublished_mixed_components(); !missing.empty()) { + wxString missing_list; + for (size_t i = 0; i < missing.size(); ++i) { + if (i > 0) + missing_list += ", "; + missing_list += wxString::Format(_L("Filament %d"), int(missing[i] + 1)); + } + const wxString msg = _L("The following filaments are used by published mixed filaments but will not carry their material identity:") + + wxString(" ") + missing_list; + MessageDialog warn(this, msg, _L("Warning"), wxICON_WARNING); + warn.AddButton(wxID_CANCEL, _L("Cancel"), true); // safe choice gets the focus + warn.AddButton(wxID_OK, _L("Proceed"), false); + if (warn.ShowModal() != wxID_OK) + return; // Cancel: dismiss the warning and stay in this dialog + } EndModal(wxID_OK); }); dlg_btns->GetCANCEL()->Bind(wxEVT_BUTTON, [this](wxCommandEvent&) { EndModal(wxID_CANCEL); }); @@ -1695,6 +1712,53 @@ std::vector PublishSettingsDialog::GetPublishedKeys() const return out; } +std::vector PublishSettingsDialog::unpublished_mixed_components() const +{ + std::set missing; + for (const Category& cat : m_categories) { + if (!cat.is_mixed || cat.section != Section::Material) + continue; + // Only enabled mixed slots depend on their components being published. + if (cat.enable_check == nullptr || !cat.enable_check->GetValue()) + continue; + const DynamicPrintConfig full = wxGetApp().preset_bundle->full_config(); + // Components are 1-based physical filament indices. + for (const unsigned int component : mixed_slot_components(full, cat.filament_slot)) { + const size_t component_slot = size_t(component) - 1; + // Find the component slot's material category (one exists per physical slot). + const Category* comp_cat = nullptr; + for (const Category& other : m_categories) { + if (other.section == Section::Material && !other.is_mixed && other.filament_slot == component_slot) { + comp_cat = &other; + break; + } + } + if (comp_cat == nullptr || comp_cat->enable_check == nullptr) + continue; + // Missing when the component's "Enable" is off, or it is enabled with neither + // "Full Publish" nor the "Type" requirement row checked. Colour never counts: + // the receiver renders the mix from its own components' colours. + if (!comp_cat->enable_check->GetValue()) { + missing.insert(component_slot); + continue; + } + if (comp_cat->full_check != nullptr && comp_cat->full_check->GetValue()) + continue; + bool type_checked = false; + for (const size_t r : comp_cat->rows) { + const Row& row = m_rows[r]; + if (row.kind == RowKind::Type && row.check->GetValue()) { + type_checked = true; + break; + } + } + if (!type_checked) + missing.insert(component_slot); + } + } + return std::vector(missing.begin(), missing.end()); +} + std::vector PublishSettingsDialog::GetPublishedMaterialKeys() const { std::vector out; diff --git a/src/slic3r/GUI/PublishSettingsDialog.hpp b/src/slic3r/GUI/PublishSettingsDialog.hpp index e00bec37fd..60c33e5a2d 100644 --- a/src/slic3r/GUI/PublishSettingsDialog.hpp +++ b/src/slic3r/GUI/PublishSettingsDialog.hpp @@ -187,6 +187,11 @@ private: // "Enable" toggled on a material slot: reveals/hides everything below the header and, for a // mixed slot, auto-selects its component filaments' "Enable" + "Full Publish" toggles. void on_enable_toggle(size_t category_index); + // 0-based material slots required by enabled mixed-filament slots that would ship without + // their identity: "Enable" not checked, or enabled with neither "Full Publish" nor the + // "Type" requirement row checked. Colour is deliberately ignored (the receiver renders the + // mix from its own components' colours). Sorted, deduplicated. + std::vector unpublished_mixed_components() const; // Read-only visualization of a mixed slot's definition (a stacked ratio bar, or the // Material Ratio vs Model Height graph for a gradient), inserted above the info hint // inside the category's scroll area.