|
@@ -0,0 +1,266 @@
|
|
|
+
|
|
|
+SEQUENCE GROUPING MANAGEMENT MODULE
|
|
|
+allows to define a template of layers, then create groups of keys using that template
|
|
|
+groups are composed of one key per layer and a cue
|
|
|
+cue is used to define the time position of the keys
|
|
|
+values of each key can be changed
|
|
|
+keys are grouped by name, and groups can be saved/loaded to a file
|
|
|
+
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+var newKey = script.addTrigger("newKey", "adds a key at current cursor position" );
|
|
|
+var refreshKeys = script.addTrigger("refresh keys", "truc");
|
|
|
+var printKeys = script.addTrigger("printKeys","truc");
|
|
|
+var moveKey = script.addTrigger("moveKey","truc");
|
|
|
+
|
|
|
+
|
|
|
+var sequence_structure = { params: {},
|
|
|
+ groups:{},
|
|
|
+ keys:{
|
|
|
+ cues:{},
|
|
|
+ layers:{}
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ outCue : {pan : "key", tilt : "key", zoom : "key", dim : "key", focus : "key"}
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function init() {
|
|
|
+ script.log("LOADED SEQUENCE GROUPING MANAGEMENT MODULE ");
|
|
|
+
|
|
|
+ testSequenceFile();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function moduleParameterChanged(param){
|
|
|
+ script.log("received " + param.name);
|
|
|
+ if (param.name == "sequenceFile") {}
|
|
|
+ else if (param.name == "loadSequence"){loadSequenceFile();}
|
|
|
+ else if (param.name == "exportSequence") { exportSequenceFile();}
|
|
|
+ else if (param.name == "refreshList"){refreshSequenceEnum();}
|
|
|
+ else if (param.name == "sequence"){
|
|
|
+ var seq = root.sequences.getItems()[local.parameters.sequence.get()];
|
|
|
+ sequence_structure.params.sequence = seq.name ;
|
|
|
+ script.log(seq.name);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function moduleValueChanged(value){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function scriptParameterChanged(param){
|
|
|
+ script.log("paramchanged" + param.name);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (param.is(printKeys) ){printKeys();}
|
|
|
+ if(param.is(newKey)){
|
|
|
+ var key = root.sequences.sequence.layers.mapping.automation.addItem();
|
|
|
+ key.position.set(root.sequences.sequence.currentTime.get());
|
|
|
+ key.value.set(Math.random());
|
|
|
+ root.sequences.sequence.layers.mapping.automation.reorderItems();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.is(refreshKeys)){
|
|
|
+ script.log("refreshKeys");
|
|
|
+ refreshKeysList();
|
|
|
+ }
|
|
|
+ if (param.is(moveKey)){
|
|
|
+ root.sequences.sequence.layers.mapping.automation.key2.position.set(10.);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function printMethodsAndProperties(obj){
|
|
|
+ script.log(" ");
|
|
|
+ script.log(" METHODS OF " + obj.getControlAddress());
|
|
|
+ var methods = util.getObjectMethods(obj);
|
|
|
+ for(var i=0 ; i<methods.length ; i++){
|
|
|
+ script.log(" "+ methods[i]);
|
|
|
+ }
|
|
|
+ script.log(" PARAMETERS OF " + obj.getControlAddress());
|
|
|
+ var props = util.getObjectProperties(obj, true, false);
|
|
|
+ for(var i=0 ; i<props.length ; i++){
|
|
|
+ script.log(" "+ props[i]);
|
|
|
+ }
|
|
|
+ script.log(" OBJECTS OF " + obj.getControlAddress());
|
|
|
+ var props = util.getObjectProperties(obj, false, true);
|
|
|
+ for(var i=0 ; i<props.length ; i++){
|
|
|
+ script.log(" "+ props[i]);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function refreshSequenceEnum(){
|
|
|
+ script.log("refresh list of sequences");
|
|
|
+ local.parameters.sequence.setAttribute("readonly",false);
|
|
|
+ if(root.sequences.getItems().length){
|
|
|
+ local.parameters.sequence.removeOptions();
|
|
|
+ for(var i=0 ; i<root.sequences.getItems().length ; i++ ){
|
|
|
+ local.parameters.sequence.addOption(root.sequences.getItems()[i].name,i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function testSequenceFile(){
|
|
|
+ var file = local.parameters.sequenceFile;
|
|
|
+
|
|
|
+ if( file.getAbsolutePath() != ""){
|
|
|
+ script.log("testing file " + file.getAbsolutePath() );
|
|
|
+ var data = file.readFile(true);
|
|
|
+
|
|
|
+ if (data.groups == undefined){
|
|
|
+ script.log("file structure not recognized");
|
|
|
+ refreshSequenceEnum();
|
|
|
+ }
|
|
|
+
|
|
|
+ else {
|
|
|
+ script.log("ready to import");
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ script.log("no file to load");
|
|
|
+ refreshSequenceEnum();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function loadSequenceFile(){
|
|
|
+ script.log("loading file");
|
|
|
+ sequence_structure = data;
|
|
|
+
|
|
|
+ var sequenceList = local.parameters.sequence;
|
|
|
+ sequenceList.removeOptions();
|
|
|
+ sequenceList.addOption(data.params.sequence, 0);
|
|
|
+ local.parameters.sequence.setAttribute("readonly",true);
|
|
|
+}
|
|
|
+
|
|
|
+function exportSequenceFile(){
|
|
|
+ script.log("exporting file");
|
|
|
+ local.parameters.sequenceFile.writeFile(JSON.stringify(sequence_structure), true);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function printKeys(){
|
|
|
+
|
|
|
+ var seq = root.sequences.sequence.layers.mapping.automation.getItems() ;
|
|
|
+ if(seq.length){
|
|
|
+ for(var i=0; i<seq.length; i++){
|
|
|
+ script.log (">> "+seq[i].name + " " + seq[i].position.get() + " " + seq[i].listSize.get() );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{script.log("nothing to print");}
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+a nogroup container shows keys that are not grouped
|
|
|
+*/
|
|
|
+
|
|
|
+function clearValues(){
|
|
|
+ var values = local.values.getItems();
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function refreshKeysList(){
|
|
|
+
|
|
|
+ var sequence = root.sequences.getItemWithName(local.parameters.sequence.getKey(0));
|
|
|
+ var cues = sequence.cues.getItems();
|
|
|
+ sequence_structure.keys.cues = {};
|
|
|
+ if(cues.length){
|
|
|
+ for (var i = 0 ; i < cues.length ; i++){
|
|
|
+ sequence_structure.keys.cues['cue'+i] = {index : i};
|
|
|
+ sequence_structure.keys['cues']['cue'+i]['name'] = cues[i].name;
|
|
|
+ sequence_structure.keys['cues']['cue'+i]['niceName'] = cues[i].niceName;
|
|
|
+ sequence_structure.keys['cues']['cue'+i]['time'] = cues[i].time.get();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var layers = sequence.layers.getItems();
|
|
|
+ sequence_structure.keys.layers={};
|
|
|
+ if(layers.length){
|
|
|
+ for (var i = 0 ; i < layers.length ; i++){
|
|
|
+ sequence_structure['keys']['layers'][layers[i].name] = {};
|
|
|
+
|
|
|
+
|
|
|
+ if(layers[i].automation.getItems().length){
|
|
|
+
|
|
|
+ for (var j = 0 ; j < layers[i].automation.getItems().length ; j++){
|
|
|
+
|
|
|
+ var currentkey = layers[i].automation.getItems()[j] ;
|
|
|
+ sequence_structure['keys']['layers'][layers[i].name][currentkey.name] = {
|
|
|
+ position : currentkey.position.get(),
|
|
|
+ value : currentkey.value.get()
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|