2#include "Engine/Network/UpdateLock.h"
3#include "Engine/Operator/GeometryOperator.h"
4#include "Engine/UndoRedo/UndoStack.h"
7#include <unordered_map>
34 using Map = std::unordered_map<OpId, std::unique_ptr<GeometryOperator>>;
40 using value_type = std::pair<const OpId, GeometryOperator&>;
41 using reference = value_type;
42 using difference_type = std::ptrdiff_t;
43 using iterator_category = std::forward_iterator_tag;
45 Iterator(Map::iterator it) : it_(it) {}
46 reference operator*()
const {
return {it_->first, *it_->second}; }
47 Iterator& operator++() { ++it_;
return *
this; }
49 bool operator==(
const Iterator& other)
const {
return it_ == other.it_; }
50 bool operator!=(
const Iterator& other)
const {
return it_ != other.it_; }
54 Iterator begin() {
return Iterator(map_.begin()); }
55 Iterator end() {
return Iterator(map_.end()); }
56 std::size_t size()
const {
return map_.size(); }
143 void moveNode(
OpId opId, bt::Vector2f newPos,
bool skipUndo=
false);
184 boost::signals2::signal<void (std::optional<nt::OpId>)> displayNodeChanged;
189 boost::signals2::signal<void (std::shared_ptr<const enzo::NodePacket>)> displayGeoChanged;
192 boost::signals2::signal<void (std::shared_ptr<const enzo::NodePacket>)> selectedGeoChanged;
195 boost::signals2::signal<void (std::vector<nt::OpId> selectedNodeIds)> selectedNodesChanged;
198 boost::signals2::signal<void (
nt::OpId)> operatorCreated;
201 boost::signals2::signal<void (
nt::OpId)> operatorRemoved;
204 boost::signals2::signal<void (std::weak_ptr<nt::GeometryConnection>)> connectionCreated;
207 boost::signals2::signal<void ()> networkCleared;
210 boost::signals2::signal<void (
nt::OpId, bt::Vector2f)> nodePositionChanged;
213 UndoStack& undoStack() {
return undoStack_; }
224 std::vector<enzo::nt::OpId> getDependencyGraph(
enzo::nt::OpId opId);
225 std::vector<enzo::nt::OpId> getDependentsGraph(
enzo::nt::OpId opId);
230 void onNodeDirtied(nt::OpId opId,
bool dirtyDependents);
234 std::vector<enzo::nt::OpId> selectedNodes_;
235 std::unordered_map<enzo::nt::OpId, std::unique_ptr<enzo::nt::GeometryOperator>> gopStore_;
239 std::optional<OpId> displayOp_=std::nullopt;
241 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:87
The unique runtime representation of a node.
Definition GeometryOperator.h:20
Definition NetworkManager.h:37
Iterable range over operators, yields {OpId, GeometryOperator&} pairs.
Definition NetworkManager.h:33
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:69
void removeOperator(OpId opId)
Removes an operator and all its connections from the network.
Definition NetworkManager.cpp:84
void setSelectedNodes(std::vector< enzo::nt::OpId > opIds)
Replaces the entire selection with the given set of nodes.
Definition NetworkManager.cpp:247
NetworkManager(const NetworkManager &obj)=delete
Deleted the copy constructor for singleton.
bool isValidOp(nt::OpId opId)
Returns whether the node exists in the network and is valid.
Definition NetworkManager.cpp:150
void clearDisplayFlag()
Clears the display flag so no node is displayed.
Definition NetworkManager.cpp:171
void setSelectedNode(OpId opId, bool selected, bool add=false)
Set the selection state for the given node.
Definition NetworkManager.cpp:178
void setDisplayOp(OpId opId)
Sets given OpId to be displayed, releasing previous display Node.
Definition NetworkManager.cpp:160
void cookOp(enzo::nt::OpId opId)
Cooks the given operator.
Definition NetworkManager.cpp:272
void deleteNode(OpId opId)
Deletes a node, pushing an undo command.
Definition NetworkManager.cpp:59
OperatorRange operators()
Returns an iterable range over all operators in the network.
Definition NetworkManager.h:60
const std::vector< enzo::nt::OpId > & getSelectedNodes()
Returns the OpIds for all selected nodes.
Definition NetworkManager.cpp:242
static NetworkManager & getInstance()
Returns a reference to the singleton instance.
Definition NetworkManager.cpp:134
OpId createOperator(op::OpInfo opInfo, bt::Vector2f position={0.f, 0.f})
Creates a new node in the network.
Definition NetworkManager.cpp:20
enzo::nt::UpdateLock lockUpdates()
Creates a lock object that prevents cooking until destroyed.
Definition NetworkManager.cpp:214
void clear()
Clears all operators and resets the network to its initial state.
Definition NetworkManager.cpp:261
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:340
void update()
Cooks dirtied nodes, is called automatically.
Definition NetworkManager.cpp:219
GeometryOperator & getGeoOperator(nt::OpId opId)
Returns a reference to the GeometryOperator with the given OpId.
Definition NetworkManager.cpp:140
void moveNode(OpId opId, bt::Vector2f newPos, bool skipUndo=false)
Moves a node to a new position, pushing an undo command.
Definition NetworkManager.cpp:45
Definition UndoStack.h:10
Prevents updates on the network manager while in scope.
Definition UpdateLock.h:16