Working on config nodes. They exist now, but do nothing yet.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "config-node.h"
|
||||
#include "midi-node.h"
|
||||
#include "graph-item.h"
|
||||
#include "node.h"
|
||||
@@ -124,7 +125,51 @@ namespace VISEQ::GRAPH::NODES {
|
||||
j = json{{"port_id", MO.i}, {"enabled", MO.enabled}, {"name", MO.name}};
|
||||
}
|
||||
|
||||
/* ----------------- CONFIG NODE -----------------*/
|
||||
|
||||
inline void to_json(json& j, const ConfigNode& N){
|
||||
std::vector<int> conns;
|
||||
std::ranges::transform(N.connections.begin(), N.connections.end(), std::back_inserter(conns), [](VISEQ::GRAPH::EDGES::SPTR_Edge e){ return e->id;});
|
||||
|
||||
j = json{
|
||||
{"id", N.id},
|
||||
{"position", N.position},
|
||||
{"distributionMode", N.distributionMode},
|
||||
{"nodeType", N.nodeType},
|
||||
{"midi_note_channel",N.midiNote.channel},
|
||||
{"midi_note",N.midiNote.note},
|
||||
{"midi_cc_channel",N.midiCC.channel},
|
||||
{"midi_cc",N.midiCC.value},
|
||||
{"midi_pitch_bend_channel",N.midiPitchBend.channel},
|
||||
{"midi_pitch_bend",N.midiPitchBend.value},
|
||||
{"connections",conns}};
|
||||
}
|
||||
|
||||
inline void from_json(const json& j, ConfigNode& N){
|
||||
std::cout << "ConfigNode" << std::endl;
|
||||
|
||||
j.at("id").get_to(N.id);
|
||||
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.midiNote.channel);
|
||||
j.at("midi_note").get_to(N.midiNote.note);
|
||||
j.at("midi_cc_channel").get_to(N.midiCC.channel);
|
||||
j.at("midi_cc").get_to(N.midiCC.value);
|
||||
j.at("midi_pitch_bend_channel").get_to(N.midiPitchBend.channel);
|
||||
j.at("midi_pitch_bend").get_to(N.midiPitchBend.value);
|
||||
|
||||
//j.at("connections").get_to(N.connections);
|
||||
}
|
||||
|
||||
inline void to_json(json& j, const std::shared_ptr<ConfigNode>& N){
|
||||
j = *N;
|
||||
}
|
||||
|
||||
inline void from_json(const json& j, std::shared_ptr<ConfigNode>& N){
|
||||
N.reset(new ConfigNode(j.get<ConfigNode>()));
|
||||
}
|
||||
|
||||
/* ------------------- NODE ---------------------- */
|
||||
|
||||
|
||||
@@ -132,6 +177,9 @@ namespace VISEQ::GRAPH::NODES {
|
||||
if(N.getNodeType() == NodeType::MIDINODE){
|
||||
j = dynamic_cast<const MidiNode&>(N);
|
||||
}
|
||||
if(N.getNodeType() == NodeType::CONFIGNODE){
|
||||
j = dynamic_cast<const ConfigNode&>(N);
|
||||
}
|
||||
}
|
||||
|
||||
inline void from_json(const json& j, Node& N){
|
||||
@@ -140,6 +188,10 @@ namespace VISEQ::GRAPH::NODES {
|
||||
std::cout << j.at("nodeType") << std::endl;
|
||||
N = j.template get<MidiNode>();
|
||||
}
|
||||
if(j.at("nodeType") == NodeType::CONFIGNODE){
|
||||
std::cout << j.at("nodeType") << std::endl;
|
||||
N = j.template get<ConfigNode>();
|
||||
}
|
||||
}
|
||||
|
||||
inline void to_json(json& j, const SPTR_Node& N){
|
||||
|
||||
Reference in New Issue
Block a user