summaryrefslogtreecommitdiff
path: root/rotord/src/rotor.cpp
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-10-06 02:03:44 +0100
committerComment <tim@gray.(none)>2013-10-06 02:03:44 +0100
commit3252e78c0a43613e2a48d39a8dec74ffaf5ee100 (patch)
tree4a52642267023663e4829d41fab7853367ea4363 /rotord/src/rotor.cpp
parentb1e28de710c0810db2cc6a5c298080238b68bfbc (diff)
video loader stretch to segment
Diffstat (limited to 'rotord/src/rotor.cpp')
-rw-r--r--rotord/src/rotor.cpp260
1 files changed, 252 insertions, 8 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp
index 77d6d0f..444d861 100644
--- a/rotord/src/rotor.cpp
+++ b/rotord/src/rotor.cpp
@@ -1,4 +1,8 @@
#include "rotor.h"
+
+#include "nodes_signals.h"
+#include "nodes_channels.h"
+#include "nodes_source.h"
#include "nodes_audio_analysis.h"
#include "nodes_maths.h"
#include "nodes_drawing.h"
@@ -15,7 +19,7 @@ Node_factory::Node_factory(){
//this can be hard coded also
//
- categories["signals"]=vector<Rotor::Node*>();
+ categories["signals"]=vector<Node*>();
add_type("time",new Time(),categories["signals"]);
add_type("track_time",new Track_time(),categories["signals"]);
add_type("at_track_time",new At_track_time(),categories["signals"]);
@@ -23,7 +27,7 @@ Node_factory::Node_factory(){
add_type("signal_output",new Signal_output());
add_type("testcard",new Testcard());
//
- categories["channels"]=vector<Rotor::Node*>();
+ categories["channels"]=vector<Node*>();
add_type("invert",new Invert(),categories["channels"]);
add_type("monochrome",new Monochrome(),categories["channels"]);
add_type("blend",new Blend(),categories["channels"]);
@@ -33,7 +37,7 @@ Node_factory::Node_factory(){
add_type("rgb_levels",new RGB_levels(),categories["channels"]);
add_type("luma_levels",new Luma_levels(),categories["channels"]);
- categories["source"]=vector<Rotor::Node*>();
+ categories["source"]=vector<Node*>();
add_type("signal_colour",new Signal_colour(),categories["source"]);
add_type("signal_greyscale",new Signal_greyscale(),categories["source"]);
add_type("shape",new Shape(),categories["source"]);
@@ -42,26 +46,26 @@ Node_factory::Node_factory(){
add_type("still_image",new Still_image(),categories["source"]);
add_type("video_loader",new Video_loader(),categories["source"]);
- categories["distort"]=vector<Rotor::Node*>();
+ categories["distort"]=vector<Node*>();
add_type("mirror",new Mirror(),categories["distort"]);
add_type("transform",new Transform(),categories["distort"]);
- categories["editing"]=vector<Rotor::Node*>();
+ categories["editing"]=vector<Node*>();
add_type("video_cycler",new Video_cycler(),categories["editing"]);
add_type("video_output",new Video_output(),categories["editing"]);
add_type("act_segmenter",new Act_segmenter(),categories["editing"]);
- categories["audio"]=vector<Rotor::Node*>();
+ categories["audio"]=vector<Node*>();
add_type("audio_analysis",new Audio_analysis(),categories["audio"]);
- categories["maths"]=vector<Rotor::Node*>();
+ categories["maths"]=vector<Node*>();
add_type("comparison",new Comparison(),categories["maths"]); //TODO: alias to symbols
add_type("arithmetic",new Arithmetic(),categories["maths"]); //TODO: alias to symbols
add_type("bang",new Is_new_integer(),categories["maths"]);
add_type("on_off",new On_off(),categories["maths"]);
add_type("random",new Random(),categories["maths"]);
- categories["fx"]=vector<Rotor::Node*>();
+ categories["fx"]=vector<Node*>();
add_type("blur",new Blur(),categories["fx"]);
add_type("vhs",new VHS(),categories["fx"]);
add_type("echo_trails",new Echo_trails(),categories["fx"]);
@@ -96,3 +100,243 @@ float Parameter::get(const Time_spec& time){ //gets input and updates variable
}
return value;
}
+bool Node_factory::list_node(const string &t,xmlIO XML){
+ for (auto& type: type_map) {
+ if (type.first==t) {
+ list_node(type.second,XML);
+ return true;
+ }
+ }
+ XML.addValue("error","Node /"+t+"/ not found");
+};
+void Node_factory::list_node(Rotor::Node* type,xmlIO XML,int i=0){
+ XML.addTag("node");
+ XML.addAttribute("node","type",type->type,i);
+ XML.addAttribute("node","inputs",type->duplicate_inputs?"expandable":"fixed",i);
+ XML.addAttribute("node","title",type->title,i);
+ XML.addAttribute("node","description",type->description,i);
+ XML.addAttribute("node","UID",type->UID,i);
+ if (dynamic_cast<Signal_node*> (type)!=nullptr) XML.addAttribute("node","output","signal",i);
+ if (dynamic_cast<Image_node*> (type)!=nullptr) XML.addAttribute("node","output","image",i);
+ XML.pushTag("node",i);
+ //if (type->description!="") {
+ // XML.addTag("description");
+ // XML.setValue("description",type->description,0);
+ //}
+ int j=0;
+ for (auto& input: type->inputs) {
+ XML.addTag("signal_input");
+ XML.addAttribute("signal_input","title",input->title,j);
+ XML.addAttribute("signal_input","description",input->description,j);
+ j++;
+ }
+ j=0;
+ if (dynamic_cast<Image_node*> (type)!=nullptr) {
+ for (auto& input: (dynamic_cast<Image_node*>(type))->image_inputs) {
+ XML.addTag("image_input");
+ XML.addAttribute("image_input","title",input->title,j);
+ XML.addAttribute("image_input","description",input->description,j);
+ j++;
+ }
+ }
+ j=0;
+ for (auto& parameter: type->parameters) {
+ XML.addTag("parameter");
+ XML.addAttribute("parameter","name",parameter.first,j);
+ XML.addAttribute("parameter","type",parameter.second->type,j);
+ XML.addAttribute("parameter","title",parameter.second->title,j);
+ XML.addAttribute("parameter","description",parameter.second->description,j);
+ XML.addAttribute("parameter","value",parameter.second->value,j);
+ XML.addAttribute("parameter","min",parameter.second->min,j);
+ XML.addAttribute("parameter","max",parameter.second->max,j);
+ j++;
+ }
+ j=0;
+ for (auto& attribute: type->attributes) {
+ XML.addTag("attribute");
+ 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","type","enum",j);
+ XML.pushTag("attribute",j);
+ int k=0;
+ for (auto val: attribute.second->vals){
+ XML.addTag("option");
+ XML.addAttribute("option","value",val,k);
+ k++;
+ }
+ XML.popTag();
+ }
+ else XML.addAttribute("attribute","type","string",j);
+ j++;
+ }
+ XML.popTag();
+}
+void Node_factory::list_nodes(xmlIO XML){
+ int i=0;
+ for (auto& type: type_map) {
+ if (type.second->description!="") { //blank description = internal/ testing node
+ list_node(type.second,XML,i);
+ i++;
+ }
+ }
+}
+void Node_factory::list_categories(xmlIO XML){
+ int i=0;
+ for (auto& category: categories) {
+ XML.addTag("category");
+ XML.addAttribute("category","name",category.first,i);
+ XML.pushTag("category",i);
+ int j=0;
+ for (auto& node: category.second){
+ list_node(node,XML,j);
+ j++;
+ }
+ XML.popTag();
+ i++;
+ }
+}
+void Node_factory::list_categories(Json::Value &JSON){
+ JSON["categories"]=Json::arrayValue;
+ for (auto& _category: categories) {
+ Json::Value category;
+ 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;
+ 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);
+ }
+ JSON["categories"].append(category);
+ }
+}
+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;
+ 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);
+ }
+ }
+} \ No newline at end of file