Enzo
Loading...
Searching...
No Matches
NetworkManager.h
1#pragma once
2#include "Engine/Operator/GeometryOperator.h"
3#include "Engine/Operator/Geometry.h"
4#include "Engine/Types.h"
5#include <memory>
6#include <unordered_map>
7#include <QObject>
8
9namespace enzo::nt {
25: public QObject
26{
27 Q_OBJECT
28public:
30 NetworkManager(const NetworkManager& obj) = delete;
31
34
43
48 std::optional<OpId> getDisplayOp();
49
50
55 bool isValidOp(nt::OpId opId);
56
61
65 void setDisplayOp(OpId opId);
66
75 void setSelectedNode(OpId opId, bool selected, bool add=false);
76
80 const std::vector<enzo::nt::OpId>& getSelectedNodes();
81
85 // @brief A signal emitted when the display node is changed
86 boost::signals2::signal<void (nt::OpId)> displayNodeChanged;
87
88 // @brief A signal emitted when the geometry to be displayed is changed
89 // This is different to #displayNodeChanged because the state of geometry
90 // in a node can change based on parameters or other factors.
91 boost::signals2::signal<void (enzo::geo::Geometry& geometry)> displayGeoChanged;
92
93 // @brief A signal emitted when the selection of nodes changes
94 boost::signals2::signal<void (std::vector<nt::OpId> selectedNodeIds)> selectedNodesChanged;
97 #ifdef UNIT_TEST
99 void _reset();
100 #endif
101
102private:
103 NetworkManager() {};
104
105 // functions
106 void cookOp(enzo::nt::OpId opId);
107 std::vector<enzo::nt::OpId> getDependencyGraph(enzo::nt::OpId opId);
108 std::vector<enzo::nt::OpId> getDependentsGraph(enzo::nt::OpId opId);
109
110 // variables
111 // store for geometry operators
112 std::vector<enzo::nt::OpId> selectedNodes_;
113 std::unordered_map<enzo::nt::OpId, std::unique_ptr<enzo::nt::GeometryOperator>> gopStore_;
114 // the highest operator id currently stored
115 enzo::nt::OpId maxOpId_=0;
116 // operator selected for displaying in the viewport
117 std::optional<OpId> displayOp_=std::nullopt;
118
119
120};
121
122inline enzo::nt::NetworkManager& nm() {
124}
125}
Basic attribute, parameter, and node types for Enzo.
uint64_t OpId
The unique ID assigned to each node in the network.
Definition Types.h:80
Attribute based geometry container exchanged and modified by nodes.
The unique runtime representation of a node.
Definition GeometryOperator.h:19
The central coordinator of the engine's node system.
Definition NetworkManager.h:26
OpId addOperator(op::OpInfo opInfo)
Creates a new node in the network.
Definition NetworkManager.cpp:16
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:66
void setSelectedNode(OpId opId, bool selected, bool add=false)
Set the selection state for the given node.
Definition NetworkManager.cpp:87
void setDisplayOp(OpId opId)
Sets given OpId to be displayed, releasing previous display Node.
Definition NetworkManager.cpp:76
const std::vector< enzo::nt::OpId > & getSelectedNodes()
Returns the OpIds for all selected nodes.
Definition NetworkManager.cpp:123
static NetworkManager & getInstance()
Returns a reference to the singleton instance.
Definition NetworkManager.cpp:50
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:196
GeometryOperator & getGeoOperator(nt::OpId opId)
Returns a reference to the GeometryOperator with the given OpId.
Definition NetworkManager.cpp:56
Definition OpInfo.h:20