Skip to content

Add hotkey to group nodes into a node graph#3002

Open
minhpham1810 wants to merge 7 commits into
AcademySoftwareFoundation:mainfrom
minhpham1810:issue-2018-group-nodes-nodegraph
Open

Add hotkey to group nodes into a node graph#3002
minhpham1810 wants to merge 7 commits into
AcademySoftwareFoundation:mainfrom
minhpham1810:issue-2018-group-nodes-nodegraph

Conversation

@minhpham1810

@minhpham1810 minhpham1810 commented Jul 8, 2026

Copy link
Copy Markdown

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 new GraphElement::createNodeGraphFromNodes(nodes, name), which groups the given nodes into a new child nodegraph while preserving internal and boundary connections.
  • source/MaterialXCore/Node.cpp — Implement createNodeGraphFromNodes plus 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 rewrite groupSelectedNodesIntoNodeGraph to 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 duplicate resolveNameReference<NodeGraph> no-op in PortElement::validate left over from the reverted nesting rework.

Testing

  • git diff --check
  • MaterialXTest "Graph editor grouping shortcut"
  • cmake --build build --target MaterialXGraphEditor

Related Issue

Fixes #2018

@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 8, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@minhpham1810 minhpham1810 changed the title Issue 2018 group nodes into nodegraph hotkey Add hot key to group nodes into a node graph Jul 8, 2026
@minhpham1810 minhpham1810 changed the title Add hot key to group nodes into a node graph Add hotkey to group nodes into a node graph Jul 8, 2026
@minhpham1810
minhpham1810 marked this pull request as draft July 9, 2026 00:16
@minhpham1810
minhpham1810 marked this pull request as ready for review July 9, 2026 00:17
@jstone-lucasfilm

Copy link
Copy Markdown
Member

This looks very promising, thanks @minhpham1810, and take a look at the comment above for instructions on resolving the EasyCLA errors.

@minhpham1810
minhpham1810 force-pushed the issue-2018-group-nodes-nodegraph branch from 7a4a73e to 027125f Compare July 9, 2026 03:55
@minhpham1810
minhpham1810 marked this pull request as draft July 9, 2026 03:59
@minhpham1810
minhpham1810 force-pushed the issue-2018-group-nodes-nodegraph branch from 027125f to c344edb Compare July 9, 2026 04:06
@minhpham1810
minhpham1810 marked this pull request as ready for review July 9, 2026 04:11
@minhpham1810

Copy link
Copy Markdown
Author

@jstone-lucasfilm I just signed the CLA and changed my commit email, please have a look.

@jstone-lucasfilm

Copy link
Copy Markdown
Member

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:

  1. Update the PR description to reflect the full change. It currently reads as a Shift+C shortcut fix, but it implements the whole grouping feature along with some MaterialXCore changes.
  2. The key decision is nested nodegraphs. When this was first scoped, @kwokcb suggested the editor guard against nesting; this PR adds support for it instead, which is what motivates the Interface.cpp changes. I'd suggest we start with grouping at the top document level only, which would cover the original use case, keep us on well-supported ground, and require no MaterialXCore changes. We can then take up nested nodegraphs (and the resolution work they require) as a deliberate follow-up.

Once we've settled the scope, I'm glad to go deep on the grouping logic itself. Thanks again for the strong contribution!

@minhpham1810

Copy link
Copy Markdown
Author

@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 MaterialXCore, as well as editing the safeguard for top-level document node grouping. Please let me know if there is any other parts that I should look at.

@kwokcb

kwokcb commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

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

  1. Put new "grouping" functionality in core so it's a reusable and testable function.
  2. Then expose it in editor.
  3. Then add the hotkey as a minor addition.

@minhpham1810

minhpham1810 commented Jul 15, 2026

Copy link
Copy Markdown
Author

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 .

@minhpham1810

Copy link
Copy Markdown
Author

@jstone-lucasfilm @kwokcb I just push the changes that relocate grouping logic into core. Please have a look.

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.

Graph Editor: Group nodes to create node graph

3 participants