From ac19851e5254d1a6d54492d08b9c5734eed9020f Mon Sep 17 00:00:00 2001 From: "zhimin.zeng" Date: Tue, 19 Nov 2024 14:40:43 +0800 Subject: [PATCH] ENH: Add automatic slicing behavior for some steps jira: none Change-Id: If94726eee45724985b3b49b36695086da24f7848 (cherry picked from commit 0476a83264660841c5601168ab6f11a9c70411ff) --- src/slic3r/GUI/GCodeViewer.cpp | 2 +- src/slic3r/GUI/Plater.cpp | 21 +++++++++++++++------ src/slic3r/GUI/Plater.hpp | 4 ++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index a597e92893..b7940609e0 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -4408,7 +4408,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding) Plater *plater = wxGetApp().plater(); wxCommandEvent evt(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG); evt.SetEventObject(plater); - evt.SetInt(0); + evt.SetInt(0b0010); //0010 means from gcode view, manual mode wxPostEvent(plater, evt); } } diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4dbe5a3efc..15c5766611 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -8496,6 +8496,8 @@ bool Plater::priv::check_ams_status_impl() dlg.Fit(); if (dlg.ShowModal() == wxID_YES) { GUI::wxGetApp().sidebar().sync_extruder_list(); + wxPostEvent(q, SimpleEvent(EVT_GLTOOLBAR_SLICE_PLATE)); + wxGetApp().mainframe->m_tabpanel->SetSelection(MainFrame::TabPosition::tpPreview); return false; } } @@ -14753,12 +14755,14 @@ void Plater::open_platesettings_dialog(wxCommandEvent& evt) { void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt) { PartPlate* curr_plate = p->partplate_list.get_curr_plate(); - int is_auto = evt.GetInt(); + int value = evt.GetInt(); + bool is_auto = value & 1; //0000 means manual, 0001 means auto + bool need_slice = value & (1 << 1); //0010 means from gcode view, 0000 means not from gcode view FilamentMapDialog filament_dlg(this, config(), curr_plate->get_filament_maps(), curr_plate->get_extruders(true), - is_auto==1, + is_auto, curr_plate->has_auto_filament_map_reslut() ); if (filament_dlg.ShowModal() == wxID_OK) { @@ -14782,9 +14786,14 @@ void Plater::open_filament_map_setting_dialog(wxCommandEvent &evt) need_invalidate = true; } if (need_invalidate) { - curr_plate->update_slice_result_valid_state(false); - set_plater_dirty(true); - update(); + if (need_slice) { + wxPostEvent(this, SimpleEvent(EVT_GLTOOLBAR_SLICE_PLATE)); + } + else { + curr_plate->update_slice_result_valid_state(false); + set_plater_dirty(true); + update(); + } } } return; @@ -14952,7 +14961,7 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi if (!ret) { PartPlate * curr_plate = p->partplate_list.get_curr_plate(); wxCommandEvent evt(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG); - evt.SetInt(curr_plate->get_filament_map_mode()==FilamentMapMode::fmmAuto); + evt.SetInt(curr_plate->get_filament_map_mode()==FilamentMapMode::fmmAuto ? 1 : 0); evt.SetEventObject(this); wxPostEvent(this, evt); } else { diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index e6d0e920b4..3fc1d7d786 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -91,6 +91,10 @@ enum class ActionButtonType : int; wxDECLARE_EVENT(EVT_SLICING_UPDATE, Slic3r::SlicingStatusEvent); wxDECLARE_EVENT(EVT_PUBLISH, wxCommandEvent); wxDECLARE_EVENT(EVT_OPEN_PLATESETTINGSDIALOG, wxCommandEvent); + +// Explanation of int param +// Bit 0: 1 = automatic mode, 0 = manual mode. +// Bit 1: 1 = need auto slicing(from preview page), 0 = not need auto slicing. wxDECLARE_EVENT(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG, wxCommandEvent); wxDECLARE_EVENT(EVT_REPAIR_MODEL, wxCommandEvent); wxDECLARE_EVENT(EVT_FILAMENT_COLOR_CHANGED, wxCommandEvent);