3#include "Engine/Network/Network.h"
4#include "Engine/Network/Node.h"
5#include "Engine/Network/Scope.h"
6#include "Engine/Network/UpdateLock.h"
7#include "Engine/NetworkGraph/NetworkGraph.h"
8#include "Engine/UndoRedo/UndoStack.h"
65 const std::string& typeName,
67 const std::string& name =
"",
68 Vector2 position = {0.f, 0.f}
171 floatT
getTime()
const {
return (frame_ - 1) / fps_; }
200 void moveNode(
NodeId nodeId, Vector2 newPos,
bool skipUndo =
false);
266 unsigned int inputIndex,
268 unsigned int outputIndex
280 return network_.
findNode(path, fromNode);
285 std::weak_ptr<prm::NodeParameter>
295 boost::signals2::signal<void(std::optional<nt::NodeId>)> displayNodeChanged;
300 boost::signals2::signal<void(std::shared_ptr<const enzo::NodePacket>)> displayGeoChanged;
303 boost::signals2::signal<void(std::shared_ptr<const enzo::NodePacket>)> selectedGeoChanged;
306 boost::signals2::signal<void(std::optional<nt::NodeId>)> primaryNodeChanged;
309 boost::signals2::signal<void(std::shared_ptr<const enzo::NodePacket>)> primaryGeoChanged;
312 boost::signals2::signal<void(std::vector<nt::NodeId> selectedNodeIds)> selectedNodesChanged;
315 boost::signals2::signal<void(
nt::NodeId)> nodeCreated;
318 boost::signals2::signal<void(
nt::NodeId)> nodeRemoved;
321 boost::signals2::signal<void(
nt::NodeLink)> nodeLinkCreated;
324 boost::signals2::signal<void(
nt::NodeLink)> nodeLinkRemoved;
327 boost::signals2::signal<void()> networkCleared;
330 boost::signals2::signal<void(
nt::NodeId, Vector2)> nodePositionChanged;
333 boost::signals2::signal<void(floatT frame)> frameChanged;
336 boost::signals2::signal<void(intT startFrame, intT endFrame)> frameRangeChanged;
339 boost::signals2::signal<void(floatT fps)> fpsChanged;
342 UndoStack& undoStack() {
return undoStack_; }
354 void disconnectNode(NodeId nodeId);
357 void openInputGap(NodeId nodeId,
unsigned int fromIndex);
360 void closeInputGap(NodeId nodeId,
unsigned int fromIndex);
363 void moveInput(
const nt::NodeLink& nodeLink,
unsigned int inputIndex);
368 void onNodeDirtied(nt::NodeId nodeId,
bool dirtyDependents);
372 void dirtyUnits_(
const std::vector<nt::Unit>& units);
375 void dirtyTimeDependents_();
382 nt::Network network_;
383 std::vector<enzo::nt::NodeId> selectedNodes_;
385 std::optional<NodeId> displayNode_ = std::nullopt;
387 std::optional<NodeId> primaryNode_ = std::nullopt;
391 intT startFrame_ = 1;
392 intT endFrame_ = 240;
395 UndoStack undoStack_;
Basic attribute, parameter, and node types for Enzo.
uint64_t NodeId
The unique ID assigned to each node in the network.
Definition Types.h:335
A path that references a network entity, either a node or a parameter on a node.
Definition NetworkPath.h:20
A default path class for creation and manipulation of tree-based paths.
Definition Path.h:14
The single owner of the network's wiring and dependencies.
Definition NetworkGraph.h:24
The central coordinator of the engine's node system.
Definition NetworkManager.h:31
void setEndFrame(intT frame)
Sets the frame the playback range ends on.
Definition NetworkManager.cpp:201
std::optional< NodeId > getPrimaryNode()
Returns the node ID of the primary node, or nullopt when none.
Definition NetworkManager.cpp:160
void setDisplayNode(NodeId nodeId)
Sets given NodeId to be displayed, releasing previous display Node.
Definition NetworkManager.cpp:142
bool isValidNode(nt::NodeId nodeId)
Returns whether the node exists in the network and is valid.
Definition NetworkManager.cpp:140
intT getStartFrame() const
Returns the first frame of the playback range.
Definition NetworkManager.h:149
Node * findNode(const NetworkPath &path, NodeId fromNode=nullNode)
Resolves a node reference such as "grid1" or "../grid1" to its node.
Definition NetworkManager.h:278
auto nodes()
Returns an iterable range over all nodes in the network.
Definition NetworkManager.h:37
NodeId createNode(const std::string &typeName, const Path &parent=Path("/"), const std::string &name="", Vector2 position={0.f, 0.f})
Creates a new node inside a scope.
Definition NetworkManager.cpp:22
void clearPrimaryNode()
Clears the primary node so none is primary.
Definition NetworkManager.cpp:173
Node & getNode(nt::NodeId nodeId)
Returns a reference to the Node with the given NodeId.
Definition NetworkManager.cpp:138
void cook(enzo::nt::NodeId nodeId)
Cooks the given node.
Definition NetworkManager.cpp:327
Node * getNodeAtPath(const Path &path)
Returns the node at an exact path, or null when no node is there.
Definition NetworkManager.h:73
floatT getTime() const
Returns the current frame as seconds, where the start of frame 1 is zero.
Definition NetworkManager.h:171
void setStartFrame(intT frame)
Sets the frame the playback range starts on.
Definition NetworkManager.cpp:191
enzo::nt::UpdateLock lockUpdates()
Creates a lock object that prevents cooking until destroyed.
Definition NetworkManager.cpp:265
const std::vector< enzo::nt::NodeId > & getSelectedNodes()
Returns the NodeIds for all selected nodes.
Definition NetworkManager.cpp:299
void setSelectedNode(NodeId nodeId, bool selected, bool add=false)
Set the selection state for the given node.
Definition NetworkManager.cpp:230
NetworkManager(const NetworkManager &obj)=delete
Deleted the copy constructor for singleton.
void moveNode(NodeId nodeId, Vector2 newPos, bool skipUndo=false)
Moves a node to a new position, pushing an undo command.
Definition NetworkManager.cpp:46
nt::NodeLink connectNodes(NodeId inputNodeId, unsigned int inputIndex, NodeId outputNodeId, unsigned int outputIndex)
Wires one node's output into another node's input.
Definition NetworkManager.cpp:358
void clearDisplayFlag()
Clears the display flag so no node is displayed.
Definition NetworkManager.cpp:153
floatT getFrame() const
Returns the frame the scene sits on.
Definition NetworkManager.h:143
unsigned int getInputCount(NodeId nodeId)
Returns how many inputs a node currently takes.
Definition NetworkManager.cpp:345
void setSelectedNodes(std::vector< enzo::nt::NodeId > nodeIds)
Replaces the entire selection with the given set of nodes.
Definition NetworkManager.cpp:301
void deleteNode(NodeId nodeId)
Deletes a node, pushing an undo command.
Definition NetworkManager.cpp:60
intT getEndFrame() const
Returns the last frame of the playback range.
Definition NetworkManager.h:152
void _reset()
For use in unit tests, resets the state of the node.
Definition NetworkManager.cpp:495
void createNodeWithId(NodeId nodeId, const nt::NodeType &nodeType, const Path &path, Vector2 position)
Creates a node with an identity the caller dictates rather than one picked here.
Definition NetworkManager.cpp:91
Scope * getScope(const Path &path)
Returns the scope at a path, or null when no scope sits there.
Definition NetworkManager.h:77
void setFrame(floatT frame)
Moves the scene to a frame, clamped to the playback range.
Definition NetworkManager.cpp:180
void setFps(floatT fps)
Sets how many frames make up a second of playback.
Definition NetworkManager.cpp:210
nt::Network & network()
Returns the network holding every node, its wiring, and its scopes.
Definition NetworkManager.h:34
void clear()
Clears all nodes and resets the network to its initial state.
Definition NetworkManager.cpp:315
nt::NetworkGraph & graph()
Returns the graph that owns the network's wiring and dependencies.
Definition NetworkManager.h:248
floatT getFps() const
Returns how many frames make up a second of playback.
Definition NetworkManager.h:163
void update()
Cooks dirtied nodes, is called automatically.
Definition NetworkManager.cpp:267
std::weak_ptr< prm::NodeParameter > findParameter(const NetworkPath &path, NodeId fromNode=nullNode)
Resolves a parameter reference such as "grid1.tx" to its parameter.
Definition NetworkManager.h:286
std::vector< NodeId > getChildNodeIds(const Path &scope)
Returns the ids of the nodes living directly inside a scope, in no particular order.
Definition NetworkManager.h:81
std::optional< NodeId > getDisplayNode()
Returns the node ID for the node with its display flag set. There can only be only be one node displa...
Definition NetworkManager.cpp:463
void disconnectNodes(const nt::NodeLink &nodeLink)
Removes a node link between two nodes.
Definition NetworkManager.cpp:399
void setPrimaryNode(NodeId nodeId)
Sets the given NodeId as the primary node, releasing the previous one.
Definition NetworkManager.cpp:162
static NetworkManager & getInstance()
Returns a reference to the singleton instance.
Definition NetworkManager.cpp:132
Every node in a scene, their wiring, and the scopes they live in.
Definition Network.h:30
Node * getNodeAtPath(const Path &path)
Returns the node at an exact path, or null when no node is there.
Definition Network.cpp:26
std::vector< NodeId > getChildNodeIds(const Path &scope)
Returns the ids of the nodes living directly inside a scope, in no particular order.
Definition Network.cpp:35
NetworkGraph & graph()
Returns the wiring and dependencies between the nodes.
Definition Network.h:103
std::weak_ptr< prm::NodeParameter > findParameter(const NetworkPath &path, NodeId fromNode=nullNode)
Resolves a parameter reference to its parameter.
Definition Network.cpp:102
Node * findNode(const NetworkPath &path, NodeId fromNode=nullNode)
Resolves a node reference to its node.
Definition Network.cpp:88
Scope * getScope(const Path &path)
Returns the scope at a path, or null when no scope sits there.
Definition Network.cpp:64
auto nodes()
Returns an iterable range over every node, yielding {NodeId, Node&} pairs.
Definition Network.h:43
The unique runtime representation of a node.
Definition Node.h:18
One place nodes live, either the root or the inside of a node that holds one.
Definition Scope.h:26
Definition UndoStack.h:11
Prevents updates on the network manager while in scope.
Definition UpdateLock.h:15
One wired link between two nodes, the ground truth of the network's wiring.
Definition NodeLink.h:20
Everything every node of one kind shares.
Definition NodeType.h:40