38 friend class Flowgraph;
44 const std::string title;
45 const std::string internal_id;
46 const std::shared_ptr<NodeInternal> internal;
48 bool pos_was_set =
false;
58 NLOHMANN_DEFINE_TYPE_INTRUSIVE(InOut,
id, name, is_out);
61 std::vector<InOut> node_io;
66 for (
auto &io : internal->blk->get_inputs())
67 node_io.push_back({_f->getNewNodeIOID(&node_io), io.name,
false});
68 for (
auto &io : internal->blk->get_outputs())
69 node_io.push_back({_f->getNewNodeIOID(&node_io), io.name,
true});
73 Node(Flowgraph *f, std::string
id, std::shared_ptr<NodeInternal> i) : _f(f), id(f->getNewNodeID()), internal_id(
id), title(i->blk->d_id), internal(i) { updateIO(); }
75 Node(Flowgraph *f, nlohmann::json j, std::shared_ptr<NodeInternal> i)
76 : id(j[
"id"]), internal_id(j[
"int_id"]), title(i->blk->d_id), node_io(j[
"io"].get<std::vector<InOut>>()), internal(i)
78 if (j.contains(
"int_cfg"))
79 internal->setP(j[
"int_cfg"]);
81 pos_x = j.contains(
"pos_x") ? j[
"pos_x"].get<
float>() : 0;
82 pos_y = j.contains(
"pos_y") ? j[
"pos_y"].get<
float>() : 0;
85 nlohmann::json getJSON()
90 j[
"int_id"] = internal_id;
91 j[
"int_cfg"] = internal->getP();
115 void renderAddMenu(std::pair<const std::string, NodeInternalReg> &opt, std::vector<std::string> cats,
int pos);
123 std::shared_ptr<Node> addNode(std::string
id, std::shared_ptr<NodeInternal> i)