diff options
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/cvimage.h | 4 | ||||
| -rw-r--r-- | rotord/src/rotor.cpp | 95 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 125 | ||||
| -rw-r--r-- | rotord/src/rotord.cpp | 24 |
4 files changed, 193 insertions, 55 deletions
diff --git a/rotord/src/cvimage.h b/rotord/src/cvimage.h index 2902295..ebf6f4c 100644 --- a/rotord/src/cvimage.h +++ b/rotord/src/cvimage.h @@ -213,6 +213,10 @@ namespace Rotor { int h,w; bool ownsRGBdata,ownsAdata,ownsZdata; //better done through auto_ptr? + //making the interface for mip mapping + //should reduce in powers of 2 + // + cv::Mat rgb; cv::Mat alpha; }; diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index 6c1c61e..77d6d0f 100644 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -9,47 +9,64 @@ using namespace Rotor; using Poco::Logger; Node_factory::Node_factory(){ //for now, statically load prototype map in constructor - add_type("time",new Time()); - add_type("track_time",new Track_time()); - add_type("at_track_time",new At_track_time()); + + //how to deal with categories + //have an associative array of arrays of pointers to nodes, "categories" + //this can be hard coded also + + // + categories["signals"]=vector<Rotor::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"]); + // add_type("signal_output",new Signal_output()); add_type("testcard",new Testcard()); - add_type("invert",new Invert()); - add_type("video_cycler",new Video_cycler()); - add_type("signal_colour",new Signal_colour()); - add_type("signal_greyscale",new Signal_greyscale()); - add_type("image_arithmetic",new Image_arithmetic()); - add_type("blend",new Blend()); - add_type("mirror",new Mirror()); - add_type("monochrome",new Monochrome()); - add_type("alpha_merge",new Alpha_merge()); - add_type("difference_matte",new Difference_matte()); - //nodes_audio_analysis.h - add_type("audio_analysis",new Audio_analysis()); - add_type("act_segmenter",new Act_segmenter()); - //nodes_maths.h - add_type("comparison",new Comparison()); //TODO: alias to symbols - add_type("arithmetic",new Arithmetic()); //TODO: alias to symbols - add_type("bang",new Is_new_integer()); - add_type("on_off",new On_off()); - add_type("random",new Random()); - //nodes_drawing.h - add_type("shape",new Shape()); - add_type("text",new Text()); - add_type("waves",new Waves()); - //nodes_filters.h - add_type("blur",new Blur()); - add_type("vhs",new VHS()); - add_type("luma_levels",new Luma_levels()); - add_type("echo_trails",new Echo_trails()); - add_type("rgb_levels",new RGB_levels()); - //nodes_transform.h - add_type("transform",new Transform()); - add_type("still_image",new Still_image()); - //video nodes - add_type("video_loader",new Video_loader()); - add_type("video_output",new Video_output()); - add_type("video_feedback",new Video_feedback()); + // + categories["channels"]=vector<Rotor::Node*>(); + add_type("invert",new Invert(),categories["channels"]); + add_type("monochrome",new Monochrome(),categories["channels"]); + add_type("blend",new Blend(),categories["channels"]); + add_type("image_arithmetic",new Image_arithmetic(),categories["channels"]); + add_type("alpha_merge",new Alpha_merge(),categories["channels"]); + add_type("difference_matte",new Difference_matte(),categories["channels"]); + add_type("rgb_levels",new RGB_levels(),categories["channels"]); + add_type("luma_levels",new Luma_levels(),categories["channels"]); + + categories["source"]=vector<Rotor::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"]); + add_type("text",new Text(),categories["source"]); + add_type("waves",new Waves(),categories["source"]); + add_type("still_image",new Still_image(),categories["source"]); + add_type("video_loader",new Video_loader(),categories["source"]); + + categories["distort"]=vector<Rotor::Node*>(); + add_type("mirror",new Mirror(),categories["distort"]); + add_type("transform",new Transform(),categories["distort"]); + + categories["editing"]=vector<Rotor::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*>(); + add_type("audio_analysis",new Audio_analysis(),categories["audio"]); + + categories["maths"]=vector<Rotor::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*>(); + add_type("blur",new Blur(),categories["fx"]); + add_type("vhs",new VHS(),categories["fx"]); + add_type("echo_trails",new Echo_trails(),categories["fx"]); + add_type("video_feedback",new Video_feedback(),categories["fx"]); + } bool Signal_input::connect(Node* source) { connection=dynamic_cast<Signal_node*>(source); diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index d6cbbc6..72ef7d0 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -1050,6 +1050,11 @@ namespace Rotor { } void add_type(string type,Node* proto){ type_map[type]=proto; + type_map[type]->type=type; + }; + void add_type(string type,Node* proto,vector<Rotor::Node*> &category){ + add_type(type,proto); + category.push_back(proto); }; Node *create(map<string,string> &settings){ if (settings.find("type")!=settings.end()) { @@ -1062,35 +1067,35 @@ namespace Rotor { bool list_node(const string &t,xmlIO XML){ for (auto& type: type_map) { if (type.first==t) { - list_node(type,XML); + list_node(type.second,XML); return true; } } XML.addValue("error","Node /"+t+"/ not found"); }; - void list_node(std::pair<const std::basic_string<char>, Rotor::Node*> &type,xmlIO XML,int i=0){ + void list_node(Rotor::Node* type,xmlIO XML,int i=0){ XML.addTag("node"); - XML.addAttribute("node","type",type.first,i); - XML.addAttribute("node","inputs",type.second->duplicate_inputs?"expandable":"fixed",i); - XML.addAttribute("node","title",type.second->title,i); - XML.addAttribute("node","description",type.second->description,i); - if (dynamic_cast<Signal_node*> (type.second)!=nullptr) XML.addAttribute("node","output","signal",i); - if (dynamic_cast<Image_node*> (type.second)!=nullptr) XML.addAttribute("node","output","image",i); + 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); + 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.second->description!="") { + //if (type->description!="") { // XML.addTag("description"); - // XML.setValue("description",type.second->description,0); + // XML.setValue("description",type->description,0); //} int j=0; - for (auto& input: type.second->inputs) { + 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.second)!=nullptr) { - for (auto& input: (dynamic_cast<Image_node*>(type.second))->image_inputs) { + 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); @@ -1098,7 +1103,7 @@ namespace Rotor { } } j=0; - for (auto& parameter: type.second->parameters) { + for (auto& parameter: type->parameters) { XML.addTag("parameter"); XML.addAttribute("parameter","name",parameter.first,j); XML.addAttribute("parameter","type",parameter.second->type,j); @@ -1110,7 +1115,7 @@ namespace Rotor { j++; } j=0; - for (auto& attribute: type.second->attributes) { + for (auto& attribute: type->attributes) { XML.addTag("attribute"); XML.addAttribute("attribute","name",attribute.first,j); XML.addAttribute("attribute","title",attribute.second->title,j); @@ -1136,11 +1141,98 @@ namespace Rotor { int i=0; for (auto& type: type_map) { if (type.second->description!="") { //blank description = internal/ testing node - list_node(type,XML,i); + list_node(type.second,XML,i); i++; } } } + void 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 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; + 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 list_nodes(Json::Value &JSON){ JSON["nodeslist"]=Json::arrayValue; for (auto& type: type_map) { @@ -1211,6 +1303,7 @@ namespace Rotor { } private: unordered_map<string,Node*> type_map; + unordered_map<string,vector<Rotor::Node*> > categories; }; } diff --git a/rotord/src/rotord.cpp b/rotord/src/rotord.cpp index e7c68cf..a22c6c3 100644 --- a/rotord/src/rotord.cpp +++ b/rotord/src/rotord.cpp @@ -187,6 +187,30 @@ HTTPRequestHandler* RotorRequestHandlerFactory::createRequestHandler(const HTTPS } } } + else if (command[0]=="listcategories") { + if (command.size()>1){ + if (command[1]=="json") { + Json::Value root; + Json::StyledWriter writer; + //root["title"]="Lights Down @Rotor"; + //root["audio"]="filename"; + + Node_factory factory; + factory.list_categories(root); + string content = writer.write(root); + status=HTTPResponse::HTTP_OK; + return new RenderContextHandler(content, status); + } + } + else { + XML.pushTag("rotor"); + if (request.getMethod()=="GET") { + Node_factory factory; + factory.list_categories(XML); + status=HTTPResponse::HTTP_OK; + } + } + } else if (command[0]=="listnode") { XML.pushTag("rotor"); if (request.getMethod()=="GET") { |
