diff --git a/src/Gui/Selection/SoFCUnifiedSelection.cpp b/src/Gui/Selection/SoFCUnifiedSelection.cpp index 32328d0cf7..b225d8025d 100644 --- a/src/Gui/Selection/SoFCUnifiedSelection.cpp +++ b/src/Gui/Selection/SoFCUnifiedSelection.cpp @@ -455,8 +455,30 @@ void SoFCUnifiedSelection::doAction(SoAction* action) App::Document* doc = App::GetApplication().getDocument(selectionAction->SelChange.pDocName); App::DocumentObject* obj = doc->getObject(selectionAction->SelChange.pObjectName); ViewProvider* vp = Application::Instance->getViewProvider(obj); - if (vp && (useNewSelection.getValue() || vp->useNewSelectionModel()) - && vp->isSelectable()) { + + // check if the subobject and all its parent containers are selectable + bool isSelectable = false; + if (vp) { + if (selectionAction->SelChange.pSubName && selectionAction->SelChange.pSubName[0]) { + // get the entire object hierarchy from root to leaf + auto objList = obj->getSubObjectList(selectionAction->SelChange.pSubName); + + isSelectable = true; + for (auto* checkObj : objList) { + if (auto checkVp = Application::Instance->getViewProvider(checkObj)) { + if (!checkVp->isSelectable()) { + isSelectable = false; + break; + } + } + } + } + else { + isSelectable = vp->isSelectable(); + } + } + + if (vp && (useNewSelection.getValue() || vp->useNewSelectionModel()) && isSelectable) { SoDetail* detail = nullptr; detailPath->truncate(0); auto subName = selectionAction->SelChange.pSubName; diff --git a/src/Gui/ViewProviderPart.cpp b/src/Gui/ViewProviderPart.cpp index 8dff54813f..7c576959a6 100644 --- a/src/Gui/ViewProviderPart.cpp +++ b/src/Gui/ViewProviderPart.cpp @@ -39,7 +39,7 @@ using namespace Gui; -PROPERTY_SOURCE_WITH_EXTENSIONS(Gui::ViewProviderPart, Gui::ViewProviderDragger) +PROPERTY_SOURCE_WITH_EXTENSIONS(Gui::ViewProviderPart, Gui::ViewProviderGeometryObject) /** @@ -62,7 +62,7 @@ ViewProviderPart::~ViewProviderPart() = default; */ void ViewProviderPart::onChanged(const App::Property* prop) { - ViewProviderDragger::onChanged(prop); + ViewProviderGeometryObject::onChanged(prop); } void ViewProviderPart::setupContextMenu(QMenu* menu, QObject* receiver, const char* member) @@ -74,7 +74,7 @@ void ViewProviderPart::setupContextMenu(QMenu* menu, QObject* receiver, const ch act->setChecked(isActivePart()); func->trigger(act, [this]() { this->toggleActivePart(); }); - ViewProviderDragger::setupContextMenu(menu, receiver, member); + ViewProviderGeometryObject::setupContextMenu(menu, receiver, member); } bool ViewProviderPart::isActivePart() diff --git a/src/Gui/ViewProviderPart.h b/src/Gui/ViewProviderPart.h index 4098fcae22..5d9ec8db4a 100644 --- a/src/Gui/ViewProviderPart.h +++ b/src/Gui/ViewProviderPart.h @@ -23,7 +23,7 @@ #ifndef GUI_VIEWPROVIDER_ViewProviderPart_H #define GUI_VIEWPROVIDER_ViewProviderPart_H -#include "ViewProviderDragger.h" +#include "ViewProviderGeometryObject.h" #include "ViewProviderOriginGroup.h" #include "ViewProviderFeaturePython.h" @@ -31,7 +31,8 @@ namespace Gui { -class GuiExport ViewProviderPart: public ViewProviderDragger, public ViewProviderOriginGroupExtension +class GuiExport ViewProviderPart: public ViewProviderGeometryObject, + public ViewProviderOriginGroupExtension { PROPERTY_HEADER_WITH_EXTENSIONS(Gui::ViewProviderPart);