App::LinkGroup breaks Visibility property handling

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

App::LinkGroup breaks Visibility property handling

Post by openBrain »

Steps to reproduce :
  1. Create a new document
  2. Add a Part/Sphere
  3. Set it in a LinkGroup (right-click the Sphere in the tree view -> Link actions -> Make Link Group (any type, you can try all 3 different ones)
  4. In the tree view, select the object inside the LinkGroup (type depends on your previous choice) then go to View tab in the Property editor and try to change 'Visibility' property => Nothing happens
Notice toggling visibility with Space key works well though.

Thanks for confirming
---
OS: Ubuntu 18.04.4 LTS (KDE/plasma)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19438 (Git)
Build type: Unknown
Branch: master
Hash: fa635035dd6a9dc3a327bd68c5f0763e2c8509b1
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: App::LinkGroup breaks Visibility property handling

Post by kisolre »

I tried with RMB/toggle visibility and Space - works as expcted. But I notice that the Visibility property does not change and is always False. When sphere is created it is properly toggled. When it is added to link group Visibility becomes false and stays that way. If I drag the sphere out of the link group visibility again starts to behave properly.

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.19424 (Git)
Build type: Release
Branch: master
Hash: 899854ac5d643e991a1006ed75aeff93baf3d224
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Bulgarian/Bulgaria (bg_BG)
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: App::LinkGroup breaks Visibility property handling

Post by openBrain »

realthunder wrote: Ping
@realthunder : may you have insight on that point ?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: App::LinkGroup breaks Visibility property handling

Post by DeepSOIC »

I think it is the expected behavior: LinkGroup overrides visibilities of contained stuff.

https://forum.freecadweb.org/viewtopic. ... 10#p349474
realthunder wrote: Sat Nov 23, 2019 11:28 pm Link (and LinkGroup) always has this visibility/color override thing implemented.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: App::LinkGroup breaks Visibility property handling

Post by openBrain »

Thanks for precision. But there is still a bug (that maybe is a bit different), because :
  • 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. ;)
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: App::LinkGroup breaks Visibility property handling

Post by realthunder »

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.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: App::LinkGroup breaks Visibility property handling

Post by openBrain »

Thx for answer. I'll wait for the PR to be merged in order to see if it fixes things. ;)
realthunder wrote: Wed Feb 05, 2020 12:12 am 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.
Will the PR fix the display issue, i.e. just making a LinkGroup visible is enough to make visible its inner Links independently of their own visibility status ?
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: App::LinkGroup breaks Visibility property handling

Post by realthunder »

openBrain wrote: Wed Feb 05, 2020 11:15 am Will the PR fix the display issue, i.e. just making a LinkGroup visible is enough to make visible its inner Links independently of their own visibility status ?
It is better if you can make a sample file showing the problem you have. I am not sure if the issue I mentioned is the same as yours.

The user may configure a group to show only some of its children. And toggling the group visibility shouldn't affect that configuration. Are you asking for the plain group visibility toggling behavior, which propagates the changes to all its nested children? I don't think that's a good behavior. In fact, one of my PR changed this. Plain group will remember its children visibility, but still provide menu action for the old behavior.

For App::Part container, you can change the child visibility by directly modify its visibility property. For LinkGroup, you can do this,

Code: Select all

for sub in LinkGroup.getSubObjects():
	LinkGroup.setElementVisible(sub, True) # or False
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
kisolre
Veteran
Posts: 4166
Joined: Wed Nov 21, 2018 1:13 pm

Re: App::LinkGroup breaks Visibility property handling

Post by kisolre »

realthunder wrote: Thu Feb 06, 2020 2:30 am It is better if you can make a sample file showing the problem you have. I am not sure if the issue I mentioned is the same as yours.
I think there is some misunderstanding. As I understand it the topic is about this:
.
Visibility property wrong.JPG
Visibility property wrong.JPG (74.79 KiB) Viewed 664 times
.
As you can see the Link group is visible, Body is visible in 3d View and in tree but its Visibility property is displayed to False and trying to change that from the properties panel does nothing. If you set it to True as soon as you leave the edit field it is again reverted to False. But this does not hide the body.
openBrain
Veteran
Posts: 9041
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: App::LinkGroup breaks Visibility property handling

Post by openBrain »

realthunder wrote: Thu Feb 06, 2020 2:30 am It is better if you can make a sample file showing the problem you have. I am not sure if the issue I mentioned is the same as yours.
Sure. Please find attached. The problem is how to make the whole LinkGroup visible with Python macro. Going a bit further, the question could be 'How to manage visibility of LinkGroup with Python API ?'
The user may configure a group to show only some of its children. And toggling the group visibility shouldn't affect that configuration. Are you asking for the plain group visibility toggling behavior, which propagates the changes to all its nested children? I don't think that's a good behavior. In fact, one of my PR changed this. Plain group will remember its children visibility, but still provide menu action for the old behavior.
No, I agree with you on propagation to children. What I'd expect is that children 'Visibility' property both reflects the true visibility state of the child and can be freely set through Python. I.e. a LinkGroup acts as a Part container on this point.
Also I don't see any practical reason for the current behavior to be as is. ;)
For App::Part container, you can change the child visibility by directly modify its visibility property. For LinkGroup, you can do this,

Code: Select all

for sub in LinkGroup.getSubObjects():
	LinkGroup.setElementVisible(sub, True) # or False
It has the limitation that (eg. on the sample file I attached) the 'getSubObjects()' function only returns the top Link but not the LinkItems below. So doing this you're still not sure what is the exact visibility of the items...
BTW, how can you get the current visibility status of a Link/LinkItem nested in a LinkGroup.

Thx for your patience on this point. :)
Attachments
LinkGroup.FCStd
(4.23 KiB) Downloaded 12 times
Post Reply