From 2b23e3c119f774b898464284d0696b50fa9ab8d3 Mon Sep 17 00:00:00 2001 From: Stone Li Date: Thu, 17 Nov 2022 14:37:01 +0800 Subject: [PATCH] NEW: add menu item of per object process Change-Id: I09c7516903e59e976f582d7efaff33cc3033c820 Signed-off-by: Stone Li --- src/slic3r/GUI/GUI_Factories.cpp | 14 ++++++++++++++ src/slic3r/GUI/GUI_Factories.hpp | 1 + src/slic3r/GUI/GUI_ObjectList.cpp | 13 ++++++++++++- src/slic3r/GUI/GUI_ObjectList.hpp | 1 + src/slic3r/GUI/ParamsPanel.cpp | 12 +++++++----- src/slic3r/GUI/ParamsPanel.hpp | 3 ++- 6 files changed, 37 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 76a93c2a1..26a96a367 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -979,6 +979,7 @@ void MenuFactory::create_bbl_object_menu() // Set filament insert menu item here // Set Printable wxMenuItem* menu_item_printable = append_menu_item_printable(&m_object_menu); + append_menu_item_per_object_process(&m_object_menu); // Enter per object parameters append_menu_item_per_object_settings(&m_object_menu); m_object_menu.AppendSeparator(); @@ -1363,6 +1364,19 @@ void MenuFactory::append_menu_item_center(wxMenu* menu) }, m_parent); } +void MenuFactory::append_menu_item_per_object_process(wxMenu* menu) +{ + const std::vector names = {_L("Edit Object Process"), _L("Edit Object Process")}; + append_menu_item(menu, wxID_ANY, names[0], names[1], + [](wxCommandEvent&) { + wxGetApp().obj_list()->switch_to_object_process(); + }, "", nullptr, + []() { + Selection& selection = plater()->canvas3D()->get_selection(); + return selection.is_single_full_object() || selection.is_single_full_instance() || selection.is_single_volume(); + }, m_parent); +} + void MenuFactory::append_menu_item_per_object_settings(wxMenu* menu) { const std::vector names = { _L("Edit in Parameter Table"), _L("Edit print parameters for a single object") }; diff --git a/src/slic3r/GUI/GUI_Factories.hpp b/src/slic3r/GUI/GUI_Factories.hpp index d2427c76e..a2e2e73d2 100644 --- a/src/slic3r/GUI/GUI_Factories.hpp +++ b/src/slic3r/GUI/GUI_Factories.hpp @@ -140,6 +140,7 @@ private: void append_menu_item_clone(wxMenu* menu); void append_menu_item_simplify(wxMenu* menu); void append_menu_item_center(wxMenu* menu); + void append_menu_item_per_object_process(wxMenu* menu); void append_menu_item_per_object_settings(wxMenu* menu); void append_menu_item_change_filament(wxMenu* menu); void append_menu_item_set_printable(wxMenu* menu); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 052353e0d..52385aafa 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1979,7 +1979,18 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const Mode //Show Dialog if (wxGetApp().app_config->get("do_not_show_modifer_tips").empty()) { - TipsDialog dlg(wxGetApp().mainframe, _L("Add Modifier")); + TipsDialog dlg(wxGetApp().mainframe, _L("Add Modifier"), _L("Switch to per-object setting mode to edit modifier settings."), "do_not_show_modifer_tips"); + dlg.ShowModal(); + } +} + +void ObjectList::switch_to_object_process() +{ + wxGetApp().params_panel()->switch_to_object(true); + + // Show Dialog + if (wxGetApp().app_config->get("do_not_show_object_process_tips").empty()) { + TipsDialog dlg(wxGetApp().mainframe, _L("Edit Object Process"), _L("Switch to per-object setting mode to edit object process."), "do_not_show_object_process_tips"); dlg.ShowModal(); } } diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 0192983ff..e7e3e25de 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -282,6 +282,7 @@ public: void load_shape_object(const std::string &type_name); void load_mesh_object(const TriangleMesh &mesh, const wxString &name, bool center = true); // BBS + void switch_to_object_process(); void load_mesh_part(const TriangleMesh& mesh, const wxString& name, bool center = true); void del_object(const int obj_idx, bool refresh_immediately = true); void del_subobject_item(wxDataViewItem& item); diff --git a/src/slic3r/GUI/ParamsPanel.cpp b/src/slic3r/GUI/ParamsPanel.cpp index 15d42631c..917a55d7f 100644 --- a/src/slic3r/GUI/ParamsPanel.cpp +++ b/src/slic3r/GUI/ParamsPanel.cpp @@ -22,8 +22,9 @@ namespace Slic3r { namespace GUI { -TipsDialog::TipsDialog(wxWindow *parent, const wxString &title) - : DPIDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) +TipsDialog::TipsDialog(wxWindow *parent, const wxString &title, const wxString &description, std::string app_key) + : DPIDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX), + m_app_key(app_key) { SetBackgroundColour(*wxWHITE); std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str(); @@ -38,7 +39,7 @@ TipsDialog::TipsDialog(wxWindow *parent, const wxString &title) m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(20)); - m_msg = new wxStaticText(this, wxID_ANY, _L("Switch to per-object setting mode to edit modifier settings."), wxDefaultPosition, wxDefaultSize, 0); + m_msg = new wxStaticText(this, wxID_ANY, description, wxDefaultPosition, wxDefaultSize, 0); m_msg->Wrap(-1); m_msg->SetFont(::Label::Body_13); m_msg->SetForegroundColour(wxColour(107, 107, 107)); @@ -51,7 +52,7 @@ TipsDialog::TipsDialog(wxWindow *parent, const wxString &title) wxBoxSizer *m_sizer_bottom = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *m_sizer_left = new wxBoxSizer(wxHORIZONTAL); - auto dont_show_again = create_item_checkbox(_L("Don't show again"), this, _L("Don't show again"), "do_not_show_modifer_tips"); + auto dont_show_again = create_item_checkbox(_L("Don't show again"), this, _L("Don't show again"), "do_not_show_tips"); m_sizer_left->Add(dont_show_again, 1, wxALL, FromDIP(5)); m_sizer_bottom->Add(m_sizer_left, 1, wxEXPAND, FromDIP(5)); @@ -119,7 +120,8 @@ void TipsDialog::on_dpi_changed(const wxRect &suggested_rect) void TipsDialog::on_ok(wxMouseEvent &event) { if (m_show_again) { - wxGetApp().app_config->set_bool("do_not_show_modifer_tips", m_show_again); + if (!m_app_key.empty()) + wxGetApp().app_config->set_bool(m_app_key, m_show_again); } EndModal(wxID_OK); } diff --git a/src/slic3r/GUI/ParamsPanel.hpp b/src/slic3r/GUI/ParamsPanel.hpp index b85ceacf8..848e546d6 100644 --- a/src/slic3r/GUI/ParamsPanel.hpp +++ b/src/slic3r/GUI/ParamsPanel.hpp @@ -43,9 +43,10 @@ class TipsDialog : public DPIDialog { private: bool m_show_again{false}; + std::string m_app_key; public: - TipsDialog(wxWindow *parent, const wxString &title); + TipsDialog(wxWindow *parent, const wxString &title, const wxString &description, std::string app_key = ""); Button *m_confirm{nullptr}; Button *m_cancel{nullptr}; wxPanel *m_top_line{nullptr};