78 friend class Flowgraph;
82 const std::string title;
83 const std::string internal_id;
84 const std::shared_ptr<NodeInternal> internal;
86 bool pos_was_set =
false;
96 NLOHMANN_DEFINE_TYPE_INTRUSIVE(InOut,
id, name, is_out);
99 std::vector<InOut> node_io;
102 Node(Flowgraph *f, std::string
id, std::shared_ptr<NodeInternal> i)
103 : id(f->getNewNodeID()), internal_id(
id), title(i->title), internal(i)
105 for (
auto &io : internal->inputs)
106 node_io.push_back({f->getNewNodeIOID(&node_io), io.name,
false});
107 for (
auto &io : internal->outputs)
108 node_io.push_back({f->getNewNodeIOID(&node_io), io.name,
true});
111 node_io.push_back({f->getNewNodeIOID(&node_io), io.name, out});
115 Node(Flowgraph *f, nlohmann::json j, std::shared_ptr<NodeInternal> i)
116 : id(j[
"id"]), internal_id(j[
"int_id"]), title(i->title), node_io(j[
"io"].get<std::vector<InOut>>()), internal(i)
118 internal->from_json(j[
"int_cfg"]);
121 node_io.push_back({f->getNewNodeIOID(&node_io), io.name, out});
124 pos_x = j.contains(
"pos_x") ? j[
"pos_x"].get<
float>() : 0;
125 pos_y = j.contains(
"pos_y") ? j[
"pos_y"].get<
float>() : 0;
128 nlohmann::json getJSON()
133 j[
"int_id"] = internal_id;
134 j[
"int_cfg"] = internal->to_json();
162 std::shared_ptr<Node> addNode(std::string
id, std::shared_ptr<NodeInternal> i)