From f042c817a7ed21b4b18915e2a649aed733a80f48 Mon Sep 17 00:00:00 2001 From: "xun.zhang" Date: Thu, 13 Feb 2025 22:53:57 +0800 Subject: [PATCH] ENH: refine logic with filament group 1. In slice plate mode,force use plate mode 2. In slice all mode, force use global mode jira:STUDIO-10390 Signed-off-by: xun.zhang Change-Id: I3edb559043fdc52339b7f611643b8f5ac116571d --- src/slic3r/GUI/FilamentGroupPopup.cpp | 15 ++++++++++++--- src/slic3r/GUI/FilamentGroupPopup.hpp | 3 ++- src/slic3r/GUI/FilamentMapDialog.cpp | 22 ++++++++++++++++------ src/slic3r/GUI/FilamentMapDialog.hpp | 4 ++-- src/slic3r/GUI/PartPlate.cpp | 1 + src/slic3r/GUI/Plater.cpp | 2 +- 6 files changed, 34 insertions(+), 13 deletions(-) diff --git a/src/slic3r/GUI/FilamentGroupPopup.cpp b/src/slic3r/GUI/FilamentGroupPopup.cpp index 033152cc9..53f972700 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.cpp +++ b/src/slic3r/GUI/FilamentGroupPopup.cpp @@ -254,13 +254,14 @@ void FilamentGroupPopup::Init() GUI::wxGetApp().UpdateDarkUIWin(this); } -void FilamentGroupPopup::tryPopup(Plater* plater,PartPlate* partplate,bool skip_plate_sync) +void FilamentGroupPopup::tryPopup(Plater* plater,PartPlate* partplate,bool slice_all) { if (should_pop_up()) { bool connect_status = plater->get_machine_sync_status(); this->partplate_ref = partplate; this->plater_ref = plater; - this->m_sync_plate = !skip_plate_sync && partplate->get_filament_map_mode() != fmmDefault; + this->m_sync_plate = true; + this->m_slice_all = slice_all; if (m_active) { if (m_connected != connect_status) { Init(); } m_connected = connect_status; @@ -289,7 +290,15 @@ FilamentMapMode FilamentGroupPopup::GetFilamentMapMode() const void FilamentGroupPopup::SetFilamentMapMode(const FilamentMapMode mode) { if (m_sync_plate) { - partplate_ref->set_filament_map_mode(mode); + if (m_slice_all) { + auto plate_list = plater_ref->get_partplate_list().get_plate_list(); + for (int i = 0; i < plate_list.size(); ++i) { + plate_list[i]->set_filament_map_mode(mode); + } + } + else { + partplate_ref->set_filament_map_mode(mode); + } return; } plater_ref->set_global_filament_map_mode(mode); diff --git a/src/slic3r/GUI/FilamentGroupPopup.hpp b/src/slic3r/GUI/FilamentGroupPopup.hpp index 314772823..af59a700f 100644 --- a/src/slic3r/GUI/FilamentGroupPopup.hpp +++ b/src/slic3r/GUI/FilamentGroupPopup.hpp @@ -14,7 +14,7 @@ class FilamentGroupPopup : public PopupWindow { public: FilamentGroupPopup(wxWindow *parent); - void tryPopup(Plater* plater,PartPlate* plate,bool skip_plate_sync); + void tryPopup(Plater* plater,PartPlate* plate, bool slice_all); void tryClose(); FilamentMapMode GetSelectedMode() const { return m_mode; } @@ -45,6 +45,7 @@ private: bool m_active{ false }; bool m_sync_plate{ false }; + bool m_slice_all{ false }; FilamentMapMode m_mode; wxTimer *m_timer; diff --git a/src/slic3r/GUI/FilamentMapDialog.cpp b/src/slic3r/GUI/FilamentMapDialog.cpp index 6d6038208..0c4ba6e9b 100644 --- a/src/slic3r/GUI/FilamentMapDialog.cpp +++ b/src/slic3r/GUI/FilamentMapDialog.cpp @@ -37,7 +37,7 @@ extern std::string& get_left_extruder_unprintable_text(); extern std::string& get_right_extruder_unprintable_text(); -bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate* partplate_ref) +bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* partplate_ref) { auto full_config = wxGetApp().preset_bundle->full_config(); const auto nozzle_diameters = full_config.option("nozzle_diameter"); @@ -45,7 +45,7 @@ bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate return true; bool force_pop_up = get_pop_up_remind_flag(); - bool sync_plate = !skip_plate_sync && partplate_ref->get_filament_map_mode() != fmmDefault; + bool sync_plate = true; std::vector filament_colors = full_config.option("filament_colour")->values; FilamentMapMode applied_mode = get_applied_map_mode(full_config, plater_ref,partplate_ref, sync_plate); @@ -56,7 +56,7 @@ bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate return true; std::vector filament_lists; - if (skip_plate_sync) { + if (is_slice_all) { filament_lists.resize(filament_colors.size()); std::iota(filament_lists.begin(), filament_lists.end(), 1); } @@ -79,9 +79,19 @@ bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate FilamentMapMode new_mode = map_dlg.get_mode(); std::vector new_maps = map_dlg.get_filament_maps(); if (sync_plate) { - partplate_ref->set_filament_map_mode(new_mode); - if (new_mode == fmmManual) - partplate_ref->set_filament_maps(new_maps); + if (is_slice_all) { + auto plate_list = plater_ref->get_partplate_list().get_plate_list(); + for (int i = 0; i < plate_list.size(); ++i) { + plate_list[i]->set_filament_map_mode(new_mode); + if(new_mode == fmmManual) + plate_list[i]->set_filament_maps(new_maps); + } + } + else { + partplate_ref->set_filament_map_mode(new_mode); + if (new_mode == fmmManual) + partplate_ref->set_filament_maps(new_maps); + } } else { plater_ref->set_global_filament_map_mode(new_mode); diff --git a/src/slic3r/GUI/FilamentMapDialog.hpp b/src/slic3r/GUI/FilamentMapDialog.hpp index cab5cbda5..99fd50aca 100644 --- a/src/slic3r/GUI/FilamentMapDialog.hpp +++ b/src/slic3r/GUI/FilamentMapDialog.hpp @@ -22,12 +22,12 @@ class PartPlate; * Only pop up in multi extruder machines. If user don't want the pop up, we * pop up if the applied filament map mode in manual * - * @param skip_plate_sync whether sync the map mode change to plate. In slice all, we should skip the sync and change on global param + * @param is_slice_all In slice all * @param plater_ref Plater to get/set global filament map * @param partplate_ref Partplate to get/set plate filament map mode * @return whether continue slicing */ -bool try_pop_up_before_slice(bool skip_plate_sync, Plater* plater_ref, PartPlate* partplate_ref); +bool try_pop_up_before_slice(bool is_slice_all, Plater* plater_ref, PartPlate* partplate_ref); class FilamentMapDialog : public wxDialog diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index f6df098be..5678caa27 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -140,6 +140,7 @@ void PartPlate::init() m_print_index = -1; m_print = nullptr; + m_config.option>("filament_map_mode", true)->value = FilamentMapMode::fmmAutoForFlush; } BedType PartPlate::get_bed_type(bool load_from_project) const diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6f23e01b4..e11770073 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -16080,7 +16080,7 @@ void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt) curr_plate->get_extruders(true), plate_filament_map_mode, this->get_machine_sync_status(), - true + false ); if (filament_dlg.ShowModal() == wxID_OK) {