Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisualiserTool Primitive Variable Menu #6181

Open
wants to merge 7 commits into
base: 1.5_maintenance
Choose a base branch
from

Conversation

ericmehl
Copy link
Collaborator

This adds a handy sub-menu to the context menu for the VisualisationTool.dataName plug listing all the primitive variables that can be visualised by the tool for the current selection.

Checklist

  • I have read the contribution guidelines.
  • I have updated the documentation, if applicable.
  • I have tested my change(s) in the test suite, and added new test cases where necessary.
  • My code follows the Gaffer project's prevailing coding style and conventions.

Copy link
Member

@johnhaddon johnhaddon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Eric - helping folks find the things they want is definitely a good thing. I've highlighted a couple of bugs inline that should be pretty straightforward to take care of.

Having this as a submenu of the right-click menu still feels a bit out of the way to me in practice, and I'm not sure how we'll fit the "Vertex ID" mode in with it. I think it might be nice to write a custom PlugValueWidget hosting a MenuButton with your menu (and only your menu) on it - what do you think?

selection = GafferSceneUI.ScriptNodeAlgo.getSelectedPaths( scriptNode )

primVars = []

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to scope the View's context here before evaluating the scene at all. Here's a repro for a failure case :

  • Focus the ContextVariables node.
  • Pin the NameSwitch into the Viewer.
  • Right-click and witness the lack of context variables.
import Gaffer
import GafferScene
import imath

Gaffer.Metadata.registerValue( parent, "serialiser:milestoneVersion", 1, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:majorVersion", 5, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:minorVersion", 1, persistent=False )
Gaffer.Metadata.registerValue( parent, "serialiser:patchVersion", 0, persistent=False )

__children = {}

__children["SceneReader"] = GafferScene.SceneReader( "SceneReader" )
parent.addChild( __children["SceneReader"] )
__children["SceneReader"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["Cube"] = GafferScene.Cube( "Cube" )
parent.addChild( __children["Cube"] )
__children["Cube"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["NameSwitch"] = Gaffer.NameSwitch( "NameSwitch" )
parent.addChild( __children["NameSwitch"] )
__children["NameSwitch"].setup( GafferScene.ScenePlug( "value", ) )
__children["NameSwitch"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["ContextVariables"] = Gaffer.ContextVariables( "ContextVariables" )
parent.addChild( __children["ContextVariables"] )
__children["ContextVariables"].setup( GafferScene.ScenePlug( "in", ) )
__children["ContextVariables"]["variables"].addChild( Gaffer.NameValuePlug( "", Gaffer.StringPlug( "value", defaultValue = '', flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ), True, "member1", Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic ) )
__children["ContextVariables"].addChild( Gaffer.V2fPlug( "__uiPosition", defaultValue = imath.V2f( 0, 0 ), flags = Gaffer.Plug.Flags.Default | Gaffer.Plug.Flags.Dynamic, ) )
__children["SceneReader"]["fileName"].setValue( '${GAFFER_ROOT}/resources/gafferBot/caches/gafferBot.scc' )
__children["SceneReader"]["__uiPosition"].setValue( imath.V2f( 23.1000023, 10.0999994 ) )
__children["Cube"]["__uiPosition"].setValue( imath.V2f( 4.70000458, 10.250001 ) )
__children["NameSwitch"]["__index"].setInput( __children["NameSwitch"]["__outIndex"] )
__children["NameSwitch"]["selector"].setValue( '${a}' )
__children["NameSwitch"]["in"][0]["name"].setValue( '*' )
__children["NameSwitch"]["in"][0]["value"].setInput( __children["Cube"]["out"] )
__children["NameSwitch"]["in"][1]["name"].setValue( 'A' )
__children["NameSwitch"]["in"][1]["value"].setInput( __children["SceneReader"]["out"] )
__children["NameSwitch"]["__uiPosition"].setValue( imath.V2f( 18.8000011, -2.06406093 ) )
__children["ContextVariables"]["variables"]["member1"]["name"].setValue( 'a' )
__children["ContextVariables"]["variables"]["member1"]["value"].setValue( 'A' )
__children["ContextVariables"]["in"].setInput( __children["NameSwitch"]["out"]["value"] )
__children["ContextVariables"]["__uiPosition"].setValue( imath.V2f( 18.8008385, -10.2281237 ) )


del __children

return

scenePlug = node.view()["in"].getInput()
scriptNode = scenePlug.ancestor( Gaffer.ScriptNode )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scriptNode can be got more directly via view.scriptNode().

Comment on lines 162 to 166
IECore.IntVectorData,
IECore.FloatVectorData,
IECore.V2fVectorData,
IECore.Color3fVectorData,
IECore.V3fVectorData,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that some of these types are omitted from the tooltip for dataName - could you update it to include them please?

primVars = []

for path in selection.paths() :
primitive = scenePlug.object( path )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check scenePlug.exists( path ) here before accessing anything else - it's possible to select stuff in one editor that doesn't exist in another.

scriptNode = scenePlug.ancestor( Gaffer.ScriptNode )
selection = GafferSceneUI.ScriptNodeAlgo.getSelectedPaths( scriptNode )

primVars = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be better to use a set here rather than a list? I can't see where we're deduplicating things, so I think that might be happening inside MenuDefinition.append(), which is pretty inefficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants