Add hotkey to group nodes into a node graph#3002
Conversation
|
This looks very promising, thanks @minhpham1810, and take a look at the comment above for instructions on resolving the EasyCLA errors. |
7a4a73e to
027125f
Compare
027125f to
c344edb
Compare
|
@jstone-lucasfilm I just signed the CLA and changed my commit email, please have a look. |
|
Thanks for the excellent work here, @minhpham1810. The connection-preservation logic is more thorough than I'd expected, and the hard parts are done well. This PR has grown into something larger than the summary suggests, though, so before we dive into code review I'd like to align on scope. Two recommended next steps would be:
Once we've settled the scope, I'm glad to go deep on the grouping logic itself. Thanks again for the strong contribution! |
|
@jstone-lucasfilm Thank you so much for the detailed feedback! I admitted that I want a bit out of scope in this PR, so I reverted the changes I made in |
|
I would agree that to only allow top level / document level grouping to occur. ( For reference, I did rework to support graph nesting and fix a other related issues in this PR . ) BTW, there was another PR proposal which took advantage of the cut/paste mechanism. From a cursory look and revisit of the previous PR, my suggested approach is to
|
|
Thank you for the constructive review and feedback. From what we've been discussing so far, I will proceed with what @kwokcb suggested in the comment above. Please let me know if there is any further instructions or directions that you want to highlight @kwokcb @jstone-lucasfilm . |
|
@jstone-lucasfilm @kwokcb I just push the changes that relocate grouping logic into core. Please have a look. |
Summary
Moves the Graph Editor's node-grouping logic into a reusable, unit-tested core method, per maintainer feedback. The editor now delegates to core, grouping stays top-level-only, and the Shift+C hotkey remains a thin trigger.
Changes
source/MaterialXCore/Node.h— Declare newGraphElement::createNodeGraphFromNodes(nodes, name), which groups the given nodes into a new child nodegraph while preserving internal and boundary connections.source/MaterialXCore/Node.cpp— ImplementcreateNodeGraphFromNodesplus file-local helpers (ported from the editor) that copy the selected nodes into a new nodegraph, turn external upstream links into nodegraph interface inputs, rewire external downstream consumers to nodegraph outputs (with fan-out dedup), and remove the originals. The method is general and does not set layout attributes or enforce a document-only policy.source/MaterialXGraphEditor/Graph.cpp— Remove the in-editor grouping helpers and rewritegroupSelectedNodesIntoNodeGraphto collect the selected nodes and delegate to the core method, keeping only editor concerns (top-level guard, average node position, graph rebuild/relink/render).source/MaterialXTest/MaterialXCore/Node.cpp— Add[nodegraph]unit tests covering internal links, upstream/downstream boundary rewiring, fan-out output dedup, original removal, document validation, and the empty-selection case.source/MaterialXCore/Interface.cpp— Remove a redundant duplicateresolveNameReference<NodeGraph>no-op inPortElement::validateleft over from the reverted nesting rework.Testing
git diff --checkMaterialXTest "Graph editor grouping shortcut"cmake --build build --target MaterialXGraphEditorRelated Issue
Fixes #2018