feat(구조물표): 323-7 새 종류 · 정리 — M02 종류 더하기(본보기 복사 · 일곱 갈래 본보기 그대로) · 손코딩 동작 · 명세 = 본보기 키 · 특수 동작 = 동작 이름 · 정본 목록 = 표 · drawing_views 걷음 · 옛 이름 되짚기 걷음(자리로 가름) · 허용 거리 파이썬 한 곳 · 벽 툴팁 = 종류 이름

- 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
This commit is contained in:
2026-10-14 18:59:13 +09:00
co-authored by Claude Opus 5.5
parent 6744524669
commit 81f7d98e6f
48 changed files with 595 additions and 169 deletions
@@ -111,7 +111,8 @@ def _row_errors(doc: dict[str, Any], before: dict[str, Any] | None) -> list[str]
continue
if row["shape"] == "none" and row["station"] != "none":
out.append(f"「{row['name']}」 형상이 「없음」이면 횡단도도 「안 만듦」")
kept = _hidden_in(before or doc, t["type_id"]) # 앞 판 없음 = 새로 숨긴 것 없음
# 앞 판 없음 = 새로 숨긴 것 없음 · 복사한 종류 = 본보기가 앞 판에서 숨긴 칸도 그대로(323-7)
kept = [k for tid in (t["type_id"], row["base"]) for k in _hidden_in(before or doc, tid)]
hidden = [key for key in _hidden_in(doc, t["type_id"]) if key not in kept]
# 숨기면 그림이 기본값을 씀 — 기본값도 비워 두는 뜻도 없는 칸만 못 숨김
keys = {
@@ -144,10 +145,36 @@ def _row_errors(doc: dict[str, Any], before: dict[str, Any] | None) -> list[str]
return out
def _template_errors(doc: dict[str, Any]) -> list[str]:
"""본보기(복사한 종류 · 323-7) — 원본(구조물 정본 · 본보기 아닌 종류) · 같은 군 · 자리꼴 ·
정본(TS 짝)."""
out: list[str] = []
kinds = doc.get("종류") or {}
now = {t["type_id"]: t for t in doc.get("types") or []}
for tid, row in kinds.items():
src = (row or {}).get("본보기") if isinstance(row, dict) else None
if src is None or tid not in now:
continue
t, base = now[tid], now.get(src)
name = t.get("name") or tid
if base is None or src == tid or (kinds.get(src) or {}).get("본보기"):
out.append(f"「{name}」 본보기 「{src}」 — 원본 종류여야 함")
continue
same = all(
t.get(k) == base.get(k) for k in ("group", "placement", "managed_by")
) and not base.get("managed_by")
if not same:
out.append(
f"「{name}」 본보기 「{base.get('name') or src}」 와 군 · 자리꼴 · 정본이 같아야 함"
)
return out
def _fixed_errors(doc: dict[str, Any], before: dict[str, Any]) -> list[str]:
"""앞 판과 비교 — 만든 뒤 고정."""
out: list[str] = []
now = {t["type_id"]: t for t in doc.get("types") or []}
base_of = lambda d, tid: ((d.get("종류") or {}).get(tid) or {}).get("본보기") # noqa: E731
for old in before.get("types") or []:
tid = old["type_id"]
name = old.get("name") or tid
@@ -159,6 +186,7 @@ def _fixed_errors(doc: dict[str, Any], before: dict[str, Any]) -> list[str]:
("자리꼴", old.get("placement"), t.get("placement")),
("정본", old.get("managed_by"), t.get("managed_by")),
("군 글자", old.get("group"), t.get("group")),
("본보기", base_of(before, tid), base_of(doc, tid)),
)
for what, a, b in fixed:
if a != b:
@@ -180,4 +208,5 @@ def catalog_errors(doc: dict[str, Any], before: dict[str, Any] | None) -> list[s
shape = _shape_errors(doc, known)
if shape:
return shape
return _row_errors(doc, before) + _fixed_errors(doc, before) if before else []
templates = _template_errors(doc)
return templates + (_row_errors(doc, before) + _fixed_errors(doc, before) if before else [])
+19 -3
View File
@@ -29,12 +29,13 @@ import {
import { buildOptionsBlock } from "./M02_SO_Def_Options";
import { buildRulesBlock } from "./M02_SO_Def_Rules";
import { buildSpecBlock } from "./M02_SO_Def_Spec";
import { STRUCTURE_SPECS } from "../../A00_Common/design/design_structure_pipe";
import { specFor } from "../../A00_Common/design/design_structure_pipe";
import { catalogProblems, type CheckDef } from "./M02_SO_Def_Check";
import { buildParts } from "./M02_SO_Def_Parts";
import { differs, setReflect, tidy } from "./M02_SO_Def_Reflect";
import { buildReflectBlock, buildTable } from "./M02_SO_Def_Table";
import { checkBox, textBox } from "./M02_SO_Def_Ui";
import { checkBox, pickBox, textBox } from "./M02_SO_Def_Ui";
import { addFromTemplate, templates } from "./M02_SO_Def_Add";
import { buildGroupBlock } from "./M02_SO_Groups";
import { to } from "./M02_SO_Text";
@@ -116,6 +117,21 @@ function drawDef(first: StructDef, opt: DefScreenOptions): void {
const d = shown();
const edit = canEdit();
const parts: HTMLElement[] = [];
// 종류 더하기(323-7) — 본보기 고름 + 단추 · 새 종류를 골라 둠(이름 · 반영은 오른쪽에서 고침)
if (edit) {
const pairs = templates(d);
let pick = pairs.find(([key]) => key === current)?.[0] ?? pairs[0]?.[0] ?? "";
const box = pickBox(pairs, pick, (v) => (pick = v), { edit, attr: "data-sod-add-from" });
box.title = to("AddKindNote");
const add = smallButton(to("AddKind"), () => {
const key = addFromTemplate(d, pick);
if (!key) return;
current = key;
changed();
});
add.setAttribute("data-sod-add", "");
parts.push(el("div", { className: "m02-sod__family", children: [box, add] }));
}
const families = Object.keys(d.구조물군);
families.forEach((g, gi) => {
parts.push(
@@ -194,7 +210,7 @@ function drawDef(first: StructDef, opt: DefScreenOptions): void {
const edit = canEdit();
const extra = (): NonNullable<StructDef["종류"][string]> => (d.종류[type.type_id] ??= {});
// 이름만 고침(PLAN 52-11 · 52-12) — 명세 종류 = 명세 나무 · 나머지 = 정의 그룹 나무
const spec = STRUCTURE_SPECS[type.type_id];
const spec = specFor(type.type_id);
detail.replaceChildren(
el("div", {
className: "m02-sod__kindhead",
@@ -0,0 +1,45 @@
/* =============================================================================
* 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;
}
@@ -126,7 +126,8 @@ function rowErrors(doc: CheckDef, before: CheckDef | null): string[] {
if (!row) continue;
if (row.shape === "none" && row.station !== "none")
out.push(`「${row.name}」 형상이 「없음」이면 횡단도도 「안 만듦」`);
const kept = hiddenIn(before ?? doc, t.type_id); // 앞 판 없음 = 새로 숨긴 것 없음
// 앞 판 없음 = 새로 숨긴 것 없음 · 복사한 종류 = 본보기가 앞 판에서 숨긴 칸도 그대로(323-7)
const kept = [t.type_id, row.base].flatMap((id) => hiddenIn(before ?? doc, id));
const hidden = hiddenIn(doc, t.type_id).filter((key) => !kept.includes(key));
// 숨기면 그림이 기본값을 씀 — 기본값도 비워 두는 뜻도 없는 칸만 못 숨김
const keys = new Set(
@@ -161,9 +162,35 @@ function rowErrors(doc: CheckDef, before: CheckDef | null): string[] {
}
/** 앞 판과 비교 — 만든 뒤 고정. */
/** 본보기(복사한 종류 · 323-7) — 원본(구조물 정본 · 본보기 아닌 종류) · 같은 군 · 자리꼴 · 정본(파이썬 짝). */
function templateErrors(doc: CheckDef): string[] {
const out: string[] = [];
const kinds = doc.종류 ?? {};
const now = new Map((doc.types ?? []).map((t) => [t.type_id, t]));
for (const [tid, row] of Object.entries(kinds)) {
const src = row?.본보기;
const t = now.get(tid);
if (src == null || !t) continue;
const base = now.get(src);
const name = t.name || tid;
if (!base || src === tid || kinds[src]?.본보기) {
out.push(`「${name}」 본보기 「${src}」 — 원본 종류여야 함`);
continue;
}
const same =
(["group", "placement", "managed_by"] as const).every(
(k) => (t[k] ?? null) === (base[k] ?? null),
) && !base.managed_by;
if (!same)
out.push(`「${name}」 본보기 「${base.name || src}」 와 군 · 자리꼴 · 정본이 같아야 함`);
}
return out;
}
function fixedErrors(doc: CheckDef, before: CheckDef): string[] {
const out: string[] = [];
const now = new Map((doc.types ?? []).map((t) => [t.type_id, t]));
const baseOf = (d: CheckDef, tid: string) => d.종류?.[tid]?.본보기 ?? null;
for (const old of before.types ?? []) {
const t = now.get(old.type_id);
const name = old.name ?? old.type_id;
@@ -175,6 +202,7 @@ function fixedErrors(doc: CheckDef, before: CheckDef): string[] {
["자리꼴", old.placement, t.placement],
["정본", old.managed_by ?? null, t.managed_by ?? null],
["군 글자", old.group, t.group],
["본보기", baseOf(before, old.type_id), baseOf(doc, old.type_id)],
];
for (const [what, a, b] of fixed) if (a !== b) out.push(`「${name}」 ${what} — 만든 뒤 고정`);
const options = new Map((t.options ?? []).map((o) => [o.key, o]));
@@ -195,5 +223,9 @@ export function catalogProblems(doc: CheckDef, before: CheckDef | null): string[
const known = new Set((doc.types ?? []).map((t) => t.type_id));
const shape = shapeErrors(doc, known);
if (shape.length) return shape;
return before ? [...rowErrors(doc, before), ...fixedErrors(doc, before)] : [];
const templates = templateErrors(doc);
return [
...templates,
...(before ? [...rowErrors(doc, before), ...fixedErrors(doc, before)] : []),
];
}
@@ -58,7 +58,11 @@ export interface StructDef {
동작: Record<string, string>;
types: TypeDef[];
/** 이름 = 구조물 명세 이름 바꿈 표(PLAN 52 · 키 `{컨테이너}[.{항목}[={값}]]`) */
종류: Record<string, { 기준측점?: boolean; 동작?: string[]; 이름?: Record<string, string> }>;
/** 본보기 = 복사한 종류의 원본 키(323-7 · 만든 뒤 고정 · 처음값 · 손코딩 동작을 이어받음). */
종류: Record<
string,
{ 기준측점?: boolean; 동작?: string[]; 이름?: Record<string, string>; 본보기?: string }
>;
표시: Record<string, Record<string, false>>;
그룹: Record<string, GroupDef[]>;
배치: Record<string, Record<string, Spot>>;
@@ -66,7 +66,9 @@ def _type_errors(doc: dict[str, Any]) -> tuple[list[str], dict[str, dict[str, An
groups = {}
for row in doc.get("types") if isinstance(doc.get("types"), list) else []:
try:
t = schema.StructureType.model_validate(row)
t = schema.StructureType.model_validate(
schema.without_retired(row) if isinstance(row, dict) else row
)
except ValidationError as e:
errors.append(
f"종류 「{row.get('type_id') if isinstance(row, dict) else row}」 꼴 — {e}"
@@ -111,8 +113,11 @@ def _kind_errors(doc: dict[str, Any], keys: dict[str, dict[str, Any]]) -> list[s
continue
if name == "이름" and _names_ok(value):
continue
if name == "본보기" and isinstance(value, str) and value in keys:
continue # 복사한 종류의 원본(323-7) — 같은 군 등은 `_template_errors`
errors.append(
f"종류 덧칸 「{tid}.{name}」 이 틀림(기준측점 참거짓 · 동작 = 동작 이름들 · 이름 = 글 묶음)"
f"종류 덧칸 「{tid}.{name}」 이 틀림(기준측점 참거짓 · 동작 = 동작 이름들 · "
"이름 = 글 묶음 · 본보기 = 있는 종류 키)"
)
return errors
@@ -221,6 +226,13 @@ def save(doc: Any, version: Any) -> dict[str, Any]:
"""정의 통째로 고쳐 씀(시스템 관리자) — 돌려주는 것 = 새 정의."""
if not isinstance(doc, dict):
raise store.StoreError(400, "정의는 묶음이어야 함")
# 옛 칸(drawing_views)은 [저장] 때 빠짐(323-7 · 아무도 안 읽음)
types = doc.get("types")
if isinstance(types, list):
doc = {
**doc,
"types": [schema.without_retired(t) if isinstance(t, dict) else t for t in types],
}
return _commit(lambda _: dict(doc), version)
@@ -21,6 +21,11 @@ const TEXT = {
GroupName: ["그룹 이름", "Group name"],
GroupNew: ["새 그룹 {value}", "New group {value}"],
GroupUp: ["위로", "Up"],
AddKind: ["종류 더하기", "Add type"],
AddKindNote: [
"본보기 종류를 그대로 복사한 새 종류(이름 「본보기 2」) — 옵션 · 그룹 · 반영 · 그리는 법이 같음 · 이름 · 반영은 고쳐서 [저장]",
"New type copied from the template (name “template 2”) — same options, groups, reflect and drawing; edit name / reflect, then [Save]",
],
GroupDown: ["아래로", "Down"],
GroupDel: ["지우기", "Delete"],
GroupDelAsk: [