From 3e939a7496d32723f756475389ca77e7b15a9410 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 21 Nov 2018 15:47:41 +0100 Subject: [PATCH] Added menu Edit -> Delete selected --- src/slic3r/GUI/MainFrame.cpp | 8 ++++++++ src/slic3r/GUI/MainFrame.hpp | 1 + src/slic3r/GUI/Plater.cpp | 5 +++++ src/slic3r/GUI/Plater.hpp | 1 + 4 files changed, 15 insertions(+) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 0c3b75e71..db5b8a650 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -206,6 +206,11 @@ bool MainFrame::can_select() const { return (m_plater != nullptr) ? !m_plater->model().objects.empty() : false; } + +bool MainFrame::can_delete() const +{ + return (m_plater != nullptr) ? !m_plater->is_selection_empty() : false; +} #endif // ENABLE_NEW_MENU_LAYOUT void MainFrame::init_menubar() @@ -314,8 +319,11 @@ void MainFrame::init_menubar() editMenu = new wxMenu(); wxMenuItem* item_select_all = append_menu_item(editMenu, wxID_ANY, L("Select all\tCtrl+A"), L("Selects all objects"), [this](wxCommandEvent&) { m_plater->select_all(); }, ""); + wxMenuItem* item_delete_sel = append_menu_item(editMenu, wxID_ANY, L("Delete selected\tCtrl+D"), L("Deletes the current selection"), + [this](wxCommandEvent&) { m_plater->remove_selected(); }, ""); Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_select()); }, item_select_all->GetId()); + Bind(wxEVT_UPDATE_UI, [this](wxUpdateUIEvent& evt) { evt.Enable(can_delete()); }, item_delete_sel->GetId()); } #endif // ENABLE_NEW_MENU_LAYOUT diff --git a/src/slic3r/GUI/MainFrame.hpp b/src/slic3r/GUI/MainFrame.hpp index 8b534e324..488d0bd04 100644 --- a/src/slic3r/GUI/MainFrame.hpp +++ b/src/slic3r/GUI/MainFrame.hpp @@ -72,6 +72,7 @@ class MainFrame : public wxFrame bool can_export_gcode() const; bool can_change_view() const; bool can_select() const; + bool can_delete() const; #endif // ENABLE_NEW_MENU_LAYOUT public: diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index df15f8207..f3b3318db 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2366,6 +2366,11 @@ void Plater::set_number_of_copies(/*size_t num*/) decrease_instances(-diff); } +bool Plater::is_selection_empty() const +{ + return p->get_selection().is_empty(); +} + void Plater::cut(size_t obj_idx, size_t instance_idx, coordf_t z) { wxCHECK_RET(obj_idx < p->model.objects.size(), "obj_idx out of bounds"); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 9214db4cb..b9cc9d528 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -135,6 +135,7 @@ public: void increase_instances(size_t num = 1); void decrease_instances(size_t num = 1); void set_number_of_copies(/*size_t num*/); + bool is_selection_empty() const; void cut(size_t obj_idx, size_t instance_idx, coordf_t z);