/* ============================================================================= * B05_Profile_UI_Structures_Panel_Pipes.ts * 「구조물 배치」 폼이 관 목록을 받는 몫 — 임시 관 · 고른 관이 조금 옮겨져도 따라감 * (`B05_Profile_UI_Structures_Panel.ts` setPipeFacilities 에서 나눔 · 472-5 · 동작 같음). * ========================================================================== */ import { PIPE_MATCH_M } from "../A00_Common/design/design_selection"; import type { StructuresEventContext } from "./B05_Profile_UI_Structures_Panel_Events"; import type { PipeFacilityItem } from "./B05_Profile_UI_Structures_Panel_Types"; /** 새 관 목록(`list` = 이미 갈아 낀 폼 목록) — 임시 · 고른 관 누가거리 따라감 · 사라지면 폼 닫음. */ export function followPipeList(ctx: StructuresEventContext, list: PipeFacilityItem[]): void { const temp = ctx.tempPipeChainage(); if (temp !== null) { // 스냅·재계산으로 좌표가 조금 옮겨진 임시 관을 계속 따라간다. const hit = list.find((pipe) => Math.abs(pipe.chainage_m - temp) < PIPE_MATCH_M); if (hit) { ctx.setTempPipeChainage(hit.chainage_m); if (ctx.selectedPipeChainage() !== null) ctx.setSelectedPipeChainage(hit.chainage_m); // 재계산이 끝나 도착한 담당 유역 설계유량을 입력 중인 폼에 반영한다 — // 물넘이·세월교 월류 높이가 이 값으로 계산된다(2026-08-18 진단: 재계산 // 후 선택 통지가 조용히 끝나 폼이 유량을 못 받던 문제). ctx.facilityOptions.setDesignFlow(hit.design_flow_m3s ?? null); } else { // 임시 배치 관이 재계산에서 사라졌다 — 임시 상태만 정리(관은 이미 없다). ctx.setTempPipeChainage(null); ctx.syncButtons(); } } const kept = list.find( (pipe) => Math.abs(pipe.chainage_m - (ctx.selectedPipeChainage() ?? NaN)) < PIPE_MATCH_M, ); if (kept) ctx.setSelectedPipeChainage(kept.chainage_m); // 조금 옮겨진 관도 고름 따라감(233-3) else if (ctx.selectedPipeChainage() !== null) { // 고르고 있던 관이 사라졌다(삭제·재계산 이동) — 폼도 함께 닫는다. ctx.setSelectedPipeChainage(null); ctx.facilityOptions.setFacility(null); ctx.syncButtons(); } ctx.renderList(); }