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

8
gui.py
View File

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