Skip to content

Commit

Permalink
Documentation : Prefer ScriptNodeAlgo to ContextAlgo
Browse files Browse the repository at this point in the history
  • Loading branch information
johnhaddon committed Sep 10, 2024
1 parent fc679f9 commit 6905e4f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 30 deletions.
8 changes: 4 additions & 4 deletions apps/screengrab/screengrab-1.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,19 @@ def _run( self, args ) :

# Set up the scene expansion and selection.

GafferSceneUI.ContextAlgo.clearExpansion( script.context() )
GafferSceneUI.ScriptNodeAlgo.setVisibleSet( script, GafferScene.VisibleSet() )

pathsToExpand = IECore.PathMatcher( list( args["scene"]["fullyExpandedPaths"] ) + list( args["scene"]["expandedPaths"] ) )
GafferSceneUI.ContextAlgo.expand( script.context(), pathsToExpand )
GafferSceneUI.ScriptNodeAlgo.expandInVisibleSet( script, pathsToExpand )

pathsToFullyExpand = IECore.PathMatcher( list( args["scene"]["fullyExpandedPaths"] ) )

with script.context() :
for node in script.selection() :
for scenePlug in [ p for p in node.children( GafferScene.ScenePlug ) if p.direction() == Gaffer.Plug.Direction.Out ] :
GafferSceneUI.ContextAlgo.expandDescendants( script.context(), pathsToFullyExpand, scenePlug )
GafferSceneUI.ScriptNodeAlgo.expandDescendantsInVisibleSet( script, pathsToFullyExpand, scenePlug )

GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), IECore.PathMatcher( args["scene"]["selectedPaths"] ) )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, IECore.PathMatcher( args["scene"]["selectedPaths"] ) )

# Add a delay.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ def __delay( delay ) :
GafferUI.WidgetAlgo.grab( widget = scriptWindow, imagePath = "images/viewerSceneReaderBounding.png" )

# GafferBot torso in Hierarchy View
GafferSceneUI.ContextAlgo.setExpandedPaths( script.context(), IECore.PathMatcher( [ "/GAFFERBOT", "/GAFFERBOT/C_torso_GRP" ] ) )
GafferSceneUI.ScriptNodeAlgo.setVisibleSet( script, GafferScene.VisibleSet( expansions = IECore.PathMatcher( [ "/GAFFERBOT", "/GAFFERBOT/C_torso_GRP" ] ) ) )
__delay( 0.1 )
GafferUI.WidgetAlgo.grab( widget = hierarchyView, imagePath = "images/hierarchyViewExpandedTwoLevels.png" )

# GafferBot head and left leg in main window
paths = IECore.PathMatcher( [ "/GAFFERBOT/C_torso_GRP/C_head_GRP", "/GAFFERBOT/C_torso_GRP/R_legUpper_GRP" ] )
GafferSceneUI.ContextAlgo.expand( script.context(), paths )
GafferSceneUI.ContextAlgo.expandDescendants( script.context(), paths, script["SceneReader"]["out"] )
GafferSceneUI.ContextAlgo.expandDescendants( script.context(), paths, readerNode["out"] )
GafferSceneUI.ScriptNodeAlgo.expandInVisibleSet( script, paths )
GafferSceneUI.ScriptNodeAlgo.expandDescendantsInVisibleSet( script, paths, script["SceneReader"]["out"] )
GafferSceneUI.ScriptNodeAlgo.expandDescendantsInVisibleSet( script, paths, readerNode["out"] )
viewer.view().viewportGadget().getPrimaryChild().waitForCompletion()
GafferUI.WidgetAlgo.grab( widget = scriptWindow, imagePath = "images/mainHeadAndLeftLegExpanded.png" )

# GafferBot head and both legs in Viewer
paths = IECore.PathMatcher( [ "/GAFFERBOT/C_torso_GRP/L_legUpper_GRP" ] )
GafferSceneUI.ContextAlgo.expand( script.context(), paths )
GafferSceneUI.ContextAlgo.expandDescendants( script.context(), paths, readerNode["out"] )
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), paths )
GafferSceneUI.ScriptNodeAlgo.expandInVisibleSet( script, paths )
GafferSceneUI.ScriptNodeAlgo.expandDescendantsInVisibleSet( script, paths, readerNode["out"] )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, paths )
viewer.view().viewportGadget().getPrimaryChild().waitForCompletion()
GafferUI.WidgetAlgo.grab( widget = viewer, imagePath = "images/viewerHeadAndLegsExpanded.png" )

Expand All @@ -115,15 +115,14 @@ def __delay( delay ) :
script.selection().add( groupNode )
script.setFocus( groupNode )
viewer.view()["minimumExpansionDepth"].setValue( 999 )
GafferSceneUI.ContextAlgo.clearExpansion( script.context() )
GafferSceneUI.ContextAlgo.expand( script.context(), IECore.PathMatcher( [ "/group" ] ) )
GafferSceneUI.ScriptNodeAlgo.setVisibleSet( script, GafferScene.VisibleSet( expansions = IECore.PathMatcher( [ "/group" ] ) ) )
viewer.view().viewportGadget().getPrimaryChild().waitForCompletion()
GafferUI.WidgetAlgo.grab( widget = scriptWindow, imagePath = "images/mainGroupNode.png" )

# Camera repositioned, with translate tool on, in Viewer
cameraNode["transform"]["translate"].setValue( imath.V3f( 16, 13, 31 ) )
viewer.view().viewportGadget().frame( groupNode["out"].bound( "/group" ) )
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), IECore.PathMatcher( [ "/group/camera" ] ) )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, IECore.PathMatcher( [ "/group/camera" ] ) )
for i in viewer._Viewer__toolChooser.tools():
if type( i ) == GafferSceneUI.TranslateTool:
translateTool = i
Expand Down Expand Up @@ -252,7 +251,7 @@ def __renderAndGrab( script, widget, imagePath, delay = 15 ) :
script.selection().add( script["ShaderAssignment1"] )
script.setFocus( script["ShaderAssignment1"] )
paths = IECore.PathMatcher( [ "/group/GAFFERBOT/C_torso_GRP/C_head_GRP/C_head_CPT/C_browNose001_REN", "/group/GAFFERBOT/C_torso_GRP/C_head_GRP/C_head_CPT/C_mouthGrill001_REN" ] )
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), paths )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, paths )
GafferUI.EventLoop.waitForIdle()
paths = IECore.PathMatcher( [ "/group/GAFFERBOT/C_torso_GRP/C_head_GRP/C_head_CPT" ] )
viewer.view().frame( paths, direction = imath.V3f( -0.2, -0.2, -1 ) )
Expand Down
3 changes: 1 addition & 2 deletions doc/source/WorkingWithScenes/AnatomyOfACamera/screengrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@

script.selection().add( script["Camera"] )
__path = "/camera"
__paths = IECore.PathMatcher( [ __path ] )
GafferSceneUI.ContextAlgo.expand( script.context(), __paths )
GafferSceneUI.ScriptNodeAlgo.expandInVisibleSet( script, IECore.PathMatcher( [ __path ] ) )

from GafferSceneUI.SceneInspector import __TransformSection, __BoundSection, __ObjectSection, __AttributesSection, __SetMembershipSection

Expand Down
8 changes: 4 additions & 4 deletions doc/source/WorkingWithScenes/AnatomyOfAScene/screengrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def __delay( delay ) :

# The Scene Inspector
__paths = IECore.PathMatcher( [ __path ] )
GafferSceneUI.ContextAlgo.expand( script.context(), __paths )
GafferSceneUI.ContextAlgo.expandDescendants( script.context(), __paths, script["SceneReader"]["out"] )
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), __paths )
GafferSceneUI.ScriptNodeAlgo.expandInVisibleSet( script, __paths )
GafferSceneUI.ScriptNodeAlgo.expandDescendantsInVisibleSet( script, __paths, script["SceneReader"]["out"] )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, __paths )
scriptWindow = GafferUI.ScriptWindow.acquire( script )
GafferSceneUI.ContextAlgo.setExpandedPaths( script.context(), IECore.PathMatcher( [ __path ] ) )
GafferSceneUI.ScriptNodeAlgo.setVisibleSet( script, GafferScene.VisibleSet( expansions = IECore.PathMatcher( [ __path ] ) ) )
hierarchyView = scriptWindow.getLayout().editors( GafferSceneUI.HierarchyView )[0]
__delay( 1.0 )
GafferUI.WidgetAlgo.grab( widget = hierarchyView, imagePath = "images/hierarchyView.png" )
Expand Down
4 changes: 2 additions & 2 deletions doc/source/WorkingWithScenes/Camera/screengrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def __dispatchScript( script, tasks, settings ) :
__delay( 0.1 )
viewer.view()["grid"]["visible"].setValue( False )
paths = IECore.PathMatcher( [ "/camera" ] )
GafferSceneUI.ContextAlgo.expand( script.context(), paths )
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), paths )
GafferSceneUI.ScriptNodeAlgo.expandInVisibleSet( script, paths )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, paths )
viewer.view().viewportGadget().getPrimaryChild().waitForCompletion()
GafferUI.WidgetAlgo.grab( widget = viewer, imagePath = "images/interfaceCameraVisualizer.png" )
script.selection().clear()
Expand Down
2 changes: 1 addition & 1 deletion doc/source/WorkingWithScenes/LightLinking/screengrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
script.selection().add( script["StandardAttributes"] )
__path = "/group/sphere"
__paths = IECore.PathMatcher( [ __path ] )
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), __paths )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, __paths )

from GafferSceneUI.SceneInspector import __AttributesSection

Expand Down
2 changes: 1 addition & 1 deletion doc/source/WorkingWithTheNodeGraph/Contexts/screengrab.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __delay( delay ) :
__delay( 0.1 )

# Concept: Querying results
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), IECore.PathMatcher( [ "/cube2" ] ) )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, IECore.PathMatcher( [ "/cube2" ] ) )
#sceneInspector.reveal()
# Expand the "Transform" section
#sceneInspector._SceneInspector__sections[2]._Section__collapsible.setCollapsed( False )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def __delay( delay ) :
script["Camera"]["transform"]["translate"]["z"].setValue( 8 )
script.setFocus( script["Camera"] )
paths = IECore.PathMatcher( [ "/camera" ] )
GafferSceneUI.ContextAlgo.setSelectedPaths( script.context(), paths )
GafferSceneUI.ScriptNodeAlgo.setSelectedPaths( script, paths )
__delay( 0.1 )
GafferUI.WidgetAlgo.grab( widget = viewer, imagePath = "images/viewerCameraPosition.png" )

Expand All @@ -125,8 +125,8 @@ def __delay( delay ) :
# Final script in Viewer
script.setFocus( script["Group"] )
paths = IECore.PathMatcher( [ "/group" ] )
GafferSceneUI.ContextAlgo.setExpandedPaths( script.context(), paths )
GafferSceneUI.ContextAlgo.expandDescendants( script.context(), paths, script["Group"]["out"] )
GafferSceneUI.ScriptNodeAlgo.setVisibleSet( script, GafferScene.VisibleSet( expansions = paths ) )
GafferSceneUI.ScriptNodeAlgo.expandDescendantsInVisibleSet( script, paths, script["Group"]["out"] )
__delay( 0.1 )
GafferUI.WidgetAlgo.grab( widget = viewer, imagePath = "images/viewerFinalScene.png" )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ def __dispatchScript( script, tasks, settings ) :
viewer.view().viewportGadget().frame( script["SceneReader"]["out"].bound( "/" ) )
viewer.view().viewportGadget().getPrimaryChild().waitForCompletion()
paths = IECore.PathMatcher( [ "/" ] )
GafferSceneUI.ContextAlgo.expand( script.context(), paths )
GafferSceneUI.ContextAlgo.expandDescendants( script.context(), paths, script["SceneReader"]["out"] )
GafferSceneUI.ScriptNodeAlgo.expandInVisibleSet( script, paths )
GafferSceneUI.ScriptNodeAlgo.expandDescendantsInVisibleSet( script, paths, script["SceneReader"]["out"] )
GafferUI.WidgetAlgo.grab( widget = scriptWindow, imagePath = "images/tutorialVariableSubstitutionTest.png" )

0 comments on commit 6905e4f

Please sign in to comment.