def testDeselectAndReselectNode(self): script = Gaffer.ScriptNode() script["plane"] = GafferScene.Plane() script["group"] = GafferScene.Group() script["group"]["in"][0].setInput(script["plane"]["out"]) with GafferUI.Window() as w: HierarchyView = GafferSceneUI.HierarchyView(script) w.setVisible(True) HierarchyView.setNodeSet(Gaffer.StandardSet({script["group"]})) groupPathMatcher = IECore.PathMatcher(["/group"]) planePathMatcher = IECore.PathMatcher(["/group/plane"]) GafferSceneUI.ContextAlgo.setExpandedPaths(script.context(), groupPathMatcher) GafferSceneUI.ContextAlgo.setSelectedPaths(script.context(), planePathMatcher) def assertExpectedState(): self.waitForIdle(10000) self.assertEqual( GafferSceneUI.ContextAlgo.getExpandedPaths(script.context()), groupPathMatcher) self.assertEqual( GafferSceneUI.ContextAlgo.getSelectedPaths(script.context()), planePathMatcher) assertExpectedState() HierarchyView.setNodeSet(Gaffer.StandardSet()) assertExpectedState() HierarchyView.setNodeSet(Gaffer.StandardSet({script["group"]})) assertExpectedState()
def testNoUnwantedExpansion(self): # Make a small scene, and view it with a HierarchyView editor. script = Gaffer.ScriptNode() script["plane"] = GafferScene.Plane() script["group"] = GafferScene.Group() script["group"]["in"][0].setInput(script["plane"]["out"]) HierarchyView = GafferSceneUI.HierarchyView(script) script.selection().add(script["group"]) self.waitForIdle(1000) self.assertExpanded(script.context(), "/group", False) # Expand the root, and select /group. GafferSceneUI.ContextAlgo.setExpandedPaths(script.context(), IECore.PathMatcher(["/"])) GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), IECore.PathMatcher(["/group"])) self.waitForIdle(1000) self.assertExpanded(script.context(), "/", True) self.assertExpanded(script.context(), "/group", False) # Tweak the scene to change the name of a # non-expanded location. We expect the expansion to # remain the same. script["plane"]["name"].setValue("jane") self.waitForIdle(1000) self.assertExpanded(script.context(), "/", True) self.assertExpanded(script.context(), "/group", False)