Skip to content

Commit

Permalink
add plugs in connection viewer
Browse files Browse the repository at this point in the history
Signed-off-by: Christian López Barrón <[email protected]>
  • Loading branch information
chrizzFTD committed Dec 9, 2024
1 parent 4bf2936 commit 1e8d903
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion grill/views/_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def _load_graph(self, graph):

def _add_node(nx_node):
node_data = graph.nodes[nx_node]
plugs = node_data.pop('plugs', ())
plugs = node_data.pop('plugs', ()) # implementation detail
nodes_attrs = ChainMap(node_data, graph_node_attrs)
if (shape := nodes_attrs.get('shape')) == 'record':
try:
Expand Down
4 changes: 3 additions & 1 deletion grill/views/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def traverse(api: UsdShade.ConnectableAPI):
node_id = _get_node_id(current_prim)
label = f'<<table border="1" cellspacing="2" style="ROUNDED" bgcolor="{background_color}" color="{outline_color}">'
label += table_row.format(port="", color="white", text=f'<font color="{outline_color}"><b>{api.GetPrim().GetName()}</b></font>')
plugs = {"": 0} # {graphviz port name: port index order}
for index, plug in enumerate(chain(api.GetInputs(), api.GetOutputs()), start=1): # we start at 1 because index 0 is the node itself
plug_name = plug.GetBaseName()
sources, __ = plug.GetConnectedSources() # (valid, invalid): we care only about valid sources (index 0)
Expand All @@ -263,8 +264,9 @@ def traverse(api: UsdShade.ConnectableAPI):
for source in sources:
_add_edges(_get_node_id(source.source.GetPrim()), source.sourceName, node_id, plug_name)
traverse(source.source)
plugs[plug_name] = index
label += '</table>>'
all_nodes[node_id] = dict(label=label)
all_nodes[node_id] = dict(label=label, plugs=plugs)

traverse(connections_api)

Expand Down
1 change: 0 additions & 1 deletion tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def test_connection_view(self):
cycle_input = pbrShader.CreateInput("cycle_in", Sdf.ValueTypeNames.Float)
cycle_output = pbrShader.CreateOutput("cycle_out", Sdf.ValueTypeNames.Float)
cycle_input.ConnectToSource(cycle_output)
description._graph_from_connections(material)
viewer = description._ConnectableAPIViewer()
# GraphView capabilities are tested elsewhere, so mock 'view' here.
viewer._graph_view.view = lambda indices: None
Expand Down

0 comments on commit 1e8d903

Please sign in to comment.