Added menu Edit -> Delete selected

This commit is contained in:
Enrico Turri 2018-11-21 15:47:41 +01:00
parent 681beeadf6
commit 3e939a7496
4 changed files with 15 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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