28#include "../system/system_utils.h"
29#include "../system/system_consts.h"
30#include "../third_party/imnodes/imnodes.h"
34#include <unordered_map>
78 eNode.nodeID = def.NodeID;
85 if (std::isfinite(def.EditorPosX) && std::isfinite(def.EditorPosY) &&
86 def.EditorPosX >= -100000.0f && def.EditorPosX <= 100000.0f &&
87 def.EditorPosY >= -100000.0f && def.EditorPosY <= 100000.0f)
89 eNode.posX = def.EditorPosX;
90 eNode.posY = def.EditorPosY;
94 SYSTEM_LOG <<
"[VSEditor] SyncCanvasFromTemplate: node #" << def.NodeID
95 <<
" had garbage position (" << def.EditorPosX <<
", " << def.EditorPosY
96 <<
"), using auto-layout\n";
97 eNode.posX = 200.0f *
static_cast<float>(
i);
103 eNode.posX = 200.0f *
static_cast<float>(
i);
113 if (def.Type ==
TaskNodeType::Branch && (!def.conditionRefs.empty() || !def.conditionOperandRefs.empty()))
116 eNode.def.conditionOperandRefs);
204 std::vector<std::string>
outPins;
212 for (
size_t d = 0;
d <
srcNode->DynamicExecOutputPins.size(); ++
d)
261 for (
size_t p = 0;
p <
srcNode->DataPins.size(); ++
p)
286 for (
size_t p = 0;
p <
dstNode->dynamicPins.size(); ++
p)
302 for (
size_t p = 0;
p <
inPins.size(); ++
p)
314 for (
size_t p = 0;
p <
dstNode->DataPins.size(); ++
p)
374 std::unordered_map<int, std::pair<float, float> >
savedPos;
381 if (!std::isfinite(posX) || !std::isfinite(posY) ||
388 <<
" had garbage position, reset to defaults\n";
406 eNode.nodeID = def.NodeID;
411 auto posXIt = def.Parameters.find(
"__posX");
412 auto posYIt = def.Parameters.find(
"__posY");
413 if (
posXIt != def.Parameters.end() &&
414 posYIt != def.Parameters.end() &&
431 SYSTEM_LOG <<
"[VSEditor] SyncEditorNodesFromTemplate: node #" << def.NodeID
433 <<
"), falling back\n";
438 eNode.posY =
it->second.second;
440 else if (def.HasEditorPos)
442 eNode.posX = def.EditorPosX;
443 eNode.posY = def.EditorPosY;
459 eNode.posY =
it->second.second;
461 else if (def.HasEditorPos)
464 if (std::isfinite(def.EditorPosX) && std::isfinite(def.EditorPosY) &&
465 def.EditorPosX >= -100000.0f && def.EditorPosX <= 100000.0f &&
466 def.EditorPosY >= -100000.0f && def.EditorPosY <= 100000.0f)
468 eNode.posX = def.EditorPosX;
469 eNode.posY = def.EditorPosY;
488 SYSTEM_LOG <<
"[VSEditor] SyncEditorNodesFromTemplate: node #" <<
eNode.nodeID
489 <<
" restored to (" <<
eNode.posX <<
"," <<
eNode.posY <<
")\n";
531 VSEditorLink*
link =
nullptr;
570 DataPinConnection
conn;
576 std::unique_ptr<ICommand>(
new DeleteLinkCommand(
conn)),
597 for (
size_t d = 0;
d <
srcNode->DynamicExecOutputPins.size(); ++
d)
612 ExecPinConnection
conn;
618 std::unique_ptr<ICommand>(
new DeleteLinkCommand(
conn)),
ComponentTypeID GetComponentTypeID_Static()
ImNodes-based graph editor for ATS Visual Script graphs (Phase 5).
std::vector< TaskNodeDefinition > Nodes
All graph nodes.
std::vector< ExecPinConnection > ExecConnections
Explicit exec connections (ATS VS only)
void BuildLookupCache()
Rebuilds the internal ID-to-node lookup map from the Nodes vector.
const TaskNodeDefinition * GetNode(int32_t nodeId) const
Returns a pointer to the node with the given ID, or nullptr.
std::vector< DataPinConnection > DataConnections
Explicit data connections (ATS VS only)
void PushCommand(std::unique_ptr< ICommand > cmd, TaskGraphTemplate &graph)
Executes the command on graph, then pushes it onto the undo stack.
std::unique_ptr< DynamicDataPinManager > m_pinManager
Dynamic pin manager shared across all Branch nodes in this panel.
UndoRedoStack m_undoStack
Undo/Redo command stack for reversible graph editing operations.
std::vector< VSEditorLink > m_editorLinks
Editor links (exec + data)
int ExecOutAttrUID(int nodeID, int pinIndex) const
Maps node ID + pin index -> ImNodes attribute UID for exec-out pins.
TaskGraphTemplate m_template
The template currently being edited.
int AllocLinkID()
Allocate a unique link ID.
void RemoveLink(int linkID)
Removes an ImNodes link (and its underlying template connection) by link ID.
static std::vector< std::string > GetExecInputPins(TaskNodeType type)
Returns the exec-in pin names for a node type.
void SyncCanvasFromTemplate()
Builds the editor canvas from the in-memory TaskGraphTemplate.
void SyncTemplateFromCanvas()
Builds the in-memory TaskGraphTemplate from the editor nodes/links.
static std::vector< std::string > GetDataOutputPins(TaskNodeType type)
Returns the data-out pin names for a node type.
static std::vector< std::string > GetDataInputPins(TaskNodeType type)
Returns the data-in pin names for a node type.
std::unordered_set< int > m_positionedNodes
Nodes for which ImNodes has been given a position.
int DataInAttrUID(int nodeID, int pinIndex) const
Maps node ID + data pin index -> ImNodes attribute UID for data-in pins.
void RebuildLinks()
Rebuilds ImNodes exec/data link arrays from the template.
int m_nextNodeID
Next available node ID.
std::unordered_map< int, std::pair< float, float > > m_nodeDragStartPositions
Per-node drag-start positions used to record a single MoveNodeCommand per drag gesture instead of one...
int DataOutAttrUID(int nodeID, int pinIndex) const
Maps node ID + data pin index -> ImNodes attribute UID for data-out pins.
int ExecInAttrUID(int nodeID) const
Maps node ID -> ImNodes attribute UID for an exec-in pin.
bool m_verificationDone
True once RunVerification() has been called at least once for the current graph.
std::vector< VSEditorNode > m_editorNodes
Editor nodes (mirrors m_template.Nodes + position/selection state)
void SyncEditorNodesFromTemplate()
Rebuilds m_editorNodes from m_template, preserving existing node positions.
static std::vector< std::string > GetExecOutputPins(TaskNodeType type)
Returns the exec-out pin names for a node type.
< Provides AssetID and INVALID_ASSET_ID
@ Literal
Value is embedded directly in the template.
@ Switch
Multi-branch on value (N exec outputs)
@ Branch
If/Else conditional (Then / Else exec outputs)
@ VSSequence
Execute N outputs in order ("VS" prefix avoids collision with BT Sequence=1)
@ Output
Value produced by the node.
@ Input
Value consumed by the node.