- M02 종류별 탭 [종류 더하기] = 본보기(구조물 정본 원본) 복사 — 키 자동 · 이름 「본보기 2」 · 옵션 · 표시 · 그룹 · 배치 · 규칙 · 종류 덧칸 · 반영 그대로 · 종류.{새}.본보기 · 관 지점 종류 · 복사본은 본보기 밖
- 구조물 표 = 본보기 처음값 이어받음(resolveCatalog · resolve_catalog 짝 · 줄 칸 base) · baseType/base_type · specFor(명세) · 덧단 · 길이 전후 풀기 · 옹벽 추가 단 콘크리트
- 검사(화면 = 서버 짝) — 본보기 = 원본 · 같은 군 · 자리꼴 · 정본 · 만든 뒤 고정 · 복사본은 본보기가 숨긴 칸 이어받음 · 서버 덧칸 본보기 받음
- 특수 동작 = 동작 이름 — 바로 안 놓기 · 포장 나누기 = 포장_물넘이_겹침 · 월류 높이 기다림 = 월류단면
- 정본 목록 = 표 — 파이썬 관 지점 종류 = catalog owner · B05 시설 서브폼 = 표 형상 · 안 쓰는 손 목록 걷음
- drawing_views — 스키마에서 빼고 읽을 때 버림 · M02 [저장] 때 빠짐(코드는 마스터 안 고침)
- 이관 = 지난 판 이름 대신 측점 계획 자리(planted)로 가름 · all_type_names 걷음
- 허용 거리 = common_util_structure_station.py 한 곳(SAME_STATION_M · EDGE_TOLERANCE_M · PIPE_MATCH_M) · TS 표는 station.ts 머리
- 시험: test_323_7_new_type(템플릿 · 일곱 갈래 · 그림 · 검사 짝 · 서버 읽기) · 322-0 유령 시험 = 자리 · 옛 도움 파일 동작 · 표 길 · 기대 글 고침
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
46 lines
2.5 KiB
TypeScript
46 lines
2.5 KiB
TypeScript
/* =============================================================================
|
|
* M02_SO_Def_Add.ts
|
|
* 종류 더하기(PLAN 323-7) — 본보기(구조물 정본 원본 종류)를 그대로 복사한 새 종류.
|
|
*
|
|
* 키 자동(`{본보기}_xxxxxx` · 만든 뒤 안 바뀜) · 이름 「{본보기} 2」(겹치면 3 …) · 군 · 자리꼴 · 옵션 · 표시 · 그룹 ·
|
|
* 배치 · 규칙 · 종류 덧칸(동작 · 이름 표) · 반영 그대로 · `종류.{새}.본보기 = 원본` — 구조물 표가 본보기 처음값을
|
|
* 이어받고(`resolveCatalog` · 일곱 갈래 = 목록 · 횡단도 · 카드이름 · 형상 · 형상칸 · 3D · 자리꼴), 손코딩 동작 ·
|
|
* 명세도 본보기 키로 고름(`baseType`). 관 지점 정본 종류는 본보기에서 뺌(관 시설 폼 · 정본 목록이 따로).
|
|
* ========================================================================== */
|
|
|
|
import { clone, newKey, type StructDef } from "./M02_SO_Def_Model";
|
|
|
|
/** 본보기로 고를 수 있는 종류 — 구조물 정본 · 원본(본보기 아님) · [키, 이름] (정의 차례). */
|
|
export const templates = (def: StructDef): Array<[string, string]> =>
|
|
def.types
|
|
.filter((t) => !t.managed_by && !def.종류[t.type_id]?.본보기)
|
|
.map((t) => [t.type_id, t.name] as [string, string]);
|
|
|
|
/** 본보기를 복사해 그 뒤에 새 종류를 끼움 — 새 키(못 하면 null). */
|
|
export function addFromTemplate(def: StructDef, sourceId: string): string | null {
|
|
const index = def.types.findIndex((t) => t.type_id === sourceId);
|
|
const src = def.types[index];
|
|
if (!src || src.managed_by || def.종류[sourceId]?.본보기) return null;
|
|
const key = newKey(
|
|
`${sourceId}_`,
|
|
def.types.map((t) => t.type_id),
|
|
);
|
|
const names = new Set(def.types.map((t) => t.name));
|
|
let n = 2;
|
|
while (names.has(`${src.name} ${n}`)) n += 1;
|
|
const copy = clone(src);
|
|
copy.type_id = key;
|
|
copy.name = `${src.name} ${n}`;
|
|
delete copy.drawing_views; // 안 읽는 칸(323-7)
|
|
def.types.splice(index + 1, 0, copy);
|
|
def.종류[key] = { ...clone(def.종류[sourceId] ?? {}), 본보기: sourceId };
|
|
for (const table of [def.표시, def.그룹, def.배치] as Array<Record<string, unknown>>)
|
|
if (table[sourceId] !== undefined) table[key] = clone(table[sourceId]);
|
|
def.규칙.push(
|
|
...def.규칙.filter((r) => r.종류 === sourceId).map((r) => ({ ...clone(r), 종류: key })),
|
|
);
|
|
const reflect = (def as { 반영?: Record<string, unknown> }).반영;
|
|
if (reflect?.[sourceId] !== undefined) reflect[key] = clone(reflect[sourceId]);
|
|
return key;
|
|
}
|