Flowgraph Group Helper
Helper class for grouping and ungrouping nodes in the flowgraph editor. Handles converting selected nodes into subgraphs, computing bounding rectangles, centering node layouts, and managing link re-ro
Helper class for grouping and ungrouping nodes in the flowgraph editor. Handles converting selected nodes into subgraphs, computing bounding rectangles, centering node layouts, and managing link re-routing during group/ungroup operations.
No public module exports - instantiated by the flowgraph manager.
Purpose
When users select multiple nodes and choose "Create Subgraph" or "Ungroup", this helper:
- Computes bounding rectangles for node selections
- Classifies links as internal, incoming, or outgoing
- Creates I/O boundary nodes for subgraph interfaces
- Re-routes links through subgraph entry/exit points
- Centers nodes within their new graph context
Class (C) - Key Methods
| Method | Signature | Description |
|---|---|---|
init | (mgr) | Stores manager reference. |
getRectCenter | (nodes) | Computes the bounding rectangle {minX, minY, maxX, maxY} and center point of a set of nodes. |
centerNodes | (nodes, pos) | Repositions nodes so their collective center aligns with pos, snapping to grid. |
centerMultiNodes | (fixNodes, moveNodes) | Centers moveNodes around the center of fixNodes. |
ungroupSelection | () | Dissolves a subgraph node, moving its child nodes back into the parent graph and re-routing links. |
Internal Functions
| Function | Description |
|---|---|
getEntryExitNode(graph) | Finds the stateEntry and stateExit nodes in a state graph. |
sortLinks(nodeIds, graph) | Classifies all links in a graph into inLinks (entering the selection), middleLinks (internal), and outLinks (leaving the selection). |
Grouping Flow
Selected Nodes in Parent Graph
│
▼
getRectCenter() → bounding rect + center
│
▼
sortLinks() → classify in/middle/out links
│
▼
Create child graph with:
- Selected nodes (moved)
- I/O boundary nodes for external connections
- Internal links preserved
- External links re-routed through I/O nodes
│
▼
Create "macro/integrated" node in parent graph
representing the subgraphUsage Context
-- The group helper is accessed through the manager:
local mgr = core_flowgraphManager.getManager(id)
mgr.groupHelper:getRectCenter(selectedNodes)
-- Grouping is typically triggered from node context menus:
-- Right-click → Create Subgraph...
-- Right-click on subgraph node → Ungroup
-- The helper handles all the complexity of:
-- 1. Moving nodes between graphs
-- 2. Creating I/O boundary pins
-- 3. Preserving link topology
-- 4. Grid-aligning repositioned nodesRect Calculation
-- Bounding rect for a set of nodes:
local rect, center = groupHelper:getRectCenter(nodes)
-- rect = {minX, minY, maxX, maxY}
-- center = {(minX+maxX)/2, (minY+maxY)/2}
-- Uses ui_flowgraph_editor.GetNodeSize/GetNodePosition
-- Defaults to 200×100 if node size is 0×0Additional Exports
createGroupingFromSelection()
groupStateNodes()
- Returns:
any
groupFlowNodes()
ungroupStateNode()
See Also
- Flowgraph Base Module - Related reference
- Flowgraph Base State Node - Related reference
- Flowgraph Base Node - Related reference
- FlowGraph Guide - Guide
Flowgraph Graph
Core graph class that holds nodes, links, and pins for a single flowgraph. Manages node creation/deletion, execution planning, variable storage, and serialization. Each manager contains one or more gr
Flowgraph Link
Represents a connection between two pins in a flowgraph graph. Handles link initialization, drawing (including flow animation markers), tooltips, serialization, and quick-access conversion.