diff --git a/app.js b/app.js index 224ce45..78d9f53 100644 --- a/app.js +++ b/app.js @@ -14550,6 +14550,63 @@ function mixLabelOf(it){ return pc ? PER_CHI[it.type]+" – "+pc : (it.label||"").trim(); } function nomeAscolto(it,fallback){ var n=mixLabelOf(it); return n||fallback; } /* per i messaggi sui PM */ +/* L2 (15/11/2026, CAVI_SUL_PALCO R1-R4): dove nasce una drop box AUTOMATICA. Prima stava al baricentro del gruppo, 90 cm verso + il fondo: a metà palco, tra i musicisti. Ora sta sul BORDO del gruppo che serve (45-100 cm dal suo ingombro, lati e fondo), nella + cella libera a costo minimo = distanza media dalle sorgenti + 0,7 × distanza dal bordo del palco. Mai dentro un elemento, mai + negli ultimi 110 cm verso il pubblico (lì stanno voci e spie), ≥ 70 cm da un'altra box. Le box dell'utente non passano di qui. */ +var CAB_BOX_PUBBLICO=110, CAB_BOX_DIST=70; +/* ingombro DISEGNATO della box: oltre al rettangolo 33×17 ci sono la barra di capacità e la sigla sopra (≈ 34 cm) e la barra è larga ≈ 70 cm: + l'ingombro intero deve stare dentro il palco (regia 15/11: la box sul bordo di fondo usciva sopra la scritta «10 m») */ +var CAB_BOX_MX=36, CAB_BOX_SOPRA=34, CAB_BOX_BORDO_MAX=150, CAB_BOX_PESO_BORDO=1.5, CAB_BOX_ACCORPA_DIST=500; +function cabItemHalf(it){ + var t=TYPES[it.type]||{}, w=+it.w||t.w||40, d=+it.d||t.d||40, r=(it.rot||0)*Math.PI/180, c=Math.abs(Math.cos(r)), s=Math.abs(Math.sin(r)); + return {hx:(w*c+d*s)/2, hy:(w*s+d*c)/2}; +} +function cabPlaceAutoBox(its, taken){ + var W=state.stage.w, D=state.stage.d, T=TYPES.stagebox||{}, bw=(T.w||33)/2+4, bd=(T.d||17)/2+4; + var x0=Infinity,x1=-Infinity,y0=Infinity,y1=-Infinity, cx=0, cy=0; + its.forEach(function(it){ var h=cabItemHalf(it); x0=Math.min(x0,it.x-h.hx); x1=Math.max(x1,it.x+h.hx); y0=Math.min(y0,it.y-h.hy); y1=Math.max(y1,it.y+h.hy); cx+=it.x; cy+=it.y; }); + cx/=its.length; cy/=its.length; + var halves=state.items.map(function(it){ return {it:it, h:cabItemHalf(it)}; }); + var blocks=(state.stage.blocks&&state.stage.blocks.length)?state.stage.blocks:null; + function libero(x,y){ + if(xW-CAB_BOX_MX || yD-CAB_BOX_PUBBLICO) return false; + if(blocks && !blocks.some(function(b){ return x>=b.x+CAB_BOX_MX && x<=b.x+b.w-CAB_BOX_MX && y>=b.y+bd+CAB_BOX_SOPRA && y<=b.y+b.d-bd; })) return false; + for(var i=0;iCAB_BOX_BORDO_MAX); + if(lontano){ + var lane=null, cl=[[CAB_BOX_MX,cy],[W-CAB_BOX_MX,cy],[cx,bd+CAB_BOX_SOPRA]]; + for(var ly=y0; ly<=y1; ly+=60){ cl.push([CAB_BOX_MX,ly]); cl.push([W-CAB_BOX_MX,ly]); } + for(var lx=x0; lx<=x1; lx+=60) cl.push([lx,bd+CAB_BOX_SOPRA]); + cl.forEach(function(c){ var x=c[0], y=c[1]; if(!libero(x,y)) return; + var dd=Math.hypot(Math.max(x0-x,0,x-x1), Math.max(y0-y,0,y-y1)); if(dd>400) return; + var cost=its.reduce(function(a,it){ return a+Math.abs(it.x-x)+Math.abs(it.y-y); },0)/its.length + CAB_BOX_PESO_BORDO*Math.min(x,W-x,y); + if(!lane || cost0? +it.sbId : null), res:res, resMap:rm, resNome:((it.sbResNome && typeof it.sbResNome==="object") ? it.sbResNome : {}), taken:{}, pins:{}, name:(mxm ? (mxm.brand+" "+mxm.model) : (it.label||TYPES[it.type].defLabel||"BOX"))}; }); if(!manualMode && !boxes.length && totIn){ + /* L2: prima si decide QUANTI pezzi (gruppi per box), poi dove stanno. Un pezzo lontano da ogni bordo (box in mezzo al palco, + nel passaggio fra i musicisti) si accorpa a un pezzo vicino se i canali stanno nella stessa box da 8 */ + var _pezzi=[]; cabClusters(groups, 320).forEach(function(c){ /* soglia 3,2 m: batteria/tastiere/sezioni/voci diventano cluster distinti */ - var nb=Math.max(1, Math.ceil(c.n/8)); - for(var i=0;i8 || n>8)){ _pezzi.push(cur); cur=[]; tot=0; } + cur.push(g); tot+=n; + if(n>8){ _pezzi.push(cur); cur=[]; tot=0; } + }); + if(cur.length) _pezzi.push(cur); + }); + function _pn(pz){ return pz.reduce(function(a,g){ return a+g.list.length; },0); } + function _pc(pz){ return {x:pz.reduce(function(a,g){ return a+g.it.x; },0)/pz.length, y:pz.reduce(function(a,g){ return a+g.it.y; },0)/pz.length}; } + for(var _g=0; _g<40 && _pezzi.length>1; _g++){ + var _m=null; + _pezzi.forEach(function(pz,pi){ + var e=cabPlaceAutoBox(pz.map(function(g){ return g.it; }), []); if(!e.lontano) return; e=e.edge; + var c1=_pc(pz), best=null; + _pezzi.forEach(function(q,qi){ if(qi===pi || _pn(pz)+_pn(q)>8) return; + var c2=_pc(q), d=Math.hypot(c1.x-c2.x, c1.y-c2.y); if(d<=CAB_BOX_ACCORPA_DIST && (!best || d_m.e)) _m={pi:pi, qi:best.qi, e:e}; /* si accorpa prima il più lontano dal bordo */ + }); + if(!_m) break; + _pezzi[_m.qi]=_pezzi[_m.qi].concat(_pezzi[_m.pi]); _pezzi.splice(_m.pi,1); + } + var _taken=[]; + _pezzi.forEach(function(pezzo){ + var pos=cabPlaceAutoBox(pezzo.map(function(g){ return g.it; }), _taken); _taken.push(pos); + /* stessa forma delle box reali: senza taken/pins/res/resMap l'assegnazione porte (takePort) + crashava appena si cablava senza stage box sul palco (toast "problema imprevisto"). */ + boxes.push({x:pos.x, y:pos.y, cap:8, used:0, outCap:8, usedOut:0, auto:true, id:"auto"+boxes.length, hw:null, name:"DROP BOX 8ch", + foh:false, sbId:null, res:[], resMap:{}, taken:{}, pins:{}, + plan:pezzo.reduce(function(m,g){ m[g.it.id]=1; return m; },{})}); /* L2: gli elementi per cui la box è stata piazzata */ }); issues.push({lvl:"info", msg:"Nessuna stage box sul palco: proposte "+boxes.length+" drop box da 8ch vicino ai gruppi. Trascina una stage box reale dal catalogo per fissarla."}); } @@ -14690,7 +14775,10 @@ function audioCablingEngine(){ var la=a.used/(a.cap||1), lb=b.used/(b.cap||1); return la!==lb ? la-lb : da-db; }); function bfree(b){ return b.cap-(b.res?b.res.length:0)-b.used; } /* F2: le porte riservate non contano per l'auto */ - var whole=cand.filter(function(b){ return bfree(b)>=g.list.length; })[0]||null; + /* L2: la box piazzata per questo gruppo (drop box automatiche) lo serve per prima, se ha posto: la box sta al bordo del SUO + gruppo, e senza questa preferenza uno strumento vicino al confine finirebbe sulla box del vicino */ + var _own=cand.filter(function(b){ return b.plan && b.plan[g.it.id] && bfree(b)>=Math.min(g.list.length,b.cap); })[0]||null; /* uno strumento da più di 8 canali (batteria) è un cavo unico: sta comunque sulla SUA box */ + var whole=_own || cand.filter(function(b){ return bfree(b)>=g.list.length; })[0]||null; if(g.list.length>=2 && !isPerMusicianMulti(g.it)){ /* CAVO UNICO (Simone 09/07): uno strumento multi-canale (batteria, ampli, coppie…) = UN cavo che porta tutti i canali. Instrada UNA volta con chiave di gruppo "grp:id"; gli N link condividono cavo/box/percorso diff --git a/index.template.html b/index.template.html index 53f4b28..39937c8 100644 --- a/index.template.html +++ b/index.template.html @@ -16866,6 +16866,63 @@

Esporta PDF in scala

return pc ? PER_CHI[it.type]+" – "+pc : (it.label||"").trim(); } function nomeAscolto(it,fallback){ var n=mixLabelOf(it); return n||fallback; } /* per i messaggi sui PM */ +/* L2 (15/11/2026, CAVI_SUL_PALCO R1-R4): dove nasce una drop box AUTOMATICA. Prima stava al baricentro del gruppo, 90 cm verso + il fondo: a metà palco, tra i musicisti. Ora sta sul BORDO del gruppo che serve (45-100 cm dal suo ingombro, lati e fondo), nella + cella libera a costo minimo = distanza media dalle sorgenti + 0,7 × distanza dal bordo del palco. Mai dentro un elemento, mai + negli ultimi 110 cm verso il pubblico (lì stanno voci e spie), ≥ 70 cm da un'altra box. Le box dell'utente non passano di qui. */ +var CAB_BOX_PUBBLICO=110, CAB_BOX_DIST=70; +/* ingombro DISEGNATO della box: oltre al rettangolo 33×17 ci sono la barra di capacità e la sigla sopra (≈ 34 cm) e la barra è larga ≈ 70 cm: + l'ingombro intero deve stare dentro il palco (regia 15/11: la box sul bordo di fondo usciva sopra la scritta «10 m») */ +var CAB_BOX_MX=36, CAB_BOX_SOPRA=34, CAB_BOX_BORDO_MAX=150, CAB_BOX_PESO_BORDO=1.5, CAB_BOX_ACCORPA_DIST=500; +function cabItemHalf(it){ + var t=TYPES[it.type]||{}, w=+it.w||t.w||40, d=+it.d||t.d||40, r=(it.rot||0)*Math.PI/180, c=Math.abs(Math.cos(r)), s=Math.abs(Math.sin(r)); + return {hx:(w*c+d*s)/2, hy:(w*s+d*c)/2}; +} +function cabPlaceAutoBox(its, taken){ + var W=state.stage.w, D=state.stage.d, T=TYPES.stagebox||{}, bw=(T.w||33)/2+4, bd=(T.d||17)/2+4; + var x0=Infinity,x1=-Infinity,y0=Infinity,y1=-Infinity, cx=0, cy=0; + its.forEach(function(it){ var h=cabItemHalf(it); x0=Math.min(x0,it.x-h.hx); x1=Math.max(x1,it.x+h.hx); y0=Math.min(y0,it.y-h.hy); y1=Math.max(y1,it.y+h.hy); cx+=it.x; cy+=it.y; }); + cx/=its.length; cy/=its.length; + var halves=state.items.map(function(it){ return {it:it, h:cabItemHalf(it)}; }); + var blocks=(state.stage.blocks&&state.stage.blocks.length)?state.stage.blocks:null; + function libero(x,y){ + if(xW-CAB_BOX_MX || yD-CAB_BOX_PUBBLICO) return false; + if(blocks && !blocks.some(function(b){ return x>=b.x+CAB_BOX_MX && x<=b.x+b.w-CAB_BOX_MX && y>=b.y+bd+CAB_BOX_SOPRA && y<=b.y+b.d-bd; })) return false; + for(var i=0;iCAB_BOX_BORDO_MAX); + if(lontano){ + var lane=null, cl=[[CAB_BOX_MX,cy],[W-CAB_BOX_MX,cy],[cx,bd+CAB_BOX_SOPRA]]; + for(var ly=y0; ly<=y1; ly+=60){ cl.push([CAB_BOX_MX,ly]); cl.push([W-CAB_BOX_MX,ly]); } + for(var lx=x0; lx<=x1; lx+=60) cl.push([lx,bd+CAB_BOX_SOPRA]); + cl.forEach(function(c){ var x=c[0], y=c[1]; if(!libero(x,y)) return; + var dd=Math.hypot(Math.max(x0-x,0,x-x1), Math.max(y0-y,0,y-y1)); if(dd>400) return; + var cost=its.reduce(function(a,it){ return a+Math.abs(it.x-x)+Math.abs(it.y-y); },0)/its.length + CAB_BOX_PESO_BORDO*Math.min(x,W-x,y); + if(!lane || costEsporta PDF in scala sbId:(it.sbId>0? +it.sbId : null), res:res, resMap:rm, resNome:((it.sbResNome && typeof it.sbResNome==="object") ? it.sbResNome : {}), taken:{}, pins:{}, name:(mxm ? (mxm.brand+" "+mxm.model) : (it.label||TYPES[it.type].defLabel||"BOX"))}; }); if(!manualMode && !boxes.length && totIn){ + /* L2: prima si decide QUANTI pezzi (gruppi per box), poi dove stanno. Un pezzo lontano da ogni bordo (box in mezzo al palco, + nel passaggio fra i musicisti) si accorpa a un pezzo vicino se i canali stanno nella stessa box da 8 */ + var _pezzi=[]; cabClusters(groups, 320).forEach(function(c){ /* soglia 3,2 m: batteria/tastiere/sezioni/voci diventano cluster distinti */ - var nb=Math.max(1, Math.ceil(c.n/8)); - for(var i=0;i8 || n>8)){ _pezzi.push(cur); cur=[]; tot=0; } + cur.push(g); tot+=n; + if(n>8){ _pezzi.push(cur); cur=[]; tot=0; } + }); + if(cur.length) _pezzi.push(cur); + }); + function _pn(pz){ return pz.reduce(function(a,g){ return a+g.list.length; },0); } + function _pc(pz){ return {x:pz.reduce(function(a,g){ return a+g.it.x; },0)/pz.length, y:pz.reduce(function(a,g){ return a+g.it.y; },0)/pz.length}; } + for(var _g=0; _g<40 && _pezzi.length>1; _g++){ + var _m=null; + _pezzi.forEach(function(pz,pi){ + var e=cabPlaceAutoBox(pz.map(function(g){ return g.it; }), []); if(!e.lontano) return; e=e.edge; + var c1=_pc(pz), best=null; + _pezzi.forEach(function(q,qi){ if(qi===pi || _pn(pz)+_pn(q)>8) return; + var c2=_pc(q), d=Math.hypot(c1.x-c2.x, c1.y-c2.y); if(d<=CAB_BOX_ACCORPA_DIST && (!best || d_m.e)) _m={pi:pi, qi:best.qi, e:e}; /* si accorpa prima il più lontano dal bordo */ + }); + if(!_m) break; + _pezzi[_m.qi]=_pezzi[_m.qi].concat(_pezzi[_m.pi]); _pezzi.splice(_m.pi,1); + } + var _taken=[]; + _pezzi.forEach(function(pezzo){ + var pos=cabPlaceAutoBox(pezzo.map(function(g){ return g.it; }), _taken); _taken.push(pos); + /* stessa forma delle box reali: senza taken/pins/res/resMap l'assegnazione porte (takePort) + crashava appena si cablava senza stage box sul palco (toast "problema imprevisto"). */ + boxes.push({x:pos.x, y:pos.y, cap:8, used:0, outCap:8, usedOut:0, auto:true, id:"auto"+boxes.length, hw:null, name:"DROP BOX 8ch", + foh:false, sbId:null, res:[], resMap:{}, taken:{}, pins:{}, + plan:pezzo.reduce(function(m,g){ m[g.it.id]=1; return m; },{})}); /* L2: gli elementi per cui la box è stata piazzata */ }); issues.push({lvl:"info", msg:"Nessuna stage box sul palco: proposte "+boxes.length+" drop box da 8ch vicino ai gruppi. Trascina una stage box reale dal catalogo per fissarla."}); } @@ -17006,7 +17091,10 @@

Esporta PDF in scala

var la=a.used/(a.cap||1), lb=b.used/(b.cap||1); return la!==lb ? la-lb : da-db; }); function bfree(b){ return b.cap-(b.res?b.res.length:0)-b.used; } /* F2: le porte riservate non contano per l'auto */ - var whole=cand.filter(function(b){ return bfree(b)>=g.list.length; })[0]||null; + /* L2: la box piazzata per questo gruppo (drop box automatiche) lo serve per prima, se ha posto: la box sta al bordo del SUO + gruppo, e senza questa preferenza uno strumento vicino al confine finirebbe sulla box del vicino */ + var _own=cand.filter(function(b){ return b.plan && b.plan[g.it.id] && bfree(b)>=Math.min(g.list.length,b.cap); })[0]||null; /* uno strumento da più di 8 canali (batteria) è un cavo unico: sta comunque sulla SUA box */ + var whole=_own || cand.filter(function(b){ return bfree(b)>=g.list.length; })[0]||null; if(g.list.length>=2 && !isPerMusicianMulti(g.it)){ /* CAVO UNICO (Simone 09/07): uno strumento multi-canale (batteria, ampli, coppie…) = UN cavo che porta tutti i canali. Instrada UNA volta con chiave di gruppo "grp:id"; gli N link condividono cavo/box/percorso diff --git a/test/engines.test.mjs b/test/engines.test.mjs index 3a49279..62fbf8c 100644 --- a/test/engines.test.mjs +++ b/test/engines.test.mjs @@ -33097,6 +33097,123 @@ t("rig: un progetto con americane numerate chiede «Opzioni complete» nell'avvi ok(A.funzUsateDalProgetto(A.state).indexOf("opzioni") >= 0, "con rig sì"); }); +/* ───────── L2 · Stagebox automatiche ai bordi del gruppo (15/11/2026, proposta CAVI_SUL_PALCO § 4 L2) ───────── + Prima: ogni drop box nasceva al baricentro del gruppo, 90 cm verso il fondo (a metà palco, tra i musicisti). + Ora: sul bordo del gruppo servito (45-100 cm dal suo ingombro, lati e fondo), mai dentro un elemento, + mai negli ultimi 110 cm verso il pubblico, ≥ 70 cm da un'altra box. Le box messe dall'utente non si toccano. */ +console.log("\nL2 · stagebox automatiche ai bordi del gruppo:"); +const _l2fix = (n) => JSON.parse(readFileSync(join(root, "test/fixtures/cavi-l2", "geo_" + n + ".json"), "utf8")); +const _l2half = (it) => { const r = (it.rot || 0) * Math.PI / 180, c = Math.abs(Math.cos(r)), s = Math.abs(Math.sin(r)), tp = A.TYPES[it.type] || {}; + const w = +it.w || tp.w || 40, d = +it.d || tp.d || 40; return { hx: (w * c + d * s) / 2, hy: (w * s + d * c) / 2 }; }; +function _l2carica(g) { + reset(); A.state.stage = { w: g.W, d: g.D, blocks: [{ x: 0, y: 0, w: g.W, d: g.D }] }; + g.items.forEach((o) => { const it = add(o.type, o.x, o.y); it.w = o.w; it.d = o.d; it.rot = o.rot || 0; if (o.label) it.label = o.label; }); + A.state.cab.on = true; A.state.cab.mode = "auto"; A.__cabRes = null; +} +/* controlla le box AUTOMATICHE di R rispetto agli elementi dello stato corrente; ritorna l'elenco degli errori */ +function _l2controlla(R) { + const W = A.state.stage.w, D = A.state.stage.d, err = [], aut = (R.boxes || []).filter((b) => b.auto); + const items = A.state.items.filter((it) => A.TYPES[it.type]); + aut.forEach((b) => { + const bw = (b.w || 33) / 2, bd = (b.d || 17) / 2; + items.forEach((it) => { const h = _l2half(it); + if (Math.abs(b.x - it.x) < h.hx + bw && Math.abs(b.y - it.y) < h.hy + bd) err.push(b.letter + " dentro «" + (it.label || it.type) + "»"); }); + if (b.y > D - 110) err.push(b.letter + " nella fascia pubblico (y=" + b.y + ")"); + /* ingombro INTERO disegnato: box 33×17 + barra di capacità e sigla sopra (34 cm) + barra larga ≈ 70 cm (regia 15/11: la box sul fondo usciva sopra la scritta «10 m») */ + if (b.x - 35 < 0 || b.x + 35 > W || b.y - bd - 34 < 0 || b.y + bd > D) err.push(b.letter + " con l'ingombro disegnato fuori dal palco (" + b.x + "," + b.y + ")"); + /* distanza dal bordo del gruppo: dal rettangolo che racchiude gli elementi che la box serve */ + const serviti = (R.links || []).filter((l) => l.box === b || (l.box && l.box.id === b.id)).map((l) => l.s.it); + const mine = serviti.length ? Array.from(new Set(serviti)) : []; + if (mine.length) { + const x0 = Math.min(...mine.map((it) => it.x - _l2half(it).hx)), x1 = Math.max(...mine.map((it) => it.x + _l2half(it).hx)); + const y0 = Math.min(...mine.map((it) => it.y - _l2half(it).hy)), y1 = Math.max(...mine.map((it) => it.y + _l2half(it).hy)); + const dx = Math.max(x0 - b.x, 0, b.x - x1), dy = Math.max(y0 - b.y, 0, b.y - y1), dist = Math.hypot(dx, dy); + if (dist > 100.5 && Math.min(b.x, W - b.x, b.y) > 60) err.push(b.letter + " a " + Math.round(dist) + " cm dal bordo del gruppo (>100) e non sul bordo del palco"); + } + aut.forEach((o) => { if (o !== b && o.letter > b.letter && Math.hypot(o.x - b.x, o.y - b.y) < 69.5) err.push(b.letter + "/" + o.letter + " a meno di 70 cm"); }); + }); + return err; +} +["band5", "band11", "orch"].forEach((nome) => { + t("caso «" + nome + "»: box automatiche fuori dagli elementi, fuori dalla fascia pubblico, ≤ 100 cm dal bordo, ≥ 70 cm tra loro", () => { + _l2carica(_l2fix(nome)); const R = A.audioCablingEngine(); + const aut = R.boxes.filter((b) => b.auto); ok(aut.length >= 1, "nessuna box automatica"); + const e = _l2controlla(R); ok(e.length === 0, e.slice(0, 6).join("; ")); + }); +}); +t("nessuna box in mezzo al palco: ogni box automatica è a ≤ 150 cm da un bordo, oppure serve una sola fila di gruppi vicini (casi band5, band11)", () => { + ["band5", "band11"].forEach((nome) => { _l2carica(_l2fix(nome)); const R = A.audioCablingEngine(); const W = A.state.stage.w; + R.boxes.filter((b) => b.auto).forEach((b) => ok(Math.min(b.x, W - b.x, b.y) <= 150, nome + ": box " + b.letter + " a " + Math.min(b.x, W - b.x, b.y) + " cm dal bordo (" + b.x + "," + b.y + ")")); }); +}); +t("accorpamento: due gruppi piccoli in cluster diversi, lontani da ogni bordo, finiscono in UNA box invece di due in mezzo al palco", () => { + _l2palco(1200, 800); add("astamic", 400, 400); add("astamic", 800, 400); + const R = A.audioCablingEngine(); const b = R.boxes.filter((x) => x.auto); eq(b.length, 1, "box"); +}); +t("numero di box = ⌈canali/8⌉ per cluster (nessuna box in più del necessario)", () => { + _l2carica(_l2fix("band5")); const R = A.audioCablingEngine(); const aut = R.boxes.filter((b) => b.auto); + const tot = R.totIn; ok(aut.length >= Math.ceil(tot / 8) && aut.length <= Math.ceil(tot / 8) + 2, aut.length + " box per " + tot + " canali"); + /* una box può superare gli 8 solo se un singolo strumento ne porta più di 8 (batteria a 9 canali = un cavo unico, non si spezza) */ + const grandi = new Set(A.state.items.filter((it) => A.cabItemInputs(it).length > 8).map((it) => it.id)); + ok(aut.every((b) => b.used <= b.cap || R.links.some((l) => l.box === b && grandi.has(l.s.it.id))), "una box oltre la capacità senza uno strumento >8 canali: " + aut.map((b) => b.used + "/" + b.cap).join(" ")); +}); +t("ogni box automatica serve i gruppi per cui è stata piazzata (non quelli del vicino)", () => { + ["band5", "band11"].forEach((nome) => { _l2carica(_l2fix(nome)); const R = A.audioCablingEngine(); + const fuori = R.links.filter((l) => l.box && l.box.auto && l.box.plan && !l.box.plan[l.s.it.id]); + ok(fuori.length === 0, nome + ": " + fuori.length + " canali su una box che non è la loro (es. " + (fuori[0] && (fuori[0].s.it.label || fuori[0].s.it.type)) + ")"); }); +}); +t("deterministico: due calcoli di fila danno le stesse posizioni", () => { + _l2carica(_l2fix("band11")); const a = A.audioCablingEngine().boxes.map((b) => b.x + "," + b.y).join(" "); + A.__cabRes = null; const b2 = A.audioCablingEngine().boxes.map((b) => b.x + "," + b.y).join(" "); eq(a, b2); +}); +t("box messa a mano dall'utente: non si sposta e le automatiche non nascono", () => { + _l2carica(_l2fix("band5")); const sb = add("stagebox", 650, 300); const x0 = sb.x, y0 = sb.y; + A.__cabRes = null; const R = A.audioCablingEngine(); + ok(R.boxes.every((b) => !b.auto), "con una box vera non devono nascere box automatiche"); + eq([sb.x, sb.y], [x0, y0], "la box dell'utente si è mossa"); +}); +function _l2palco(w, d, blocchi) { reset(); A.state.stage = { w, d, blocks: blocchi || [{ x: 0, y: 0, w, d }] }; A.state.cab.on = true; A.state.cab.mode = "auto"; A.__cabRes = null; } +t("gruppo davanti, vicino al pubblico: la box non entra negli ultimi 110 cm (box automatica)", () => { + _l2palco(800, 600); add("astamic", 400, 560); const R = A.audioCablingEngine(); const b = R.boxes.filter((x) => x.auto); + ok(b.length === 1 && b[0].y <= 600 - 110, "box a y=" + (b[0] && b[0].y)); +}); +t("12 microfoni nello stesso punto = 2 box vicine al gruppo, ≥ 70 cm una dall'altra (box automatica)", () => { + _l2palco(1200, 800); for (let i = 0; i < 12; i++) add("astamic", 600 + (i % 4) * 8, 300 + Math.floor(i / 4) * 8); + const R = A.audioCablingEngine(); const b = R.boxes.filter((x) => x.auto); + ok(b.length === 2, b.length + " box invece di 2"); ok(Math.hypot(b[0].x - b[1].x, b[0].y - b[1].y) >= 69.5, "box troppo vicine"); +}); +t("gruppo circondato da una pedana: la box esce con un giro più largo, fuori da ogni elemento (box automatica)", () => { + _l2palco(1200, 800); const ped = add("pedana", 600, 300); ped.w = 300; ped.d = 300; add("astamic", 600, 300); + const R = A.audioCablingEngine(); const b = R.boxes.filter((x) => x.auto)[0]; + ok(b && (Math.abs(b.x - 600) > 150 + 16 || Math.abs(b.y - 300) > 150 + 8), "la box è dentro la pedana: " + (b && b.x + "," + b.y)); +}); +t("senza nessuna cella libera, l'ultima spiaggia resta fuori dalla fascia pubblico (box automatica)", () => { + _l2palco(200, 200); const ped = add("pedana", 100, 100); ped.w = 900; ped.d = 900; add("astamic", 100, 190); + const b = A.audioCablingEngine().boxes.filter((x) => x.auto)[0]; ok(b && b.y <= 200 - 110, "box a y=" + (b && b.y)); +}); +t("a parità di distanza dalle sorgenti vince il lato più vicino al bordo del palco (box automatica)", () => { + _l2palco(1200, 800); const m = add("astamic", 600, 150); const b = A.audioCablingEngine().boxes.filter((x) => x.auto)[0]; + ok(b && b.y < m.y, "la box doveva stare sul fondo (verso il bordo), è a " + (b && b.x + "," + b.y)); +}); +t("palco a L: la box resta dentro i blocchi, non nel vuoto accanto (box automatica)", () => { + const bl = [{ x: 0, y: 0, w: 1200, d: 400 }, { x: 0, y: 400, w: 800, d: 400 }]; + _l2palco(1200, 800, bl); add("astamic", 760, 600); + const b = A.audioCablingEngine().boxes.filter((x) => x.auto)[0]; + ok(b && A.state.stage.blocks.some((k) => b.x >= k.x && b.x <= k.x + k.w && b.y >= k.y && b.y <= k.y + k.d) && !(b.y > 400 && b.x > 800), "box nel vuoto: " + (b && b.x + "," + b.y)); +}); +t("collaudo: ogni progetto vero con box automatiche rispetta le stesse regole", () => { + let base = null; for (let d = root, i = 0; i < 8 && !base; i++, d = dirname(d)) if (existsSync(join(d, "collaudo", "progetti"))) base = join(d, "collaudo", "progetti"); + if (!base) { console.log(" (cartella collaudo non trovata: saltato)"); return; } + let visti = 0; const errori = []; + readdirSync(base).filter((f) => /^\d+\.json$/.test(f)).sort().forEach((f) => { + A.loadDoc(JSON.parse(readFileSync(join(base, f), "utf8"))); + A.VARIANTS.slice().forEach((v) => { A.switchVariant(v.id); if (!A.state.cab || A.state.cab.mode !== "auto") return; + A.__cabRes = null; const R = A.audioCablingEngine(); if (!R.boxes.some((b) => b.auto)) return; visti++; + _l2controlla(R).forEach((e) => errori.push(f + " «" + (v.name || v.id) + "»: " + e)); }); + }); + console.log(" (" + visti + " scene con box automatiche controllate)"); + ok(errori.length === 0, errori.slice(0, 6).join("; ")); +}); + /* Segnalazione anonima 15/11/2026 «manca una immagine del coro»: il coro intero era solo nel modello «Nuovo». */ t("ricerca «coro»: la voce «Coro» è la prima (coro intero), prima di mic, pedana e singolo corista", () => { reset(); diff --git a/test/fixtures/cavi-l2/geo_band11.json b/test/fixtures/cavi-l2/geo_band11.json new file mode 100644 index 0000000..eb1b394 --- /dev/null +++ b/test/fixtures/cavi-l2/geo_band11.json @@ -0,0 +1 @@ +{"W":1000,"D":700,"items":[{"type":"batteria","label":"Batteria 1","x":500,"y":130,"w":147,"d":142,"rot":0,"ins":9,"watt":0},{"type":"musBasso","label":"Basso musicista 1","x":250,"y":220,"w":97,"d":79,"rot":0,"ins":1,"watt":0},{"type":"dimono","label":"DI 1","x":321,"y":266,"w":13,"d":10,"rot":0,"ins":0,"watt":0},{"type":"bassamp","label":"Ampli basso 1","x":180,"y":150,"w":68,"d":43,"rot":0,"ins":2,"watt":400},{"type":"musChitElettrica","label":"Chitarra elettrica musicista 1","x":750,"y":220,"w":88,"d":87,"rot":0,"ins":1,"watt":0},{"type":"comboamp","label":"Ampli chitarra 1","x":830,"y":150,"w":66,"d":28,"rot":0,"ins":1,"watt":150},{"type":"musChitAcustica","label":"Chitarra acustica musicista 1","x":680,"y":340,"w":86,"d":88,"rot":0,"ins":1,"watt":0},{"type":"dimono","label":"DI 2","x":745,"y":390,"w":13,"d":10,"rot":0,"ins":0,"watt":0},{"type":"tastiera","label":"Tastiera 1","x":330,"y":300,"w":120,"d":36,"rot":0,"ins":2,"watt":50},{"type":"dimono","label":"DI 3","x":412,"y":324,"w":19,"d":13,"rot":0,"ins":0,"watt":0},{"type":"stagepiano","label":"Stage piano 1","x":170,"y":330,"w":132,"d":117,"rot":0,"ins":2,"watt":50},{"type":"dimono","label":"DI 4","x":258,"y":395,"w":19,"d":13,"rot":0,"ins":0,"watt":0},{"type":"cantante","label":"Cantante 1","x":500,"y":470,"w":70,"d":120,"rot":0,"ins":1,"watt":0},{"type":"cantante","label":"Cantante 2","x":350,"y":490,"w":70,"d":120,"rot":0,"ins":1,"watt":0},{"type":"cantante","label":"Cantante 3","x":650,"y":490,"w":70,"d":120,"rot":0,"ins":1,"watt":0},{"type":"wedge","label":"Wedge 1","x":500,"y":560,"w":60,"d":52,"rot":180,"ins":0,"watt":400},{"type":"wedge","label":"Wedge 2","x":350,"y":570,"w":60,"d":52,"rot":180,"ins":0,"watt":400},{"type":"wedge","label":"Wedge 3","x":650,"y":570,"w":60,"d":52,"rot":180,"ins":0,"watt":400},{"type":"wedge","label":"Wedge 4","x":850,"y":420,"w":60,"d":52,"rot":180,"ins":0,"watt":400}]} \ No newline at end of file diff --git a/test/fixtures/cavi-l2/geo_band5.json b/test/fixtures/cavi-l2/geo_band5.json new file mode 100644 index 0000000..d2e2fcc --- /dev/null +++ b/test/fixtures/cavi-l2/geo_band5.json @@ -0,0 +1 @@ +{"W":800,"D":600,"items":[{"type":"batteria","label":"Batteria 1","x":400,"y":130,"w":147,"d":142,"rot":0,"ins":9,"watt":0},{"type":"musBasso","label":"Basso musicista 1","x":170,"y":230,"w":97,"d":79,"rot":0,"ins":1,"watt":0},{"type":"dimono","label":"DI 1","x":241,"y":276,"w":13,"d":10,"rot":0,"ins":0,"watt":0},{"type":"musChitElettrica","label":"Chitarra elettrica musicista 1","x":630,"y":230,"w":88,"d":87,"rot":0,"ins":1,"watt":0},{"type":"tastiera","label":"Tastiera 1","x":250,"y":330,"w":120,"d":36,"rot":0,"ins":2,"watt":50},{"type":"dimono","label":"DI 2","x":332,"y":354,"w":19,"d":13,"rot":0,"ins":0,"watt":0},{"type":"cantante","label":"Cantante 1","x":400,"y":430,"w":70,"d":120,"rot":0,"ins":1,"watt":0},{"type":"bassamp","label":"Ampli basso 1","x":120,"y":150,"w":68,"d":43,"rot":0,"ins":2,"watt":400},{"type":"comboamp","label":"Ampli chitarra 1","x":690,"y":150,"w":66,"d":28,"rot":0,"ins":1,"watt":150},{"type":"wedge","label":"Wedge 1","x":400,"y":500,"w":60,"d":52,"rot":180,"ins":0,"watt":400}]} \ No newline at end of file diff --git a/test/fixtures/cavi-l2/geo_orch.json b/test/fixtures/cavi-l2/geo_orch.json new file mode 100644 index 0000000..415a698 --- /dev/null +++ b/test/fixtures/cavi-l2/geo_orch.json @@ -0,0 +1 @@ +{"W":2400,"D":2743,"items":[{"type":"vlnpost","label":"Violino I 1","x":845,"y":2130,"w":100,"d":105,"rot":-150,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 2","x":744,"y":2021,"w":100,"d":105,"rot":-120,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 3","x":710,"y":1878,"w":100,"d":105,"rot":-90,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 4","x":751,"y":1736,"w":100,"d":105,"rot":-60,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 1","x":857,"y":1633,"w":100,"d":105,"rot":-30,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 2","x":1000,"y":1595,"w":100,"d":105,"rot":0,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 3","x":1143,"y":1633,"w":100,"d":105,"rot":30,"ins":1,"watt":0},{"type":"violapost","label":"Viola 1","x":1249,"y":1736,"w":100,"d":115,"rot":60,"ins":1,"watt":0},{"type":"violapost","label":"Viola 2","x":1290,"y":1878,"w":100,"d":115,"rot":90,"ins":1,"watt":0},{"type":"violoncello","label":"Violoncello 1","x":1256,"y":2021,"w":110,"d":160,"rot":120,"ins":1,"watt":0},{"type":"violoncello","label":"Violoncello 2","x":1155,"y":2130,"w":110,"d":160,"rot":150,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 5","x":655,"y":2205,"w":100,"d":105,"rot":-135,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 6","x":543,"y":1993,"w":100,"d":105,"rot":-105,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 7","x":549,"y":1754,"w":100,"d":105,"rot":-75,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 4","x":672,"y":1548,"w":100,"d":105,"rot":-45,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 5","x":880,"y":1431,"w":100,"d":105,"rot":-15,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 6","x":1120,"y":1431,"w":100,"d":105,"rot":15,"ins":1,"watt":0},{"type":"violapost","label":"Viola 3","x":1328,"y":1548,"w":100,"d":115,"rot":45,"ins":1,"watt":0},{"type":"violapost","label":"Viola 4","x":1451,"y":1754,"w":100,"d":115,"rot":75,"ins":1,"watt":0},{"type":"violoncello","label":"Violoncello 3","x":1457,"y":1993,"w":110,"d":160,"rot":105,"ins":1,"watt":0},{"type":"violoncello","label":"Violoncello 4","x":1345,"y":2205,"w":110,"d":160,"rot":135,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 8","x":367,"y":2035,"w":100,"d":105,"rot":-105,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 9","x":376,"y":1704,"w":100,"d":105,"rot":-75,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino I 10","x":546,"y":1420,"w":100,"d":105,"rot":-45,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 7","x":834,"y":1256,"w":100,"d":105,"rot":-15,"ins":1,"watt":0},{"type":"vlnpost","label":"Violino II 8","x":1166,"y":1256,"w":100,"d":105,"rot":15,"ins":1,"watt":0},{"type":"violapost","label":"Viola 5","x":1454,"y":1420,"w":100,"d":115,"rot":45,"ins":1,"watt":0},{"type":"violapost","label":"Viola 6","x":1624,"y":1704,"w":100,"d":115,"rot":75,"ins":1,"watt":0},{"type":"violoncello","label":"Violoncello 5","x":1633,"y":2035,"w":110,"d":160,"rot":105,"ins":1,"watt":0},{"type":"contrabbasso","label":"Contrabbasso 1","x":1820,"y":1758,"w":150,"d":195,"rot":80,"ins":1,"watt":0},{"type":"contrabbasso","label":"Contrabbasso 2","x":1776,"y":2178,"w":150,"d":195,"rot":110,"ins":1,"watt":0},{"type":"contrabbasso","label":"Contrabbasso 3","x":1531,"y":2523,"w":150,"d":195,"rot":140,"ins":1,"watt":0},{"type":"flauto","label":"Flauto 1","x":758,"y":835,"w":95,"d":105,"rot":-15,"ins":1,"watt":0},{"type":"flauto","label":"Flauto 2","x":888,"y":835,"w":95,"d":105,"rot":-5,"ins":1,"watt":0},{"type":"oboe","label":"Oboe 1","x":1113,"y":835,"w":95,"d":105,"rot":5,"ins":1,"watt":0},{"type":"oboe","label":"Oboe 2","x":1243,"y":835,"w":95,"d":105,"rot":15,"ins":1,"watt":0},{"type":"clarinetto","label":"Clarinetto 1","x":758,"y":660,"w":95,"d":105,"rot":-10,"ins":1,"watt":0},{"type":"clarinetto","label":"Clarinetto 2","x":888,"y":660,"w":95,"d":105,"rot":-5,"ins":1,"watt":0},{"type":"fagotto","label":"Fagotto 1","x":1113,"y":660,"w":95,"d":110,"rot":5,"ins":1,"watt":0},{"type":"fagotto","label":"Fagotto 2","x":1243,"y":660,"w":95,"d":110,"rot":10,"ins":1,"watt":0},{"type":"corno","label":"Corno 1","x":320,"y":485,"w":95,"d":105,"rot":-25,"ins":1,"watt":0},{"type":"corno","label":"Corno 2","x":450,"y":485,"w":95,"d":105,"rot":-20,"ins":1,"watt":0},{"type":"corno","label":"Corno 3","x":580,"y":485,"w":95,"d":105,"rot":-15,"ins":1,"watt":0},{"type":"corno","label":"Corno 4","x":710,"y":485,"w":95,"d":105,"rot":-10,"ins":1,"watt":0},{"type":"tromba","label":"Tromba 1","x":935,"y":485,"w":95,"d":105,"rot":-5,"ins":1,"watt":0},{"type":"tromba","label":"Tromba 2","x":1065,"y":485,"w":95,"d":105,"rot":5,"ins":1,"watt":0},{"type":"tromba","label":"Tromba 3","x":1195,"y":485,"w":95,"d":105,"rot":10,"ins":1,"watt":0},{"type":"trombone","label":"Trombone 1","x":1420,"y":485,"w":95,"d":112,"rot":15,"ins":1,"watt":0},{"type":"trombone","label":"Trombone 2","x":1550,"y":485,"w":95,"d":112,"rot":20,"ins":1,"watt":0},{"type":"trombone","label":"Trombone 3","x":1680,"y":485,"w":95,"d":112,"rot":25,"ins":1,"watt":0},{"type":"pedana","label":"","x":1000,"y":219,"w":500,"d":222,"rot":0,"ins":0,"watt":0},{"type":"timpani","label":"Timpani","x":1000,"y":219,"w":265,"d":146,"rot":0,"ins":2,"watt":0},{"type":"arpa","label":"Arpa","x":270,"y":1428,"w":54,"d":134,"rot":-60,"ins":1,"watt":0},{"type":"podio","label":"","x":1000,"y":1885,"w":100,"d":100,"rot":0,"ins":0,"watt":0},{"type":"corista","label":"Corista 1","x":900,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 2","x":970,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 3","x":1040,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 4","x":1110,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 5","x":1180,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 6","x":1250,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 7","x":1320,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 8","x":1390,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 9","x":1460,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 10","x":1530,"y":89,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 11","x":900,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 12","x":970,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 13","x":1040,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 14","x":1110,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 15","x":1180,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 16","x":1250,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 17","x":1320,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 18","x":1390,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 19","x":1460,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"corista","label":"Corista 20","x":1530,"y":149,"w":70,"d":88,"rot":0,"ins":1,"watt":0},{"type":"batteria","label":"Batteria 1","x":2070,"y":419,"w":147,"d":142,"rot":0,"ins":9,"watt":0},{"type":"musBasso","label":"Basso musicista 1","x":1940,"y":549,"w":97,"d":79,"rot":0,"ins":1,"watt":0},{"type":"dimono","label":"DI 1","x":2011,"y":595,"w":13,"d":10,"rot":0,"ins":0,"watt":0},{"type":"bassamp","label":"Ampli basso 1","x":1880,"y":469,"w":68,"d":43,"rot":0,"ins":2,"watt":400},{"type":"musChitElettrica","label":"Chitarra elettrica musicista 1","x":2200,"y":549,"w":88,"d":87,"rot":0,"ins":1,"watt":0},{"type":"comboamp","label":"Ampli chitarra 1","x":2150,"y":469,"w":66,"d":28,"rot":0,"ins":1,"watt":150},{"type":"tastiera","label":"Tastiera 1","x":2070,"y":669,"w":120,"d":36,"rot":0,"ins":2,"watt":50},{"type":"dimono","label":"DI 2","x":2152,"y":693,"w":19,"d":13,"rot":0,"ins":0,"watt":0},{"type":"cantante","label":"Cantante 1","x":2070,"y":819,"w":70,"d":120,"rot":0,"ins":1,"watt":0}]} \ No newline at end of file