diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index c714b6797..6ab87bd66 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -752,8 +752,8 @@ void ObjectList::OnContextMenu(wxDataViewEvent&) #endif // __WXOSX__ const wxString title = col->GetTitle(); - if (title == " "); - // show_context_menu(); + if (title == " ") + toggle_printable_state(item); else if (title == _("Editing")) show_context_menu(); else if (title == _("Name")) @@ -2276,7 +2276,7 @@ void ObjectList::add_object_to_list(size_t obj_idx, bool call_selection_changed) select_item(m_objects_model->AddInstanceChild(m_objects_model->GetItemById(obj_idx), print_idicator)); } else - m_objects_model->SetPrintableState(obj_idx, model_object->instances[0]->is_printable() ? piPrintable : piUnprintable); + m_objects_model->SetPrintableState(model_object->instances[0]->is_printable() ? piPrintable : piUnprintable, obj_idx); // add settings to the object, if it has those add_settings_item(item, &model_object->config); @@ -3623,11 +3623,23 @@ void ObjectList::update_printable_state(int obj_idx, int instance_idx) } else { - m_objects_model->SetPrintableState(obj_idx, piUndef); + m_objects_model->SetPrintableState(piUndef, obj_idx); printable = object->instances[instance_idx]->printable ? piPrintable : piUnprintable; } - select_item(m_objects_model->SetPrintableState(obj_idx, printable, instance_idx)); + m_objects_model->SetPrintableState(printable, obj_idx, instance_idx); +} + +void ObjectList::toggle_printable_state(wxDataViewItem item) +{ + const ItemType type = m_objects_model->GetItemType(item); + if (!(type&(itObject|itInstance/*|itVolume*/))) + return; + + wxGetApp().plater()->canvas3D()->get_selection().toggle_instance_printable_state(); + + // update scene + wxGetApp().plater()->update(); } ModelObject* ObjectList::object(const int obj_idx) const diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index 1cfca1a42..bdec06081 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -349,7 +349,9 @@ public: void msw_rescale(); void update_after_undo_redo(); + //update printable state for item from objects model void update_printable_state(int obj_idx, int instance_idx); + void toggle_printable_state(wxDataViewItem item); private: #ifdef __WXOSX__ diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 3da6997a7..524861133 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -1657,8 +1657,8 @@ void ObjectDataViewModel::SetVolumeType(const wxDataViewItem &item, const Slic3r } wxDataViewItem ObjectDataViewModel::SetPrintableState( + PrintIndicator printable, int obj_idx, - PrintIndicator printable/* = piUndef*/, int subobj_idx /* = -1*/, ItemType subobj_type/* = itInstance*/) { @@ -1673,6 +1673,7 @@ wxDataViewItem ObjectDataViewModel::SetPrintableState( if (!node) return wxDataViewItem(0); node->set_printable_icon(printable); + ItemChanged(item); return item; } diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 5b9bdee02..242a487d1 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -485,8 +485,7 @@ public: void SetVolumeBitmaps(const std::vector& volume_bmps) { m_volume_bmps = volume_bmps; } void SetWarningBitmap(wxBitmap* bitmap) { m_warning_bmp = bitmap; } void SetVolumeType(const wxDataViewItem &item, const Slic3r::ModelVolumeType type); - wxDataViewItem SetPrintableState( int obj_idx, - PrintIndicator printable = piUndef, + wxDataViewItem SetPrintableState( PrintIndicator printable, int obj_idx, int subobj_idx = -1, ItemType subobj_type = itInstance);