Fixed disabling for "Set As separated object" context menu item

+ added missed bug fix in get_freq_settings_choice (part of b9899f9496)
This commit is contained in:
YuSanka 2019-12-12 15:54:53 +01:00
parent 2eb3766e11
commit 967da67d2e

View File

@ -1324,11 +1324,17 @@ void ObjectList::get_freq_settings_choice(const wxString& bundle_name)
{
std::vector<std::string> options = get_options_for_bundle(bundle_name);
const Selection& selection = scene_selection();
wxDataViewItem item = GetSelectedItemsCount() > 1 && selection.is_single_full_object() ?
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,16 +1558,20 @@ 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() ?
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;