Gui: Respect Selectable property for objects inside Part containers#25009
Conversation
7a85790 to
947d1d6
Compare
|
PR has a conflict |
688a004 to
68c9124
Compare
|
Great thanks |
|
However I think checking just the subobject is not ideal. Part (not selectable)
Then the box is selectable. No? Then it is not good. If the parent container is set as not selectable then the child should also be not selectable.
|
|
So I think the solution is rather to keep the something like : |
|
Maybe it's worth checking how Visibility is doing it and just copying the same behavior |
|
Actually I just checked and in current main FreeCAD, App::Part do not have Selectable Property. Only in Realthunder's branch there is. Yet again a feature that got lost in Linkstage and never got merged... Additionally I have just tested in more details and found that : Part
Body (selectable)
Body (Not selectable)
Part
Part
So what we learn here is that what is actually broken here is the Body's Selectable property. My guess is that all of this works properly in LinkStage. @realthunder |
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.
68c9124 to
585e957
Compare
|
@PaddleStroke thanks for catching this and sorry for late reply, been busy last month. Could you recheck it? I decided to not port RT for now as I will be probably refactoring those parts of the code so I left area for improvement. I've just added a simple parents check for the currently selected object, so it will reject selection if parent is not selectable. |
25c85b5 to
b44d754
Compare
| 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); |
There was a problem hiding this comment.
is obj included in objList? If not then you also need to check if obj is selectable.
There was a problem hiding this comment.
Yes, looks like it is included:
res.push_back(const_cast<DocumentObject*>(this)); in DocumentObject::getSubObjectList.
|
Sounds good I think. Although I have never used getSubObjectList before so I'm not sure how it behaves, but if it behaves as I think it should then it's a convenient helper that I just learned about. Then we can also add a |
Change `ViewProviderPart` to inherit from `ViewProviderGeometryObject`, giving Part containers the Selectable property. This allows recursive selectability checks to respect the entire container hierarchy.
|
@PaddleStroke I've implemented this in a separate commit by changing ViewProviderPart to inherit from ViewProviderGeometryObject (instead of ViewProviderDragger). This adds the property to Part containers, since it is inherited from |
Oh wait I am already doing that in a PR : https://github.com/FreeCAD/FreeCAD/pull/26174/files#diff-afbda03a6d43c61b6d039dbc3e361c32f8481082209088e133135c40fda1ce5b Although the conflict is quite minimal so it's no matter. |
|
@PaddleStroke Hmm.. want me to adapt or will you adapt the PR? |
|
You can leave it, it'll be a small conflict no problem. |
|
@PaddleStroke so, is the patch alright? Can we merge this soon? |
|
It looks good to me. |
Currently if user selects object with
Selectable=falseproperty which is nested inside a Part container, for examplePart->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,SoFCUnifiedSelectionwas only checking Part'sisSelectable()status, even though the target isPad.So the fix is to resolve subname to get the final target object and checks its
isSelectable()status before checking for highlighting.Resolves: #24940