feat(pcb): 회로도 오메가(∩) 다리 — 연결 안 된 가로·세로 선이 교차하면 가로선이 세로선을 넘는 반원으로 표시(표시만, 교차점에 끝점·이름표·핀이 있으면 연결로 보고 제외)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c53357c1ea
commit
8ff0c7323e
1 file changed
+26
-1
@@ -924,6 +924,24 @@ function drawPower(pw,isSel){
|
||||
const len=(gnd?3.6:2.0)*S, ex=SX(pw.x)+vec[0]*len, ey=SY(pw.y)+vec[1]*len, fs=Math.max(9,1.15*S);
|
||||
if(vec[0]===0) stext(pw.name,ex,vec[1]>0?ey+fs:ey-4,'center',col,fs); else stext(pw.name,ex+(vec[0]>0?4:-4),ey+4,vec[0]>0?'left':'right',col,fs);
|
||||
}
|
||||
|
||||
// 연결 안 된 가로·세로 선이 선분 한가운데서 교차하면 가로선에 오메가(∩) 다리를 놓는다(표시만 — 연결 해석은 그대로: 교차점에 끝점·이름표·접합점이 있으면 연결이므로 제외).
|
||||
let _hopKey='', _hopVal=new Map();
|
||||
function schHops(){
|
||||
const key=JSON.stringify(P.sch.wires)+'|'+P.sch.labels.length+P.sch.power.length; if(key===_hopKey) return _hopVal;
|
||||
const H=[], V=[], E=0.02, M=0.35, R=1.0, out=new Map();
|
||||
P.sch.wires.forEach((w,wi)=>{for(let k=1;k<w.pts.length;k++){const a=w.pts[k-1],b=w.pts[k];
|
||||
if(Math.abs(a[1]-b[1])<E&&Math.abs(a[0]-b[0])>E) H.push({wi,k,y:a[1],x0:Math.min(a[0],b[0]),x1:Math.max(a[0],b[0])});
|
||||
else if(Math.abs(a[0]-b[0])<E&&Math.abs(a[1]-b[1])>E) V.push({wi,k,x:a[0],y0:Math.min(a[1],b[1]),y1:Math.max(a[1],b[1])});}});
|
||||
const pts=[]; P.sch.wires.forEach(w=>w.pts.forEach(q=>pts.push(q))); for(const l of [...P.sch.labels,...P.sch.power]) pts.push([l.x,l.y]); for(const p of P.parts) for(const q of partPins(p)) pts.push([q.x,q.y]);
|
||||
for(const h of H){ const xs=[];
|
||||
for(const v of V){ if(v.wi===h.wi&&Math.abs(v.k-h.k)<=1) continue;
|
||||
if(v.x<=h.x0+M||v.x>=h.x1-M||h.y<=v.y0+M||h.y>=v.y1-M) continue; // 끝 가까이/끝점에서 만나는 건 연결(T·꺾임)
|
||||
if(pts.some(q=>Math.abs(q[0]-v.x)<0.06&&Math.abs(q[1]-h.y)<0.06)) continue; xs.push(v.x); }
|
||||
xs.sort((a,b)=>a-b); const keep=[]; for(const x of xs){ if(x-R<h.x0+0.1||x+R>h.x1-0.1) continue; if(keep.length&&x-keep[keep.length-1]<2*R+0.3) continue; keep.push(x); }
|
||||
if(keep.length) out.set(h.wi+':'+h.k,keep); }
|
||||
_hopKey=key; _hopVal=out; return out;
|
||||
}
|
||||
function drawSch(){
|
||||
if(!P||tab!=='sch') return;
|
||||
const r=sc2.getBoundingClientRect(); sctx.clearRect(0,0,r.width,r.height); ensureSch(); const S=sview.s;
|
||||
@@ -931,7 +949,14 @@ function drawSch(){
|
||||
if(S>=5){sctx.fillStyle='rgba(255,255,255,.12)';const x0=Math.floor(-sview.ox/S/SGRID/2)*SGRID*2,y0=Math.floor(-sview.oy/S/SGRID/2)*SGRID*2;for(let x=x0;x<(r.width-sview.ox)/S;x+=SGRID*2)for(let y=y0;y<(r.height-sview.oy)/S;y+=SGRID*2)sctx.fillRect(SX(x)-.5,SY(y)-.5,1.2,1.2);}
|
||||
// 배선
|
||||
sctx.lineCap='round';sctx.lineJoin='round';
|
||||
P.sch.wires.forEach((w,i)=>{const isSel=ssel&&ssel.kind==='wire'&&ssel.i===i;sctx.strokeStyle=isSel?'#fff176':'#6fcf6f';sctx.lineWidth=Math.max(1.4,0.3*S);sctx.beginPath();w.pts.forEach((q,k)=>k?sctx.lineTo(SX(q[0]),SY(q[1])):sctx.moveTo(SX(q[0]),SY(q[1])));sctx.stroke();});
|
||||
const hops=schHops(), HR=1.0;
|
||||
P.sch.wires.forEach((w,i)=>{const isSel=ssel&&ssel.kind==='wire'&&ssel.i===i;sctx.strokeStyle=isSel?'#fff176':'#6fcf6f';sctx.lineWidth=Math.max(1.4,0.3*S);sctx.beginPath();
|
||||
w.pts.forEach((q,k)=>{ if(!k){sctx.moveTo(SX(q[0]),SY(q[1]));return;}
|
||||
const a=w.pts[k-1], hs=hops.get(i+':'+k);
|
||||
if(hs&&hs.length){ const dir=q[0]>=a[0]?1:-1, xs=hs.slice().sort((m,n)=>dir*(m-n)); // 연결 안 된 교차: 가로선이 세로선을 오메가(∩)로 넘어간다
|
||||
for(const hx of xs){ sctx.lineTo(SX(hx-dir*HR),SY(a[1])); sctx.arc(SX(hx),SY(a[1]),HR*S,dir>0?Math.PI:0,dir>0?0:Math.PI,dir<0); } }
|
||||
sctx.lineTo(SX(q[0]),SY(q[1])); });
|
||||
sctx.stroke();});
|
||||
sctx.fillStyle='#6fcf6f';for(const j of sres.junctions){sctx.beginPath();sctx.arc(SX(j[0]),SY(j[1]),Math.max(2.5,0.5*S),0,7);sctx.fill();}
|
||||
for(const part of P.parts){const pos=sPos(part.ref);if(pos)drawSym(part,pos,ssel&&ssel.kind==='part'&&ssel.ref===part.ref);}
|
||||
P.sch.power.forEach((pw,i)=>drawPower(pw,ssel&&ssel.kind==='power'&&ssel.i===i));
|
||||
|
||||
Reference in new issue
Block a user