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 <xun.zhang@bambulab.com>
Change-Id: I3edb559043fdc52339b7f611643b8f5ac116571d
This commit is contained in:
xun.zhang 2025-02-13 22:53:57 +08:00 committed by lane.wei
parent 0381d5827c
commit f042c817a7
6 changed files with 34 additions and 13 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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<ConfigOptionFloatsNullable>("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<std::string> filament_colors = full_config.option<ConfigOptionStrings>("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<int> 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<int> 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);

View File

@ -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

View File

@ -140,6 +140,7 @@ void PartPlate::init()
m_print_index = -1;
m_print = nullptr;
m_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = FilamentMapMode::fmmAutoForFlush;
}
BedType PartPlate::get_bed_type(bool load_from_project) const

View File

@ -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) {