gui: change auto element visibility command behavior

This commit is contained in:
Zheng, Lei 2018-07-16 17:08:32 +08:00
parent 2dcbb2e1fb
commit 5dacdb4fde
2 changed files with 8 additions and 11 deletions

View File

@ -561,8 +561,7 @@ class ViewProviderAsmElement(ViewProviderAsmOnTop):
def attach(self,vobj):
super(ViewProviderAsmElement,self).attach(vobj)
if gui.AsmCmdManager.AutoElementVis:
vobj.OnTopWhenSelected = 2
vobj.OnTopWhenSelected = 2
def getDefaultColor(self):
return (60.0/255.0,1.0,1.0)
@ -956,7 +955,7 @@ class AsmElementLink(AsmBase):
ViewProviderAsmElementLink(link.ViewObject)
info.Constraint.setLink({-1:link})
link.Proxy.setLink(info.Owner,info.Subname)
if not gui.AsmCmdManager.AutoElementVis:
if gui.AsmCmdManager.AutoElementVis:
info.Constraint.setElementVisible(link.Name,False)
return link
@ -974,8 +973,7 @@ class ViewProviderAsmElementLink(ViewProviderAsmOnTop):
def attach(self,vobj):
super(ViewProviderAsmElementLink,self).attach(vobj)
if gui.AsmCmdManager.AutoElementVis:
vobj.OnTopWhenSelected = 2
vobj.OnTopWhenSelected = 2
def getDefaultColor(self):
return (1.0,60.0/255.0,60.0/255.0)
@ -1248,8 +1246,7 @@ class AsmConstraint(AsmGroup):
class ViewProviderAsmConstraint(ViewProviderAsmGroup):
def attach(self,vobj):
super(ViewProviderAsmConstraint,self).attach(vobj)
if gui.AsmCmdManager.AutoElementVis:
vobj.OnTopWhenSelected = 2
vobj.OnTopWhenSelected = 2
def getIcon(self):
return Constraint.getIcon(self.ViewObject.Object)

8
gui.py
View File

@ -431,19 +431,19 @@ class AsmCmdAutoElementVis(AsmCmdCheckable):
super(AsmCmdAutoElementVis,cls).Activated(checked)
from .assembly import isTypeOf,AsmConstraint,\
AsmElement,AsmElementLink,AsmElementGroup
visible = not checked
for doc in FreeCAD.listDocuments().values():
for obj in doc.Objects:
if isTypeOf(obj,(AsmConstraint,AsmElementGroup)):
obj.Visibility = False
if isTypeOf(obj,AsmConstraint):
obj.ViewObject.OnTopWhenSelected = 2 if checked else 0
obj.ViewObject.OnTopWhenSelected = 2
obj.setPropertyStatus('VisibilityList',
'NoModify' if checked else '-NoModify')
elif isTypeOf(obj,(AsmElementLink,AsmElement)):
if checked:
obj.Proxy.parent.Object.setElementVisible(
obj.Name,False)
obj.Visibility = False
vis = visible and not isTypeOf(obj,AsmElement)
obj.Proxy.parent.Object.setElementVisible(obj.Name,vis)
obj.ViewObject.OnTopWhenSelected = 2