From 967da67d2e228060ef5cb50ff2da2ddf46f3120c Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 12 Dec 2019 15:54:53 +0100 Subject: [PATCH] Fixed disabling for "Set As separated object" context menu item + added missed bug fix in get_freq_settings_choice (part of b9899f9496029354b3c96a5088f56e2f03a1338d) --- src/slic3r/GUI/GUI_ObjectList.cpp | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 7e5353718..c0520cb9a 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -1324,11 +1324,17 @@ void ObjectList::get_freq_settings_choice(const wxString& bundle_name) { std::vector options = get_options_for_bundle(bundle_name); const Selection& selection = scene_selection(); - wxDataViewItem item = GetSelectedItemsCount() > 1 && selection.is_single_full_object() ? - m_objects_model->GetItemById(selection.get_object_idx()) : - GetSelection(); + const wxDataViewItem sel_item = // when all instances in object are selected + GetSelectedItemsCount() > 1 && selection.is_single_full_object() ? + m_objects_model->GetItemById(selection.get_object_idx()) : + GetSelection(); - ItemType item_type = m_objects_model->GetItemType(item); + /* If we try to add settings for object/part from 3Dscene, + * for the second try there is selected ItemSettings in ObjectList. + * So, check if selected item isn't SettingsItem. And get a SettingsItem's parent item, if yes + */ + wxDataViewItem item = m_objects_model->GetItemType(sel_item) & itSettings ? m_objects_model->GetParent(sel_item) : sel_item; + const ItemType item_type = m_objects_model->GetItemType(item); /* Because of we couldn't edited layer_height for ItVolume from settings list, * correct options according to the selected item type : @@ -1552,17 +1558,21 @@ wxMenuItem* ObjectList::append_menu_item_change_type(wxMenu* menu) wxMenuItem* ObjectList::append_menu_item_instance_to_object(wxMenu* menu, wxWindow* parent) { wxMenuItem* menu_item = append_menu_item(menu, wxID_ANY, _(L("Set as a Separated Object")), "", - [this](wxCommandEvent&) { split_instances(); }, "", menu, [](){return wxGetApp().plater()->can_set_instance_to_object(); }, parent); + [this](wxCommandEvent&) { split_instances(); }, "", menu); /* New behavior logic: * 1. Split Object to several separated object, if ALL instances are selected * 2. Separate selected instances from the initial object to the separated object, * if some (not all) instances are selected */ - parent->Bind(wxEVT_UPDATE_UI, [](wxUpdateUIEvent& evt) { - evt.SetText(wxGetApp().plater()->canvas3D()->get_selection().is_single_full_object() ? - _(L("Set as a Separated Objects")) : _(L("Set as a Separated Object"))); - }, menu_item->GetId()); + parent->Bind(wxEVT_UPDATE_UI, [](wxUpdateUIEvent& evt) + { + const Selection& selection = wxGetApp().plater()->canvas3D()->get_selection(); + evt.SetText(selection.is_single_full_object() ? + _(L("Set as a Separated Objects")) : _(L("Set as a Separated Object"))); + + evt.Enable(wxGetApp().plater()->can_set_instance_to_object()); + }, menu_item->GetId()); return menu_item; }