summaryrefslogtreecommitdiff
path: root/rotord/src/rotor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/rotor.cpp')
-rw-r--r--rotord/src/rotor.cpp315
1 files changed, 142 insertions, 173 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index 88284c9..840298e 100644
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -19,61 +19,62 @@ Node_factory::Node_factory(){
//this can be hard coded also
//
- category["signals"]=vector<Node*>();
- add_type("time",new Time(),category["signals"]);
- add_type("track_time",new Track_time(),category["signals"]);
- add_type("at_track_time",new At_track_time(),category["signals"]);
+ category["Signals"]=vector<Node*>();
+ add_type("time",new Time(),category["Signals"]);
+ add_type("track_time",new Track_time(),category["Signals"]);
+ add_type("at_track_time",new At_track_time(),category["Signals"]);
//
add_type("signal_output",new Signal_output());
add_type("testcard",new Testcard());
//
- category["channels"]=vector<Node*>();
- add_type("invert",new Invert(),category["channels"]);
- add_type("monochrome",new Monochrome(),category["channels"]);
- add_type("blend",new Blend(),category["channels"]);
- add_type("image_arithmetic",new Image_arithmetic(),category["channels"]);
- add_type("alpha_merge",new Alpha_merge(),category["channels"]);
- add_type("difference_matte",new Difference_matte(),category["channels"]);
- add_type("rgb_levels",new RGB_levels(),category["channels"]);
- add_type("luma_levels",new Luma_levels(),category["channels"]);
+ category["Channels"]=vector<Node*>();
+ add_type("invert",new Invert(),category["Channels"]);
+ add_type("monochrome",new Monochrome(),category["Channels"]);
+ add_type("blend",new Blend(),category["Channels"]);
+ add_type("image_arithmetic",new Image_arithmetic(),category["Channels"]);
+ add_type("alpha_merge",new Alpha_merge(),category["Channels"]);
+ add_type("difference_matte",new Difference_matte(),category["Channels"]);
+ add_type("rgb_levels",new RGB_levels(),category["Channels"]);
+ add_type("luma_levels",new Luma_levels(),category["Channels"]);
- category["source"]=vector<Node*>();
- add_type("signal_colour",new Signal_colour(),category["source"]);
- add_type("signal_greyscale",new Signal_greyscale(),category["source"]);
- add_type("shape",new Shape(),category["source"]);
- add_type("text",new Text(),category["source"]);
- add_type("waves",new Waves(),category["source"]);
- add_type("still_image",new Still_image(),category["source"]);
- add_type("video_loader",new Video_loader(),category["source"]);
- add_type("svg",new Svg(),category["source"]);
+ category["Source"]=vector<Node*>();
+ add_type("signal_colour",new Signal_colour(),category["Source"]);
+ add_type("signal_greyscale",new Signal_greyscale(),category["Source"]);
+ add_type("shape",new Shape(),category["Source"]);
+ add_type("text",new Text(),category["Source"]);
+ add_type("waves",new Waves(),category["Source"]);
+ add_type("still_image",new Still_image(),category["Source"]);
+ add_type("video_loader",new Video_loader(),category["Source"]);
+ add_type("video_bank",new Video_bank(),category["Source"]);
+ add_type("svg",new Svg(),category["Source"]);
- category["distort"]=vector<Node*>();
- add_type("mirror",new Mirror(),category["distort"]);
- add_type("transform",new Transform(),category["distort"]);
+ category["Distort"]=vector<Node*>();
+ add_type("mirror",new Mirror(),category["Distort"]);
+ add_type("transform",new Transform(),category["Distort"]);
- category["editing"]=vector<Node*>();
- add_type("video_cycler",new Video_cycler(),category["editing"]);
- add_type("video_output",new Video_output(),category["editing"]);
- add_type("act_segmenter",new Act_segmenter(),category["editing"]);
+ category["Editing"]=vector<Node*>();
+ add_type("video_cycler",new Video_cycler(),category["Editing"]);
+ add_type("video_output",new Video_output(),category["Editing"]);
+ add_type("act_segmenter",new Act_segmenter(),category["Editing"]);
- category["audio"]=vector<Node*>();
- add_type("audio_analysis",new Audio_analysis(),category["audio"]);
- add_type("audio_analysis2",new Audio_analysis2(),category["audio"]);
- add_type("intensity_segmenter",new Intensity_segmenter(),category["audio"]);
+ category["Audio"]=vector<Node*>();
+ add_type("audio_analysis",new Audio_analysis(),category["Audio"]);
+ add_type("audio_analysis2",new Audio_analysis2(),category["Audio"]);
+ add_type("intensity_segmenter",new Intensity_segmenter(),category["Audio"]);
- category["maths"]=vector<Node*>();
- add_type("comparison",new Comparison(),category["maths"]); //TODO: alias to symbols
- add_type("arithmetic",new Arithmetic(),category["maths"]); //TODO: alias to symbols
- add_type("bang",new Is_new_integer(),category["maths"]);
- add_type("on_off",new On_off(),category["maths"]);
- add_type("random",new Random(),category["maths"]);
- add_type("noise",new Noise(),category["maths"]);
+ category["Maths"]=vector<Node*>();
+ add_type("comparison",new Comparison(),category["Maths"]); //TODO: alias to symbols
+ add_type("arithmetic",new Arithmetic(),category["Maths"]); //TODO: alias to symbols
+ add_type("bang",new Is_new_integer(),category["Maths"]);
+ add_type("on_off",new On_off(),category["Maths"]);
+ add_type("random",new Random(),category["Maths"]);
+ add_type("noise",new Noise(),category["Maths"]);
- category["fx"]=vector<Node*>();
- add_type("blur",new Blur(),category["fx"]);
- add_type("vhs",new VHS(),category["fx"]);
- add_type("echo_trails",new Echo_trails(),category["fx"]);
- add_type("video_feedback",new Video_feedback(),category["fx"]);
+ category["FX"]=vector<Node*>();
+ add_type("blur",new Blur(),category["FX"]);
+ add_type("vhs",new VHS(),category["FX"]);
+ add_type("echo_trails",new Echo_trails(),category["FX"]);
+ add_type("video_feedback",new Video_feedback(),category["FX"]);
}
bool Signal_input::connect(Node* source) {
@@ -112,7 +113,89 @@ bool Node_factory::list_node(const string &t,xmlIO XML){
}
}
XML.addValue("error","Node /"+t+"/ not found");
+ return false;
};
+bool Node_factory::list_node(const string &t,Json::Value &JSON){
+ for (auto& type: type_map) {
+ if (type.first==t) {
+ JSON["node"]=list_node(type.second);
+ return true;
+ }
+ }
+ JSON["error"]="Node /"+t+"/ not found";
+ return false;
+};
+Json::Value Node_factory::list_node(Rotor::Node* _node){
+ Json::Value node;
+ node["type"]=_node->type;
+ node["title"]=_node->title;
+ node["inputs"]=_node->duplicate_inputs?"expandable":"fixed";
+ if (dynamic_cast<Signal_node*> (_node)!=nullptr) node["output"]="signal";
+ if (dynamic_cast<Image_node*> (_node)!=nullptr) node["output"]="image";
+ node["description"]=_node->description;
+ node["UID"]=_node->UID;
+ if (_node->inputs.size()){
+ node["signal_inputs"]=Json::arrayValue;
+ for (auto& input: _node->inputs) {
+ Json::Value signal_input;
+ signal_input["title"]=input->title;
+ signal_input["description"]=input->description;
+ node["signal_inputs"].append(signal_input);
+ }
+ }
+ if (dynamic_cast<Image_node*> (_node)!=nullptr) {
+ if ((dynamic_cast<Image_node*>(_node))->image_inputs.size()){
+ node["image_inputs"]=Json::arrayValue;
+ for (auto& input: (dynamic_cast<Image_node*>(_node))->image_inputs) {
+ Json::Value image_input;
+ image_input["title"]=input->title;
+ image_input["description"]=input->description;
+ node["image_inputs"].append(image_input);
+ }
+ }
+ }
+ if (_node->parameters.size()){
+ node["parameters"]=Json::arrayValue;
+ for (auto& param: _node->parameters) {
+ Json::Value parameter;
+ parameter["name"]=param.first;
+ parameter["type"]=param.second->type;
+ parameter["title"]=param.second->title;
+ parameter["description"]=param.second->description;
+ parameter["value"]=param.second->value;
+ parameter["min"]=param.second->min;
+ parameter["max"]=param.second->max;
+ parameter["step"]=param.second->step;
+ node["parameters"].append(parameter);
+ }
+ }
+ if (_node->attributes.size()){
+ node["attributes"]=Json::arrayValue;
+ for (auto& attr: _node->attributes) {
+ Json::Value attribute;
+ attribute["name"]=attr.first;
+ attribute["title"]=attr.second->title;
+ attribute["description"]=attr.second->description;
+ if (attr.second->vals.size()){ //document attribute enumeration
+ attribute["value"]=attr.second->value;
+ attribute["type"]="enum";
+ attribute["options"]=Json::arrayValue;
+ for (auto val: attr.second->vals){
+ attribute["options"].append(val);
+ }
+ }
+ else {
+ attribute["type"]=attr.second->type;
+ if (attr.second->type=="array"){
+ attribute["value"]=Json::arrayValue;
+ }
+ else attribute["value"]=attr.second->value;
+ }
+ node["attributes"].append(attribute);
+ }
+ }
+ return node;
+}
void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){
XML.addTag("node");
XML.addAttribute("node","type",type->type,i);
@@ -162,8 +245,8 @@ void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){
XML.addAttribute("attribute","name",attribute.first,j);
XML.addAttribute("attribute","title",attribute.second->title,j);
XML.addAttribute("attribute","description",attribute.second->description,j);
- XML.addAttribute("attribute","value",attribute.second->value,j);
if (attribute.second->vals.size()){ //document attribute enumeration
+ XML.addAttribute("attribute","value",attribute.second->value,j);
XML.addAttribute("attribute","type","enum",j);
XML.pushTag("attribute",j);
int k=0;
@@ -174,7 +257,15 @@ void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){
}
XML.popTag();
}
- else XML.addAttribute("attribute","type","string",j);
+ else {
+ XML.addAttribute("attribute","type",attribute.second->type,j);
+ if (attribute.second->type=="array"){
+ XML.pushTag("attribute",j);
+ XML.addTag("value");
+ XML.popTag();
+ }
+ else XML.addAttribute("attribute","value",attribute.second->value,j);
+ }
j++;
}
XML.popTag();
@@ -210,69 +301,9 @@ void Node_factory::list_categories(Json::Value &JSON){
category["name"]=_category.first;
category["nodes"]=Json::arrayValue;
for (auto& _node: _category.second){
- Json::Value node;
- node["type"]=_node->type;
- node["title"]=_node->title;
- node["inputs"]=_node->duplicate_inputs?"expandable":"fixed";
- if (dynamic_cast<Signal_node*> (_node)!=nullptr) node["output"]="signal";
- if (dynamic_cast<Image_node*> (_node)!=nullptr) node["output"]="image";
- node["description"]=_node->description;
- node["UID"]=_node->UID;
- if (_node->inputs.size()){
- node["signal_inputs"]=Json::arrayValue;
- for (auto& input: _node->inputs) {
- Json::Value signal_input;
- signal_input["title"]=input->title;
- signal_input["description"]=input->description;
- node["signal_inputs"].append(signal_input);
- }
- }
- if (dynamic_cast<Image_node*> (_node)!=nullptr) {
- if ((dynamic_cast<Image_node*>(_node))->image_inputs.size()){
- node["image_inputs"]=Json::arrayValue;
- for (auto& input: (dynamic_cast<Image_node*>(_node))->image_inputs) {
- Json::Value image_input;
- image_input["title"]=input->title;
- image_input["description"]=input->description;
- node["image_inputs"].append(image_input);
- }
- }
- }
- if (_node->parameters.size()){
- node["parameters"]=Json::arrayValue;
- for (auto& param: _node->parameters) {
- Json::Value parameter;
- parameter["name"]=param.first;
- parameter["type"]=param.second->type;
- parameter["title"]=param.second->title;
- parameter["description"]=param.second->description;
- parameter["value"]=param.second->value;
- parameter["min"]=param.second->min;
- parameter["max"]=param.second->max;
- parameter["step"]=param.second->step;
- node["parameters"].append(parameter);
- }
- }
- if (_node->attributes.size()){
- node["attributes"]=Json::arrayValue;
- for (auto& attr: _node->attributes) {
- Json::Value attribute;
- attribute["name"]=attr.first;
- attribute["title"]=attr.second->title;
- attribute["description"]=attr.second->description;
- attribute["value"]=attr.second->value;
- if (attr.second->vals.size()){ //document attribute enumeration
- attribute["type"]="enum";
- attribute["options"]=Json::arrayValue;
- for (auto val: attr.second->vals){
- attribute["options"].append(val);
- }
- }
- else attribute["type"]="string";
- node["attributes"].append(attribute);
- }
- }
- category["nodes"].append(node);
+ //cerr<<"Adding "<<_category.first<<":"<<_node->type<<endl;
+
+ category["nodes"].append(list_node(_node));
}
JSON["category"].append(category);
}
@@ -281,69 +312,7 @@ void Node_factory::list_nodes(Json::Value &JSON){
JSON["nodeslist"]=Json::arrayValue;
for (auto& type: type_map) {
if (type.second->description!="") { //blank description = internal/ testing node
- Json::Value node;
- node["type"]=type.first;
- node["title"]=type.second->title;
- node["inputs"]=type.second->duplicate_inputs?"expandable":"fixed";
- if (dynamic_cast<Signal_node*> (type.second)!=nullptr) node["output"]="signal";
- if (dynamic_cast<Image_node*> (type.second)!=nullptr) node["output"]="image";
- node["description"]=type.second->description;
- node["UID"]=type.second->UID;
- if (type.second->inputs.size()){
- node["signal_inputs"]=Json::arrayValue;
- for (auto& input: type.second->inputs) {
- Json::Value signal_input;
- signal_input["title"]=input->title;
- signal_input["description"]=input->description;
- node["signal_inputs"].append(signal_input);
- }
- }
- if (dynamic_cast<Image_node*> (type.second)!=nullptr) {
- if ((dynamic_cast<Image_node*>(type.second))->image_inputs.size()){
- node["image_inputs"]=Json::arrayValue;
- for (auto& input: (dynamic_cast<Image_node*>(type.second))->image_inputs) {
- Json::Value image_input;
- image_input["title"]=input->title;
- image_input["description"]=input->description;
- node["image_inputs"].append(image_input);
- }
- }
- }
- if (type.second->parameters.size()){
- node["parameters"]=Json::arrayValue;
- for (auto& param: type.second->parameters) {
- Json::Value parameter;
- parameter["name"]=param.first;
- parameter["type"]=param.second->type;
- parameter["title"]=param.second->title;
- parameter["description"]=param.second->description;
- parameter["value"]=param.second->value;
- parameter["min"]=param.second->min;
- parameter["max"]=param.second->max;
- parameter["step"]=param.second->step;
- node["parameters"].append(parameter);
- }
- }
- if (type.second->attributes.size()){
- node["attributes"]=Json::arrayValue;
- for (auto& attr: type.second->attributes) {
- Json::Value attribute;
- attribute["name"]=attr.first;
- attribute["title"]=attr.second->title;
- attribute["description"]=attr.second->description;
- attribute["value"]=attr.second->value;
- if (attr.second->vals.size()){ //document attribute enumeration
- attribute["type"]="enum";
- attribute["options"]=Json::arrayValue;
- for (auto val: attr.second->vals){
- attribute["options"].append(val);
- }
- }
- else attribute["type"]="string";
- node["attributes"].append(attribute);
- }
- }
- JSON["nodeslist"].append(node);
+ JSON["nodeslist"].append(list_node(type.second));
}
}
} \ No newline at end of file