Gui: Respect Selectable property for objects inside Part containers

Currently if user selects object with `Selectable=false` property which
is nested inside a Part container, for example `Part->Body->Pad`, parent
Part container will get highlighted in the 3D view, even though the user
clicked on a non-selectable child object.

Cause of that is that tree view's `getTopParent()` function resolves
nested objects selections to their top-level container. When a Pad
inside Part is selected, `SoFCUnifiedSelection` was only checking Part's
`isSelectable()` status, even though the target is `Pad`.

So the fix is to resolve subname to get the final target object and
checks its `isSelectable()` status before checking for highlighting.
This commit is contained in:
tetektoza
2025-11-02 16:40:11 +01:00
parent f253f453d6
commit 17543ea69e

View File

@@ -454,10 +454,25 @@ void SoFCUnifiedSelection::doAction(SoAction* action)
// selection changes inside the 3d view are handled in handleEvent()
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()) {
SoDetail* detail = nullptr;
ViewProvider*vp = Application::Instance->getViewProvider(obj);
// check if the actual subobject being selected is selectable
bool isSelectable = false;
if (vp) {
if (selectionAction->SelChange.pSubName && selectionAction->SelChange.pSubName[0]) {
if (auto subObj = obj->getSubObject(selectionAction->SelChange.pSubName)) {
auto subVp = Application::Instance->getViewProvider(subObj);
isSelectable = subVp ? subVp->isSelectable() : false;
} else {
isSelectable = vp->isSelectable();
}
} else {
isSelectable = vp->isSelectable();
}
}
if (vp && (useNewSelection.getValue() || vp->useNewSelectionModel()) && isSelectable) {
SoDetail *detail = nullptr;
detailPath->truncate(0);
auto subName = selectionAction->SelChange.pSubName;
App::ElementNamePair elementName;