Grid is reasonably functional with dual projectors.

This commit is contained in:
mmcwilliams 2019-04-19 22:55:57 -04:00
parent 5e0947d343
commit 687e1887ee
2 changed files with 144 additions and 37 deletions

View File

@ -50,11 +50,11 @@ class Grid {
className = cfg.cmd.projector_backward; className = cfg.cmd.projector_backward;
className2 = cfg.cmd.projector_second_backward; className2 = cfg.cmd.projector_second_backward;
} }
else if (step.cmd === cfg.cmd.camera_forward_camera_second_backward) { else if (step.cmd === cfg.cmd.projector_forward_projector_second_backward) {
className = cfg.cmd.projector_forward; className = cfg.cmd.projector_forward;
className2 = cfg.cmd.projector_second_backward; className2 = cfg.cmd.projector_second_backward;
} }
else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) { else if (step.cmd === cfg.cmd.projector_backward_projector_second_forward) {
className = cfg.cmd.projector_backward; className = cfg.cmd.projector_backward;
className2 = cfg.cmd.projector_second_forward; className2 = cfg.cmd.projector_second_forward;
} }
@ -90,6 +90,7 @@ class Grid {
$.each(step, function (index, value) { $.each(step, function (index, value) {
elem = $(this); elem = $(this);
cmdStr = elem.attr('class').replace('.', ''); cmdStr = elem.attr('class').replace('.', '');
//console.log(cmdStr)
if (elem.prop('checked') && cmdStr !== c) { if (elem.prop('checked') && cmdStr !== c) {
selected = cmdStr; selected = cmdStr;
return false; return false;
@ -148,14 +149,15 @@ class Grid {
const x = parseInt($(elem).attr('x')); const x = parseInt($(elem).attr('x'));
let checked = $(elem).prop('checked'); let checked = $(elem).prop('checked');
let c = ''; let c = '';
let current = '';
let other; let other;
// if input was not checked, but now is // if input was not checked, but now is
// event occurs after user action // event occurs after user action
c = $(elem).attr('class').replace('.', '');
if (checked) { if (checked) {
c = $(elem).attr('class').replace('.', '');
if (cam.second.enabled) { if (cam.second.enabled) {
other = this.otherCmd(x, c);
if (c === cfg.cmd.camera_forward) { if (c === cfg.cmd.camera_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
@ -167,7 +169,6 @@ class Grid {
} }
} }
else if (c === cfg.cmd.camera_backward) { else if (c === cfg.cmd.camera_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
@ -179,7 +180,6 @@ class Grid {
} }
} }
else if (c === cfg.cmd.camera_second_forward) { else if (c === cfg.cmd.camera_second_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
@ -191,7 +191,6 @@ class Grid {
} }
} }
else if (c === cfg.cmd.camera_second_backward) { else if (c === cfg.cmd.camera_second_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
@ -204,20 +203,19 @@ class Grid {
} }
} }
if (proj.second.enabled) { if (proj.second.enabled) {
other = this.otherCmd(x, c);
if (c === cfg.cmd.projector_forward) { if (c === cfg.cmd.projector_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
else if (other === cfg.cmd.projector_second_forward) { else if (other === cfg.cmd.projector_second_forward) {
c = cfg.cmd.projectorss_forward; c = cfg.cmd.projectors_forward;
} }
else if (other === cfg.cmd.projector_second_backward) { else if (other === cfg.cmd.projector_second_backward) {
c = cfg.cmd.projector_forward_projector_second_backward; c = cfg.cmd.projector_forward_projector_second_backward;
} }
} }
else if (c === cfg.cmd.projector_backward) { else if (c === cfg.cmd.projector_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
@ -229,7 +227,6 @@ class Grid {
} }
} }
else if (c === cfg.cmd.projector_second_forward) { else if (c === cfg.cmd.projector_second_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
@ -241,29 +238,93 @@ class Grid {
} }
} }
else if (c === cfg.cmd.projector_second_backward) { else if (c === cfg.cmd.projector_second_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} }
else if (other === cfg.cmd.projector_forward) { else if (other === cfg.cmd.projector_forward) {
c = cfg.cmd.projectors_forward_projector_second_backward; c = cfg.cmd.projector_forward_projector_second_backward;
} }
else if (other === cfg.cmd.projector_backward) { else if (other === cfg.cmd.projector_backward) {
c = cfg.cmd.projectors_backward; c = cfg.cmd.projectors_backward;
} }
} }
} }
console.log(c);
seq.set(x, c); seq.set(x, c);
} }
else { else {
if (seq.grid[x]) { if (seq.grid[x]) {
c = seq.grid[x].cmd + ''; // cast to string, bad hack current = seq.grid[x].cmd + ''; // cast to string, bad hack
} }
if (cam.second.enabled) { if (cam.second.enabled) {
other = this.otherCmd(x, c);
if (c === cfg.cmd.camera_forward
|| c === cfg.cmd.camera_backward) {
if (other === '') {
c = '';
}
else if (other === cfg.cmd.camera_second_forward) {
c = cfg.cmd.camera_second_forward;
}
else if (other === cfg.cmd.camera_second_backward) {
c = cfg.cmd.camera_second_backward;
}
}
else if (c === cfg.cmd.camera_second_forward
|| c === cfg.cmd.camera_second_backward) {
if (other === '') {
c = '';
}
else if (other === cfg.cmd.camera_forward) {
c = cfg.cmd.camera_forward;
}
else if (other === cfg.cmd.camera_backward) {
c = cfg.cmd.camera_backward;
}
}
} }
if (proj.second.enabled) { if (proj.second.enabled) {
other = this.otherCmd(x, c);
if (current === cfg.cmd.projectors_forward) {
if (other === cfg.cmd.projector_second_forward) {
c = cfg.cmd.projector_second_forward;
}
else if (other === cfg.cmd.projector_forward) {
c = cfg.cmd.projector_forward;
}
}
else if (current === cfg.cmd.projectors_backward) {
if (other === cfg.cmd.projector_second_backward) {
c = cfg.cmd.projector_second_backward;
}
else if (other === cfg.cmd.projector_backward) {
c = cfg.cmd.projector_backward;
}
}
else if (current === cfg.cmd.projector_forward_projector_second_backward) {
if (other === cfg.cmd.projector_second_backward) {
c = cfg.cmd.projector_second_backward;
}
else if (other === cfg.cmd.projector_forward) {
c = cfg.cmd.projector_forward;
}
}
else if (current === cfg.cmd.projector_backward_projector_second_forward) {
if (other === cfg.cmd.projector_second_forward) {
c = cfg.cmd.projector_second_forward;
}
else if (other === cfg.cmd.projector_backward) {
c = cfg.cmd.projector_backward;
}
}
}
if (c === '') {
seq.unset(x);
}
else {
console.log(c);
seq.set(x, c);
} }
seq.unset(x);
} }
this.state(x); this.state(x);
seq.stats(); seq.stats();

View File

@ -59,16 +59,17 @@ class Grid {
} else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) { } else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) {
className = cfg.cmd.camera_backward; className = cfg.cmd.camera_backward;
className2 = cfg.cmd.camera_second_forward; className2 = cfg.cmd.camera_second_forward;
} else if (step.cmd === cfg.cmd.projectors_forward) { } else if (step.cmd === cfg.cmd.projectors_forward) {
className = cfg.cmd.projector_forward; className = cfg.cmd.projector_forward;
className2 = cfg.cmd.projector_second_forward; className2 = cfg.cmd.projector_second_forward;
} else if (step.cmd === cfg.cmd.projectors_backward) { } else if (step.cmd === cfg.cmd.projectors_backward) {
className = cfg.cmd.projector_backward; className = cfg.cmd.projector_backward;
className2 = cfg.cmd.projector_second_backward; className2 = cfg.cmd.projector_second_backward;
} else if (step.cmd === cfg.cmd.camera_forward_camera_second_backward) { } else if (step.cmd === cfg.cmd.projector_forward_projector_second_backward) {
className = cfg.cmd.projector_forward; className = cfg.cmd.projector_forward;
className2 = cfg.cmd.projector_second_backward; className2 = cfg.cmd.projector_second_backward;
} else if (step.cmd === cfg.cmd.camera_backward_camera_second_forward) { } else if (step.cmd === cfg.cmd.projector_backward_projector_second_forward) {
className = cfg.cmd.projector_backward; className = cfg.cmd.projector_backward;
className2 = cfg.cmd.projector_second_forward; className2 = cfg.cmd.projector_second_forward;
} else { } else {
@ -104,6 +105,7 @@ class Grid {
$.each(step, function (index : number, value : any) { $.each(step, function (index : number, value : any) {
elem = $(this); elem = $(this);
cmdStr = elem.attr('class').replace('.', ''); cmdStr = elem.attr('class').replace('.', '');
//console.log(cmdStr)
if (elem.prop('checked') && cmdStr !== c) { if (elem.prop('checked') && cmdStr !== c) {
selected = cmdStr; selected = cmdStr;
return false; return false;
@ -161,16 +163,16 @@ class Grid {
const x : number = parseInt($(elem).attr('x')); const x : number = parseInt($(elem).attr('x'));
let checked : boolean = $(elem).prop('checked'); let checked : boolean = $(elem).prop('checked');
let c : string = ''; let c : string = '';
let current : string = '';
let other : string; let other : string;
// if input was not checked, but now is // if input was not checked, but now is
// event occurs after user action // event occurs after user action
c = $(elem).attr('class').replace('.', '');
if (checked) { if (checked) {
c = $(elem).attr('class').replace('.', '');
if (cam.second.enabled) { if (cam.second.enabled) {
other = this.otherCmd(x, c);
if (c === cfg.cmd.camera_forward) { if (c === cfg.cmd.camera_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.camera_second_forward) { } else if (other === cfg.cmd.camera_second_forward) {
@ -179,7 +181,6 @@ class Grid {
c = cfg.cmd.camera_forward_camera_second_backward; c = cfg.cmd.camera_forward_camera_second_backward;
} }
} else if (c === cfg.cmd.camera_backward) { } else if (c === cfg.cmd.camera_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.camera_second_forward) { } else if (other === cfg.cmd.camera_second_forward) {
@ -188,7 +189,6 @@ class Grid {
c = cfg.cmd.cameras_backward; c = cfg.cmd.cameras_backward;
} }
} else if (c === cfg.cmd.camera_second_forward) { } else if (c === cfg.cmd.camera_second_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.camera_forward) { } else if (other === cfg.cmd.camera_forward) {
@ -197,7 +197,6 @@ class Grid {
c = cfg.cmd.camera_forward_camera_second_backward; c = cfg.cmd.camera_forward_camera_second_backward;
} }
} else if (c === cfg.cmd.camera_second_backward) { } else if (c === cfg.cmd.camera_second_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.camera_second_forward) { } else if (other === cfg.cmd.camera_second_forward) {
@ -209,17 +208,16 @@ class Grid {
} }
if (proj.second.enabled) { if (proj.second.enabled) {
other = this.otherCmd(x, c);
if (c === cfg.cmd.projector_forward) { if (c === cfg.cmd.projector_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.projector_second_forward) { } else if (other === cfg.cmd.projector_second_forward) {
c = cfg.cmd.projectorss_forward; c = cfg.cmd.projectors_forward;
} else if (other === cfg.cmd.projector_second_backward) { } else if (other === cfg.cmd.projector_second_backward) {
c = cfg.cmd.projector_forward_projector_second_backward; c = cfg.cmd.projector_forward_projector_second_backward;
} }
} else if (c === cfg.cmd.projector_backward) { } else if (c === cfg.cmd.projector_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.projector_second_forward) { } else if (other === cfg.cmd.projector_second_forward) {
@ -228,7 +226,6 @@ class Grid {
c = cfg.cmd.projectors_backward; c = cfg.cmd.projectors_backward;
} }
} else if (c === cfg.cmd.projector_second_forward) { } else if (c === cfg.cmd.projector_second_forward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.projector_forward) { } else if (other === cfg.cmd.projector_forward) {
@ -237,33 +234,82 @@ class Grid {
c = cfg.cmd.projector_backward_projector_second_forward; c = cfg.cmd.projector_backward_projector_second_forward;
} }
} else if (c === cfg.cmd.projector_second_backward) { } else if (c === cfg.cmd.projector_second_backward) {
other = this.otherCmd(x, c);
if (other === '') { if (other === '') {
//skip modification //skip modification
} else if (other === cfg.cmd.projector_forward) { } else if (other === cfg.cmd.projector_forward) {
c = cfg.cmd.projectors_forward_projector_second_backward; c = cfg.cmd.projector_forward_projector_second_backward;
} else if (other === cfg.cmd.projector_backward) { } else if (other === cfg.cmd.projector_backward) {
c = cfg.cmd.projectors_backward; c = cfg.cmd.projectors_backward;
} }
} }
} }
seq.set(x, c); seq.set(x, c);
} else { } else {
if (seq.grid[x]) { if (seq.grid[x]) {
c = seq.grid[x].cmd + '' // cast to string, bad hack current = seq.grid[x].cmd + '' // cast to string, bad hack
} }
if (cam.second.enabled) { if (cam.second.enabled) {
other = this.otherCmd(x, c);
if (current === cfg.cmd.cameras_forward) {
if (other === cfg.cmd.camera_second_forward) {
c = cfg.cmd.camera_second_forward;
} else if (other === cfg.cmd.camera_forward) {
c = cfg.cmd.camera_forward;
}
} else if (current === cfg.cmd.cameras_backward) {
if (other === cfg.cmd.camera_second_backward) {
c = cfg.cmd.camera_second_backward;
} else if (other === cfg.cmd.camera_backward) {
c = cfg.cmd.camera_backward;
}
} else if (current === cfg.cmd.camera_forward_projector_second_backward) {
if (other === cfg.cmd.camera_second_backward) {
c = cfg.cmd.camera_second_backward;
} else if (other === cfg.cmd.camera_forward) {
c = cfg.cmd.camera_forward;
}
} else if (current === cfg.cmd.camera_backward_projector_second_forward) {
if (other === cfg.cmd.camera_second_forward) {
c = cfg.cmd.camera_second_forward;
} else if (other === cfg.cmd.camera_backward) {
c = cfg.cmd.camera_backward;
}
}
} }
if (proj.second.enabled) { if (proj.second.enabled) {
other = this.otherCmd(x, c);
if (current === cfg.cmd.projectors_forward) {
if (other === cfg.cmd.projector_second_forward) {
c = cfg.cmd.projector_second_forward;
} else if (other === cfg.cmd.projector_forward) {
c = cfg.cmd.projector_forward;
}
} else if (current === cfg.cmd.projectors_backward) {
if (other === cfg.cmd.projector_second_backward) {
c = cfg.cmd.projector_second_backward;
} else if (other === cfg.cmd.projector_backward) {
c = cfg.cmd.projector_backward;
}
} else if (current === cfg.cmd.projector_forward_projector_second_backward) {
if (other === cfg.cmd.projector_second_backward) {
c = cfg.cmd.projector_second_backward;
} else if (other === cfg.cmd.projector_forward) {
c = cfg.cmd.projector_forward;
}
} else if (current === cfg.cmd.projector_backward_projector_second_forward) {
if (other === cfg.cmd.projector_second_forward) {
c = cfg.cmd.projector_second_forward;
} else if (other === cfg.cmd.projector_backward) {
c = cfg.cmd.projector_backward;
}
}
}
if (c === '') {
seq.unset(x);
} else {
seq.set(x, c);
} }
seq.unset(x);
} }
this.state(x); this.state(x);