3#include "Engine/Network/GeometryOperator.h"
4#include "Engine/Network/UpdateLock.h"
5#include "Engine/NetworkGraph/NetworkGraph.h"
6#include "Engine/UndoRedo/UndoStack.h"
8#include <unordered_map>
32 using Map = std::unordered_map<OpId, std::unique_ptr<GeometryOperator>>;
41 using value_type = std::pair<const OpId, GeometryOperator&>;
42 using reference = value_type;
43 using difference_type = std::ptrdiff_t;
44 using iterator_category = std::forward_iterator_tag;
46 Iterator(Map::iterator it) : it_(it) {}
47 reference operator*()
const {
return {it_->first, *it_->second}; }
59 bool operator==(
const Iterator& other)
const {
return it_ == other.it_; }
60 bool operator!=(
const Iterator& other)
const {
return it_ != other.it_; }
64 Iterator begin() {
return Iterator(map_.begin()); }
65 Iterator end() {
return Iterator(map_.end()); }
66 std::size_t size()
const {
return map_.size(); }
159 void moveNode(
OpId opId, Vector2 newPos,
bool skipUndo =
false);
210 unsigned int inputIndex,
212 unsigned int outputIndex
234 boost::signals2::signal<void(std::optional<nt::OpId>)> displayNodeChanged;
239 boost::signals2::signal<void(std::shared_ptr<const enzo::NodePacket>)> displayGeoChanged;
242 boost::signals2::signal<void(std::shared_ptr<const enzo::NodePacket>)> selectedGeoChanged;
245 boost::signals2::signal<void(std::vector<nt::OpId> selectedNodeIds)> selectedNodesChanged;
248 boost::signals2::signal<void(
nt::OpId)> operatorCreated;
251 boost::signals2::signal<void(
nt::OpId)> operatorRemoved;
260 boost::signals2::signal<void()> networkCleared;
263 boost::signals2::signal<void(
nt::OpId, Vector2)> nodePositionChanged;
266 UndoStack& undoStack() {
return undoStack_; }
278 void disconnectOperator(OpId opId);
283 void onNodeDirtied(nt::OpId opId,
bool dirtyDependents);
287 std::vector<enzo::nt::OpId> selectedNodes_;
288 std::unordered_map<enzo::nt::OpId, std::unique_ptr<enzo::nt::GeometryOperator>> gopStore_;
292 std::optional<OpId> displayOp_ = std::nullopt;
294 nt::NetworkGraph graph_;
296 UndoStack undoStack_;
Basic attribute, parameter, and node types for Enzo.
uint64_t OpId
The unique ID assigned to each node in the network.
Definition Types.h:137
A path that references a network entity, either a node or a parameter on a node.
Definition NetworkPath.h:20
The unique runtime representation of a node.
Definition GeometryOperator.h:16
The single owner of the network's wiring and dependencies.
Definition NetworkGraph.h:24
Definition NetworkManager.h:37
Iterable range over operators, yields {OpId, GeometryOperator&} pairs.
Definition NetworkManager.h:31
The central coordinator of the engine's node system.
Definition NetworkManager.h:27
void restoreOperator(OpId opId, op::OpInfo opInfo)
Restores a previously removed operator with a specific OpId.
Definition NetworkManager.cpp:74
nt::Connection connectNodes(OpId inputOpId, unsigned int inputIndex, OpId outputOpId, unsigned int outputIndex)
Wires one node's output into another node's input.
Definition NetworkManager.cpp:312
std::weak_ptr< prm::NodeParameter > findParameter(const NetworkPath &path, OpId fromOp=nullOp)
Resolves a parameter reference to its parameter.
Definition NetworkManager.cpp:172
OpId createOperator(op::OpInfo opInfo, const std::string &path="", Vector2 position={0.f, 0.f})
Creates a new node in the network.
Definition NetworkManager.cpp:20
void setSelectedNodes(std::vector< enzo::nt::OpId > opIds)
Replaces the entire selection with the given set of nodes.
Definition NetworkManager.cpp:271
std::optional< OpId > getDisplayOp()
Returns the operator ID for the node with its display flag set. There can only be only be one operato...
Definition NetworkManager.cpp:367
void removeOperator(OpId opId, bool removeConnections=true)
Removes an operator from the network.
Definition NetworkManager.cpp:87
void moveNode(OpId opId, Vector2 newPos, bool skipUndo=false)
Moves a node to a new position, pushing an undo command.
Definition NetworkManager.cpp:42
GeometryOperator * findOperator(const NetworkPath &path, OpId fromOp=nullOp)
Resolves a node reference to its operator.
Definition NetworkManager.cpp:153
enzo::nt::UpdateLock lockUpdates()
Creates a lock object that prevents cooking until destroyed.
Definition NetworkManager.cpp:245
NetworkManager(const NetworkManager &obj)=delete
Deleted the copy constructor for singleton.
const std::vector< enzo::nt::OpId > & getSelectedNodes()
Returns the OpIds for all selected nodes.
Definition NetworkManager.cpp:269
bool isValidOp(nt::OpId opId)
Returns whether the node exists in the network and is valid.
Definition NetworkManager.cpp:182
void clearDisplayFlag()
Clears the display flag so no node is displayed.
Definition NetworkManager.cpp:203
void setSelectedNode(OpId opId, bool selected, bool add=false)
Set the selection state for the given node.
Definition NetworkManager.cpp:210
void setDisplayOp(OpId opId)
Sets given OpId to be displayed, releasing previous display Node.
Definition NetworkManager.cpp:192
void _reset()
For use in unit tests, resets the state of the operator.
Definition NetworkManager.cpp:386
void cookOp(enzo::nt::OpId opId)
Cooks the given operator.
Definition NetworkManager.cpp:297
void disconnectNodes(const nt::Connection &connection)
Removes a wired connection between two nodes.
Definition NetworkManager.cpp:345
void deleteNode(OpId opId)
Deletes a node, pushing an undo command.
Definition NetworkManager.cpp:56
OperatorRange operators()
Returns an iterable range over all operators in the network.
Definition NetworkManager.h:70
GeometryOperator & getGeoOperator(nt::OpId opId)
Returns a reference to the GeometryOperator with the given OpId.
Definition NetworkManager.cpp:141
void clear()
Clears all operators and resets the network to its initial state.
Definition NetworkManager.cpp:285
nt::NetworkGraph & graph()
Returns the graph that owns the network's wiring and dependencies.
Definition NetworkManager.h:203
void update()
Cooks dirtied nodes, is called automatically.
Definition NetworkManager.cpp:247
static NetworkManager & getInstance()
Returns a reference to the singleton instance.
Definition NetworkManager.cpp:135
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 Connection.h:20