partial reload from json working, but edges make problems

This commit is contained in:
Sebastian
2024-11-03 15:15:42 +01:00
parent 7bdd68bdcc
commit bfd8bb192e
5 changed files with 46 additions and 26 deletions
+19 -19
View File
@@ -69,8 +69,10 @@ namespace VISEQ::GRAPH::NODES {
}
inline void from_json(const json& j, MidiNode& N){
std::cout << "MidiNode" << std::endl;
j.at("id").get_to(N.id);
j.at("position").get_to(N.position);
j.at("position").get_to<Vec2Df>(N.position);
j.at("distributionMode").get_to(N.distributionMode);
j.at("nodeType").get_to(N.nodeType);
j.at("midi_note_channel").get_to(N.midi_note_channel);
@@ -94,6 +96,10 @@ namespace VISEQ::GRAPH::NODES {
inline void from_json(const json& j, std::shared_ptr<MidiNode>& N){
N.reset(new MidiNode(j.get<MidiNode>()));
}
inline void to_json(json& j, const MidiNode::NodeMidiOut& MO){
j = json{{"port_id", MO.i}, {"enabled", MO.enabled}, {"name", MO.name}};
}
/* ------------------- NODE ---------------------- */
@@ -111,23 +117,14 @@ namespace VISEQ::GRAPH::NODES {
std::cout << j.at("nodeType") << std::endl;
N = j.template get<MidiNode>();
}
/*j.at("id").get_to(N.id);*/
/*j.at("position").get_to(N.position);*/
/*j.at("distributionMode").get_to(N.distributionMode);*/
/*j.at("nodeType").get_to(N.nodeType);*/
//j.at("connections").get_to(N.connections);
}
inline void to_json(json& j, const SPTR_Node& N){
j = *N;
}
inline void to_json(json& j, const MidiNode::NodeMidiOut MO){
j = json{{"port_id", MO.i}, {"enabled", MO.enabled}, {"name", MO.name}};
}
inline void from_json(const json& j, std::shared_ptr<Node>& N){
std::cout << "SPTR_Node" << std::endl;
N.reset(new Node(j.get<Node>()));
}
@@ -136,6 +133,7 @@ namespace VISEQ::GRAPH::NODES {
namespace VISEQ::GRAPH {
inline void to_json(json& j, const GraphItem& G){
std::cout << "Movable" << std::endl;
j = json{{"id", G.id}, {"type", G.graphItemType}};
}
@@ -146,12 +144,22 @@ namespace VISEQ::GRAPH {
namespace VISEQ::BASE{
inline void to_json(json& j, const Movable& G){
std::cout << "Movable" << std::endl;
j = json{{"position", G.position}};
}
inline void to_json(json& j, const std::shared_ptr<Movable>& G){
j = *G;
}
inline void from_json(const json& j, Movable& G){
std::cout << "Movable" << std::endl;
// j = json{{"position", G.position}};
}
inline void from_json(json& j, const std::shared_ptr<Movable>& G){
// j = *G;
}
}
namespace VISEQ::SIGNAL{
@@ -163,11 +171,3 @@ namespace VISEQ::SIGNAL{
j = *G;
}
}
namespace VISEQ::MIDI {
inline void to_json(json& j, const MidiOutPort MO){
j = json{{"port_id", MO.number}, {"enabled", MO.enabled}};
}
}