[Arch] [Draft] Add guard for RootNode specific child
This commit is contained in:
@@ -210,11 +210,12 @@ class _ViewProviderProject(ArchIFCView.IfcContextView):
|
||||
"""
|
||||
|
||||
if not hasattr(self, "displaymodes_cleaned"):
|
||||
main_switch = vobj.RootNode.getChild(2) # The display mode switch.
|
||||
if main_switch is not None and main_switch.getNumChildren() == 4: # Check if all display modes are available.
|
||||
for node in tuple(main_switch.getChildren()):
|
||||
node.removeAllChildren()
|
||||
self.displaymodes_cleaned = True
|
||||
if vobj.RootNode.getNumChildren() > 2:
|
||||
main_switch = vobj.RootNode.getChild(2) # The display mode switch.
|
||||
if main_switch is not None and main_switch.getNumChildren() == 4: # Check if all display modes are available.
|
||||
for node in tuple(main_switch.getChildren()):
|
||||
node.removeAllChildren()
|
||||
self.displaymodes_cleaned = True
|
||||
|
||||
def onChanged(self,vobj,prop):
|
||||
self.removeDisplaymodeChildNodes(vobj)
|
||||
|
||||
@@ -1038,26 +1038,27 @@ class _ViewProviderSite:
|
||||
"""
|
||||
|
||||
if not hasattr(self, "terrain_switches"):
|
||||
main_switch = vobj.RootNode.getChild(2) # The display mode switch.
|
||||
if main_switch.getNumChildren() == 4: # Check if all display modes are available.
|
||||
from pivy import coin
|
||||
self.terrain_switches = []
|
||||
for node in tuple(main_switch.getChildren()):
|
||||
new_switch = coin.SoSwitch()
|
||||
sep1 = coin.SoSeparator()
|
||||
sep1.setName("NoTerrain")
|
||||
sep2 = coin.SoSeparator()
|
||||
sep2.setName("Terrain")
|
||||
child_list = list(node.getChildren())
|
||||
for child in child_list:
|
||||
sep2.addChild(child)
|
||||
new_switch.addChild(sep1)
|
||||
new_switch.addChild(sep2)
|
||||
new_switch.whichChild = 0
|
||||
node.addChild(new_switch)
|
||||
for i in range(len(child_list)):
|
||||
node.removeChild(0) # Remove the original children.
|
||||
self.terrain_switches.append(new_switch)
|
||||
if vobj.RootNode.getNumChildren() > 2:
|
||||
main_switch = vobj.RootNode.getChild(2) # The display mode switch.
|
||||
if main_switch.getNumChildren() == 4: # Check if all display modes are available.
|
||||
from pivy import coin
|
||||
self.terrain_switches = []
|
||||
for node in tuple(main_switch.getChildren()):
|
||||
new_switch = coin.SoSwitch()
|
||||
sep1 = coin.SoSeparator()
|
||||
sep1.setName("NoTerrain")
|
||||
sep2 = coin.SoSeparator()
|
||||
sep2.setName("Terrain")
|
||||
child_list = list(node.getChildren())
|
||||
for child in child_list:
|
||||
sep2.addChild(child)
|
||||
new_switch.addChild(sep1)
|
||||
new_switch.addChild(sep2)
|
||||
new_switch.whichChild = 0
|
||||
node.addChild(new_switch)
|
||||
for i in range(len(child_list)):
|
||||
node.removeChild(0) # Remove the original children.
|
||||
self.terrain_switches.append(new_switch)
|
||||
|
||||
def updateDisplaymodeTerrainSwitches(self,vobj):
|
||||
"""Updates the 'terrain' switches."""
|
||||
|
||||
@@ -138,9 +138,10 @@ class SubelementHighlight(gui_base_original.Modifier):
|
||||
obj.ViewObject.PointColor = (1.0, 0.0, 0.0)
|
||||
obj.ViewObject.LineColor = (1.0, 0.0, 0.0)
|
||||
xray = coin.SoAnnotation()
|
||||
xray.addChild(obj.ViewObject.RootNode.getChild(2).getChild(0))
|
||||
xray.setName("xray")
|
||||
obj.ViewObject.RootNode.addChild(xray)
|
||||
if obj.ViewObject.RootNode.getNumChildren() > 2:
|
||||
xray.addChild(obj.ViewObject.RootNode.getChild(2).getChild(0))
|
||||
xray.setName("xray")
|
||||
obj.ViewObject.RootNode.addChild(xray)
|
||||
|
||||
def restore_editable_objects_graphics(self):
|
||||
"""Restore the editable objects' appearance."""
|
||||
|
||||
Reference in New Issue
Block a user