조정창에서 좌·우 끝을 따로 잡는다 — ◀▶는 구체 길이, ▲▼는 그 끝의 구체 표고를 0.1m씩 움직인다. 좌·우 표고가 달라지면 구체가 기울고, 날개벽 구간 바닥(에이프런)은 각 끝 표고에서 수평을 지킨다(2026-08-25 사용자). - `computeBoxLayout`이 좌·우를 따로 푼다: 끝 표고·길이·성토선·에이프런 - 성토선은 그쪽 표고 기준으로 물매 1:1.2를 지키므로 표고를 내리면 구체가 길어진다 - 조정창 `_Cross_Box_Panel.ts` + 제어 `createBoxControls` + `design.box_adjust` 저장 (세션 → 캐시 → 확정 payload, 세월교와 같은 체계) - 3D: 구체 밖(날개벽 구간)에 서 있던 벽을 없앴다 — 천장 없는 통로가 생기던 자리는 날개벽 몫이다. 이제 상판·구체 저판·측벽 2매·에이프런 2매 + 날개벽 4매로 나뉜다 - 카드 렌더러의 구체 배선(선택 토글·강조·조정창)을 `_Cross_View_Bodies.ts`로 분리, 연동 플래그 세션은 `_Page_Link_Session.ts`로 분리(700줄 제한) 검증(10+0.9): 구체 5.34m·수평 → ◀ 1회 5.44m → ▼ 2회 표고 −0.2m·물매 1:28.4, 에이프런 두 장 모두 수평 유지, ↺ 원복. 3D 솔리드 10개(측벽 링 0.2m). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
247 lines
9.3 KiB
TypeScript
247 lines
9.3 KiB
TypeScript
/* =============================================================================
|
|
* B06_Section_UI_Page_Ford_Controls.ts
|
|
* 세월교 측벽·BOX암거 구체 조작값 제어 — 측점 제어기
|
|
* (`_UI_Page_Station_Controls.ts`)에서 700줄 제한으로 분리했다(2026-08-25).
|
|
*
|
|
* 데이터 흐름은 집수정과 같다: 세션 사본 + 캐시 `design.ford_adjust`에 함께 실어
|
|
* 3D(코리도)가 같은 값으로 다시 그리게 한다. 관경·수량은 B05 정본(`pipe_points`)이
|
|
* 원천이라 배수관 구간값과 같은 저장기로 되돌려 쓴다.
|
|
* ========================================================================== */
|
|
|
|
import type { CrossDesign, CrossSection } from "./B06_Section_Api_Fetch";
|
|
import { DEFAULT_FORD_WALL_ADJUST } from "./B06_Section_UI_Cross_Ford";
|
|
import type { FordAdjust, FordWallAdjust, FordWallRole } from "./B06_Section_UI_Cross_Ford";
|
|
import type { FordControl } from "./B06_Section_UI_Cross_Ford_Panel";
|
|
import { DEFAULT_BOX_SIDE_ADJUST } from "./B06_Section_UI_Cross_Box";
|
|
import type { BoxAdjust, BoxSideAdjust, BoxSideRole } from "./B06_Section_UI_Cross_Box";
|
|
import type { BoxControl } from "./B06_Section_UI_Cross_Box_Panel";
|
|
|
|
export interface FordControlDeps {
|
|
/** 세션 보관 키(프로젝트·노선별). 없으면 세션에 담지 않는다. */
|
|
sessionKey: () => string | null;
|
|
sectionAt: (chainageM: number) => CrossSection | undefined;
|
|
patchCachedDesign: (chainageM: number, patch: Partial<CrossDesign>) => void;
|
|
refreshCard: (chainageM: number) => void;
|
|
/** 관경·수량을 B05 정본으로 되돌려 쓴다(묶어서 늦게 저장). */
|
|
queuePipeOptions: (chainageM: number, patch: Record<string, number>) => void;
|
|
round1: (value: number) => number;
|
|
clampMove: (value: number) => number;
|
|
}
|
|
|
|
export interface FordControls {
|
|
control: FordControl;
|
|
/** 확정 payload용 — 측점별 조작값. */
|
|
byChainage: () => Map<number, FordAdjust>;
|
|
/** 노선이 바뀔 때 세션 값을 다시 읽는다. */
|
|
load: () => void;
|
|
}
|
|
|
|
export function createFordControls(deps: FordControlDeps): FordControls {
|
|
const { round1, clampMove, sectionAt, patchCachedDesign } = deps;
|
|
/* ── 세월교 측벽 조작(2026-08-25 사용자) ───────────────────────────────
|
|
* 축은 집수정과 같다(높이·좌우·상하 대각). 값은 세션 사본 + 캐시 design에 함께
|
|
* 실어 3D가 같은 값으로 다시 그리게 한다. 관경·수량은 B05 정본이 원천이라
|
|
* 배수관 구간값과 같은 저장기(`pipe_points` 되쓰기)로 보낸다. */
|
|
const fordAdjustments = new Map<string, FordAdjust>();
|
|
const fordSelections = new Map<string, FordWallRole | null>();
|
|
const fordSessionKey = (): string | null => deps.sessionKey();
|
|
|
|
function loadFordAdjustments(): void {
|
|
fordAdjustments.clear();
|
|
const key = fordSessionKey();
|
|
if (!key) return;
|
|
try {
|
|
const parsed = JSON.parse(window.sessionStorage.getItem(key) ?? "{}") as Record<
|
|
string,
|
|
FordAdjust
|
|
>;
|
|
Object.entries(parsed).forEach(([chainage, value]) =>
|
|
fordAdjustments.set(chainage, {
|
|
inlet: { ...DEFAULT_FORD_WALL_ADJUST, ...value.inlet },
|
|
outlet: { ...DEFAULT_FORD_WALL_ADJUST, ...value.outlet },
|
|
}),
|
|
);
|
|
} catch {
|
|
/* 손상된 세션 값은 기본값으로 대체. */
|
|
}
|
|
}
|
|
|
|
function persistFordAdjustments(): void {
|
|
const key = fordSessionKey();
|
|
if (key)
|
|
window.sessionStorage.setItem(key, JSON.stringify(Object.fromEntries(fordAdjustments)));
|
|
}
|
|
|
|
const fordAdjustAt = (chainageM: number): FordAdjust => {
|
|
const stored = sectionAt(chainageM)?.design?.ford_adjust;
|
|
return (
|
|
fordAdjustments.get(chainageM.toFixed(2)) ?? {
|
|
inlet: { ...DEFAULT_FORD_WALL_ADJUST, ...(stored?.inlet ?? {}) },
|
|
outlet: { ...DEFAULT_FORD_WALL_ADJUST, ...(stored?.outlet ?? {}) },
|
|
}
|
|
);
|
|
};
|
|
|
|
const writeFord = (chainageM: number, next: FordAdjust): void => {
|
|
fordAdjustments.set(chainageM.toFixed(2), next);
|
|
persistFordAdjustments();
|
|
patchCachedDesign(chainageM, { ford_adjust: next });
|
|
deps.refreshCard(chainageM);
|
|
};
|
|
|
|
const fordControl: FordControl = {
|
|
adjustFor: fordAdjustAt,
|
|
update: (chainageM, role, patch) => {
|
|
const current = fordAdjustAt(chainageM);
|
|
const wall: FordWallAdjust = { ...current[role], ...patch };
|
|
writeFord(chainageM, {
|
|
...current,
|
|
[role]: {
|
|
// 높이는 0.1m 눈금, 하한(관경+토피)은 기하가 다시 잡는다.
|
|
heightM: wall.heightM === null ? null : Math.max(round1(wall.heightM), 0),
|
|
lateralM: Math.max(0, clampMove(wall.lateralM)),
|
|
slopeM: clampMove(wall.slopeM),
|
|
},
|
|
});
|
|
},
|
|
reset: (chainageM, role) => {
|
|
const current = fordAdjustAt(chainageM);
|
|
writeFord(chainageM, { ...current, [role]: { ...DEFAULT_FORD_WALL_ADJUST } });
|
|
},
|
|
setPipe: (chainageM, patch) => {
|
|
const spec = sectionAt(chainageM)?.ford;
|
|
if (spec) {
|
|
// 캐시를 먼저 고쳐 즉시 반영한다 — 저장은 늦게 묶어서 간다.
|
|
if (patch.pipe_diameter_mm) spec.diameter_m = patch.pipe_diameter_mm / 1000;
|
|
if (patch.pipe_count) spec.pipe_count = patch.pipe_count;
|
|
}
|
|
deps.queuePipeOptions(chainageM, patch);
|
|
deps.refreshCard(chainageM);
|
|
},
|
|
selectedFor: (chainageM) => fordSelections.get(chainageM.toFixed(2)) ?? null,
|
|
select: (chainageM, role) => {
|
|
fordSelections.set(chainageM.toFixed(2), role);
|
|
},
|
|
};
|
|
|
|
return {
|
|
control: fordControl,
|
|
byChainage: () => {
|
|
const result = new Map<number, FordAdjust>();
|
|
fordAdjustments.forEach((adjust, key) => {
|
|
const value = Number(key);
|
|
if (Number.isFinite(value)) result.set(value, adjust);
|
|
});
|
|
return result;
|
|
},
|
|
load: loadFordAdjustments,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* BOX암거 구체 조작값 제어 — 세월교와 같은 흐름(세션 사본 + 캐시 `design.box_adjust`).
|
|
* 좌·우 끝을 따로 잡으며 길이는 바깥으로만, 표고는 양방향으로 움직인다.
|
|
*/
|
|
export function createBoxControls(deps: FordControlDeps): {
|
|
control: BoxControl;
|
|
byChainage: () => Map<number, BoxAdjust>;
|
|
load: () => void;
|
|
} {
|
|
const { round1, clampMove, sectionAt, patchCachedDesign } = deps;
|
|
const adjustments = new Map<string, BoxAdjust>();
|
|
const selections = new Map<string, BoxSideRole | null>();
|
|
|
|
function load(): void {
|
|
adjustments.clear();
|
|
const key = deps.sessionKey();
|
|
if (!key) return;
|
|
try {
|
|
const parsed = JSON.parse(window.sessionStorage.getItem(key) ?? "{}") as Record<
|
|
string,
|
|
BoxAdjust
|
|
>;
|
|
Object.entries(parsed).forEach(([chainage, value]) =>
|
|
adjustments.set(chainage, {
|
|
left: { ...DEFAULT_BOX_SIDE_ADJUST, ...value.left },
|
|
right: { ...DEFAULT_BOX_SIDE_ADJUST, ...value.right },
|
|
}),
|
|
);
|
|
} catch {
|
|
/* 손상된 세션 값은 기본값으로 대체. */
|
|
}
|
|
}
|
|
|
|
function persist(): void {
|
|
const key = deps.sessionKey();
|
|
if (key) window.sessionStorage.setItem(key, JSON.stringify(Object.fromEntries(adjustments)));
|
|
}
|
|
|
|
const adjustAt = (chainageM: number): BoxAdjust => {
|
|
const stored = sectionAt(chainageM)?.design?.box_adjust;
|
|
return (
|
|
adjustments.get(chainageM.toFixed(2)) ?? {
|
|
left: { ...DEFAULT_BOX_SIDE_ADJUST, ...(stored?.left ?? {}) },
|
|
right: { ...DEFAULT_BOX_SIDE_ADJUST, ...(stored?.right ?? {}) },
|
|
}
|
|
);
|
|
};
|
|
|
|
const write = (chainageM: number, next: BoxAdjust): void => {
|
|
adjustments.set(chainageM.toFixed(2), next);
|
|
persist();
|
|
patchCachedDesign(chainageM, { box_adjust: next });
|
|
deps.refreshCard(chainageM);
|
|
};
|
|
|
|
const control: BoxControl = {
|
|
adjustFor: adjustAt,
|
|
update: (chainageM, role, patch) => {
|
|
const current = adjustAt(chainageM);
|
|
const side: BoxSideAdjust = { ...current[role], ...patch };
|
|
write(chainageM, {
|
|
...current,
|
|
[role]: {
|
|
// 길이는 바깥으로만 — 안쪽으로 줄이면 성토선 물매가 깨진다.
|
|
lengthM: Math.max(0, round1(side.lengthM)),
|
|
riseM: clampMove(side.riseM),
|
|
},
|
|
});
|
|
},
|
|
reset: (chainageM, role) => {
|
|
const current = adjustAt(chainageM);
|
|
write(chainageM, { ...current, [role]: { ...DEFAULT_BOX_SIDE_ADJUST } });
|
|
},
|
|
selectedFor: (chainageM) => selections.get(chainageM.toFixed(2)) ?? null,
|
|
select: (chainageM, role) => {
|
|
selections.set(chainageM.toFixed(2), role);
|
|
},
|
|
};
|
|
|
|
return {
|
|
control,
|
|
byChainage: () => {
|
|
const result = new Map<number, BoxAdjust>();
|
|
adjustments.forEach((adjust, key) => {
|
|
const value = Number(key);
|
|
if (Number.isFinite(value)) result.set(value, adjust);
|
|
});
|
|
return result;
|
|
},
|
|
load,
|
|
};
|
|
}
|
|
|
|
/** 세월교·BOX암거 제어를 한 번에 만든다 — 측점 제어기 쪽 배선을 줄인다(700줄 제한). */
|
|
export function createBodyControls(
|
|
common: Omit<FordControlDeps, "sessionKey">,
|
|
sessionKey: (kind: "fordadjust" | "boxadjust") => string | null,
|
|
): {
|
|
ford: ReturnType<typeof createFordControls>;
|
|
box: ReturnType<typeof createBoxControls>;
|
|
} {
|
|
return {
|
|
ford: createFordControls({ ...common, sessionKey: () => sessionKey("fordadjust") }),
|
|
box: createBoxControls({ ...common, sessionKey: () => sessionKey("boxadjust") }),
|
|
};
|
|
}
|