openBrain wrote: ↑Tue Feb 04, 2020 11:04 am
- When you use Space bar (or Python 'Gui.runCommand('Std_ToggleVisibility',0)') on a Link inside a LinkGroup, it changes its visibility display in the tree view.
- Doing the same thing also changes the object visibility in the viewport !!! It means if the LinkGroup is shown but the inner Link is hidden, nothing is displayed. So clearly LinkGroup visibility doesn't override inner Link one.
What Std_ToggleVisibility does is to check for the current selection with full object hierarchy. And call the immediate parent object's setElementVisible() API to change the visibility of its child. If that function fails, it will fallback to change the object's own visibility. LinkGroup implements setElementVisible(), and changes its VisibilityList property, which controls its children visibility.
There is a subtle difficulty here, regarding how to handle the object's own visibility when it is claimed only by LinkGroup(s), but not any other object. If an object appears only inside LinkGroup(s) , which can have its own placement, we are not suppose to show the object outside the group regardless of its Visibility value. Because if we do so, the object may appear in two different places in the 3D view, but only one place in tree view (it is claimed by the LinkGroup, therefore no longer appear in tree view root).
In the current upstream, this is handled by TreeWidget::isObjectShowable(). The implementation has some glitch. I have fixed it in a pending PR. The purpose is the same, to check if an object fits the case described above, and ignore its own Visibility value.