From 303342a56e201742c90bb9c23f4de31e68be0d21 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Sat, 10 Oct 2026 15:29:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat(b07):=20=ED=9A=A1=EB=8B=A8=20=EC=9E=A5?= =?UTF-8?q?=20=EC=B8=A1=EC=A0=90=EB=A7=88=EB=8B=A4=20=EB=8F=84=EB=A9=B4?= =?UTF-8?q?=EC=B8=B5=20=C2=B7=20=EC=98=9B=20=ED=99=95=EC=A0=95=20=EC=9E=A5?= =?UTF-8?q?=20=EC=9B=90=EC=A7=80=EB=B0=98=20=EC=9E=A0=EA=B8=88=20=ED=92=82?= =?UTF-8?q?(212-1=20=C2=B7=20212-2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 까닭: 새로 만든 장은 서버 · CAD 걸름 모두 원지반이 잡힘 — 안 잡힌 것은 180-1 앞에 원지반 층 잠금째 저장된 확정 장 또는 반영 전 서버 · 페이지 메모리의 옛 도면 - 확정 장을 열 때 원지반 층 잠금 풂 · 측점 층 없는 확정 장은 stale_layers 안내([수정] 때 새 꼴) - 장의 측점마다 층 하나(b08-station-{측점} · 「횡단 No.3」) = 원지반 · 계획선 · 구조물 · 암 그림(자식 선까지) · 종류는 색 · 선 꼴 · 표 · 글은 수량표 층 · 종류 층 지움 - 개체 id · groupId 그대로 · placement 에 layer_id · design_ids — 화면 덧그림도 측점 층 · 서버 설계선은 id 로 걷음 - DXF 층 이름 = 측점 층 id - 새 시험 test_212 · 174 · 180 · 180_2 원지반 찾기를 색으로 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TNMXVCZXMpHpVvqmFkeChL --- .../B07_DesignDetail_Api_Fetch.ts | 2 + .../B07_DesignDetail_Engine_Cad_Sheet.py | 29 ++- .../B07_DesignDetail_Router_Support.py | 12 ++ .../B07_DesignDetail_UI_Cad_Structures.ts | 15 +- B07_DesignDetail/B07_DesignDetail_UI_Page.ts | 5 + .../tester/test_174_b07_cross_cell_stack.py | 6 +- .../tester/test_180_2_b07_cross_scale.py | 6 +- resources/tester/test_180_b07_cross_group.py | 9 +- .../test_212_b07_cross_station_layers.py | 185 ++++++++++++++++++ 9 files changed, 257 insertions(+), 12 deletions(-) create mode 100644 resources/tester/test_212_b07_cross_station_layers.py diff --git a/B07_DesignDetail/B07_DesignDetail_Api_Fetch.ts b/B07_DesignDetail/B07_DesignDetail_Api_Fetch.ts index 696c3f773..2efd5bcc4 100644 --- a/B07_DesignDetail/B07_DesignDetail_Api_Fetch.ts +++ b/B07_DesignDetail/B07_DesignDetail_Api_Fetch.ts @@ -41,6 +41,8 @@ export interface CadDrawing { stale_layout?: boolean; /** 횡단 장 — 지금과 다른 표 · 글 배율로 확정된 저장본(180-2). */ stale_scale?: boolean; + /** 횡단 장 — 측점 도면층(212-2) 앞에 확정된 저장본. [수정]을 누르면 측점 층으로 다시 만든다. */ + stale_layers?: boolean; layers: { id: string; name: string; diff --git a/B07_DesignDetail/B07_DesignDetail_Engine_Cad_Sheet.py b/B07_DesignDetail/B07_DesignDetail_Engine_Cad_Sheet.py index e2b8d5eb5..1dc94c77b 100644 --- a/B07_DesignDetail/B07_DesignDetail_Engine_Cad_Sheet.py +++ b/B07_DesignDetail/B07_DesignDetail_Engine_Cad_Sheet.py @@ -5,6 +5,8 @@ 칸 가운데 · 작성 척도 1/100 그대로(큰 단면이 칸을 넘으면 겹침 — 사용자 배치로 고침). 칸 = 인쇄되는 표 격자선 · 블록 테두리 없음 · 칸보다 큰 단면은 `overflow_cells`(169-2). 칸 안 = 표를 칸 아래 가운데에 먼저 · 그 위 글 · 그림(도로 중심 = 칸 가운데)(174-1). +측점마다 도면층 하나(「횡단 No.3」) = 원지반 · 계획선 · 구조물 · 암 그림 · 종류는 색 · 선 꼴 +· 표 · 글은 수량표 층(212-2). """ import re @@ -52,6 +54,10 @@ CROSS_SHEET_ID = re.compile(r"cross_s(\d{2,}(?:\.\d{2})?)m?") _BORDER_PAD_MM = CROSS_BORDER_PAD_MM # 칸 아래선 ~ 표 아래선 여백(mm) — 같은 행 표가 한 높이(174-1) CELL_TABLE_PAD_MM = 5.0 +# 측점 도면층 id 머리(212-2) — 뒤에 측점 · DXF 층 이름도 이 id +STATION_LAYER_PREFIX = "b08-station-" +# 측점 층으로 옮길 그림 종류 층 — 표 · 글(수량표 층)은 그대로 +_DRAWING_LAYER_IDS = {GROUND_LAYER_ID, DESIGN_LAYER_ID, STRUCTURE_LAYER_ID, ROCK_LAYER_ID} def _design_points(design_line: list[Any] | None) -> list[tuple[float, float]]: @@ -178,11 +184,20 @@ def _grid_lines(sheet_id: str, cols: int, rows: int) -> list[dict[str, Any]]: ] +def _move_to_layer(entity: dict[str, Any], layer_id: str) -> None: + """그림 종류 층 개체(자식 선까지)를 측점 층으로 — id 는 그대로(212-2).""" + if entity.get("layerId") in _DRAWING_LAYER_IDS: + entity["layerId"] = layer_id + for child in entity.get("children") or []: + child["layerId"] = layer_id + + def build_cross_sheet(sheet: dict[str, Any], sections: list[dict[str, Any]]) -> dict[str, Any]: """한 장을 만든다. sections는 이 장에 담을 측점 입력들(배치 순서대로).""" entities: list[dict[str, Any]] = [] placements: list[dict[str, Any]] = [] overflow: list[list[float]] = [] + station_layers: list[dict[str, Any]] = [] slots = sheet.get("slots") or [] cols, rows = sheet.get("grid") or (4, 4) usable_w, usable_h = usable_area() @@ -222,8 +237,17 @@ def build_cross_sheet(sheet: dict[str, Any], sections: list[dict[str, Any]]) -> group_id = str(uuid5(_ENTITY_NS, f"{seed_id}:group")) for entity in placed["entities"]: entity["groupId"] = group_id + # 측점 도면층(212-2) — 층 관리에서 그 측점 그림만 고르기 · 켜고 끄기 · 잠그기 + layer_id = f"{STATION_LAYER_PREFIX}{section['chainage']}" + title = section.get("title") or f"{section['chainage']}" + station_layers.append(_layer(layer_id, f"횡단 {title}")) + design_ids = [e["id"] for e in placed["entities"] if e["layerId"] == DESIGN_LAYER_ID] + for entity in placed["entities"]: + _move_to_layer(entity, layer_id) for placement in placed.get("cross_placements") or []: placement["group_id"] = group_id + placement["layer_id"] = layer_id + placement["design_ids"] = design_ids # 화면이 다시 그려 갈아 끼울 서버 설계선 entities.extend(placed["entities"]) placements.extend(placed.get("cross_placements") or []) @@ -246,10 +270,7 @@ def build_cross_sheet(sheet: dict[str, Any], sections: list[dict[str, Any]]) -> # 칸보다 큰 단면의 칸 [x0, y0, x1, y1] — 라우터가 CAD 가이드 붉은 틀로 보냄(169-2) "overflow_cells": overflow, "layers": [ - _layer(GROUND_LAYER_ID, "원지반"), - _layer(DESIGN_LAYER_ID, "계획선"), - _layer(STRUCTURE_LAYER_ID, "구조물"), - _layer(ROCK_LAYER_ID, "암 경계선"), + *station_layers, _layer(CROSS_TABLE_LAYER_ID, "수량 산출표"), _layer(FRAME_LAYER_ID, "도각", locked=True), ], diff --git a/B07_DesignDetail/B07_DesignDetail_Router_Support.py b/B07_DesignDetail/B07_DesignDetail_Router_Support.py index b63a43981..c70185032 100644 --- a/B07_DesignDetail/B07_DesignDetail_Router_Support.py +++ b/B07_DesignDetail/B07_DesignDetail_Router_Support.py @@ -18,6 +18,7 @@ from B05_Profile.B05_Profile_Engine_Sections import ( from B06_Section.B06_Section_Engine_Design import compute_cross_design, curve_widening_args from B07_DesignDetail.B07_DesignDetail_Engine_Cad import ( DRAWING_FORMAT, + GROUND_LAYER_ID, build_cross_drawing, infer_station_interval, station_no_label, @@ -32,6 +33,7 @@ from B07_DesignDetail.B07_DesignDetail_Engine_Cad_MassHaul import build_mass_hau from B07_DesignDetail.B07_DesignDetail_Engine_Cad_PlanKinds import build_plan_kind_drawing from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Sheet import ( CROSS_SHEET_ID, + STATION_LAYER_PREFIX, build_cross_sheet, plan_cross_sheets, ) @@ -462,12 +464,22 @@ def _read_drawing( else: kind = "longitudinal" if _LONG_ID.fullmatch(drawing_id) else "cross" label = str(manifest_entry.get("label") or drawing_id) + layers = [layer for layer in saved.get("layers") or [] if isinstance(layer, dict)] + if kind == "cross": + # 180-1 앞 확정본 = 원지반 층 잠금째 저장 — 열 때 풂(212-1) + for layer in layers: + if layer.get("id") == GROUND_LAYER_ID: + layer["isLocked"] = False if kind == "cross" and manifest_entry.get("layout") != CROSS_SHEET_LAYOUT: saved["stale_layout"] = True # 화면이 [수정] → 새 배치로 다시 만들기를 안내 elif kind == "cross" and drawing_id.startswith("cross_s"): scale = read_cross_layout(project_root)["table_scale"] if manifest_entry.get("table_scale", 1.0) != scale: saved["stale_scale"] = True # 옛 배율로 확정한 장 — 그대로 두고 안내(180-2) + elif not any( + str(layer.get("id")).startswith(STATION_LAYER_PREFIX) for layer in layers + ): + saved["stale_layers"] = True # 측점 층 앞 확정본 — [수정] 때 측점 층(212-2) stored_table = manifest_entry.get("quantity_table") table = stored_table if kind == "cross" and isinstance(stored_table, dict) else None return kind, label, saved, True, table diff --git a/B07_DesignDetail/B07_DesignDetail_UI_Cad_Structures.ts b/B07_DesignDetail/B07_DesignDetail_UI_Cad_Structures.ts index f0e55d6ba..c4e446c65 100644 --- a/B07_DesignDetail/B07_DesignDetail_UI_Cad_Structures.ts +++ b/B07_DesignDetail/B07_DesignDetail_UI_Cad_Structures.ts @@ -34,6 +34,16 @@ export interface CrossPlacement { frame?: number[]; /** 측점 한 벌 묶음(180-1) — 덧그림도 같은 묶음으로 함께 골라짐. */ group_id?: string; + /** 측점 도면층(212-2) — 덧그림도 그 층에. */ + layer_id?: string; + /** 갈아 끼울 서버 설계선 id(212-2) — 측점 층이면 층으로는 못 가림. */ + design_ids?: string[]; +} + +/** 개체(자식 선까지)를 측점 층으로(212-2). */ +function moveToLayer(entity: Entity, layerId: string): void { + entity.layerId = layerId; + for (const child of (entity.children as Entity[] | undefined) ?? []) moveToLayer(child, layerId); } /** 측점과 도면 배치를 같은 자리로 볼 허용 오차(m). 정본이 누가거리를 0.01m로 끊어 쓴다. */ @@ -62,6 +72,7 @@ export async function appendStructureEntities( let added = 0; const fresh: Entity[] = []; const replaced: number[][] = []; + const designIds = new Set(); for (const placement of placements) { const section = sections.find( (item) => Math.abs(item.chainage_m - placement.chainage_m) <= CHAINAGE_TOLERANCE_M, @@ -81,6 +92,8 @@ export async function appendStructureEntities( } if (!entities.length) continue; if (placement.group_id) for (const entity of entities) entity.groupId = placement.group_id; + if (placement.layer_id) for (const entity of entities) moveToLayer(entity, placement.layer_id); + for (const id of placement.design_ids ?? []) designIds.add(id); // 이 블록 설계선은 우리가 다시 그렸다 — 서버가 낸 트림 전 설계선은 걷어낸다. replaced.push(frame); fresh.push(...entities); @@ -89,7 +102,7 @@ export async function appendStructureEntities( if (replaced.length) { // 걷어내기는 새 엔티티를 넣기 **전에** 한다 — 뒤에 하면 우리 것까지 같이 지운다. drawing.entities = drawing.entities.filter((entity) => { - if (entity.layerId !== DESIGN_LAYER_ID) return true; + if (entity.layerId !== DESIGN_LAYER_ID && !designIds.has(entity.id as string)) return true; const box = entityBox(entity); if (!box) return true; return !replaced.some( diff --git a/B07_DesignDetail/B07_DesignDetail_UI_Page.ts b/B07_DesignDetail/B07_DesignDetail_UI_Page.ts index 22499e06f..4ee7d0a34 100644 --- a/B07_DesignDetail/B07_DesignDetail_UI_Page.ts +++ b/B07_DesignDetail/B07_DesignDetail_UI_Page.ts @@ -365,6 +365,11 @@ export async function renderB07DesignDetail(root: HTMLElement): Promise { "옛 표 배율로 확정된 장입니다. [수정]을 누르면 지금 배율로 다시 만듭니다.", "info", ); + } else if (response.drawing.stale_layers) { + showToast( + "측점 도면층 앞에 확정된 장입니다. [수정]을 누르면 측점마다 층(횡단 No.)으로 다시 만듭니다.", + "info", + ); } } catch (error) { cad.fail(error instanceof Error ? error.message : "CAD 도면을 불러오지 못했습니다."); diff --git a/resources/tester/test_174_b07_cross_cell_stack.py b/resources/tester/test_174_b07_cross_cell_stack.py index cb4982436..eefcac2ce 100644 --- a/resources/tester/test_174_b07_cross_cell_stack.py +++ b/resources/tester/test_174_b07_cross_cell_stack.py @@ -11,7 +11,7 @@ import pytest -from B07_DesignDetail.B07_DesignDetail_Engine_Cad import GROUND_LAYER_ID +from B07_DesignDetail.B07_DesignDetail_Engine_Cad import GROUND_COLOR from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Sheet import ( CELL_TABLE_PAD_MM, build_cross_sheet, @@ -95,7 +95,9 @@ def test_같은_행_표_한_높이_그림_중심_칸_가운데() -> None: assert tables[0][0] == pytest.approx(tables[1][0]) # 도로 중심(offset 0) = 칸 가운데 · 그림(원지반) 아래 끝 = 글(없으면 표) 위 8 mm grounds = [ - entities_bbox([e]) for e in drawing["entities"] if e.get("layerId") == GROUND_LAYER_ID + entities_bbox([e]) + for e in drawing["entities"] + if e.get("type") == "PolyLine" and e.get("lineColor") == GROUND_COLOR ] for placement, slot, table, design, ground in zip( drawing["cross_placements"], sheet["slots"], tables, designs, grounds, strict=True diff --git a/resources/tester/test_180_2_b07_cross_scale.py b/resources/tester/test_180_2_b07_cross_scale.py index 3fc8dec6e..e9d47710d 100644 --- a/resources/tester/test_180_2_b07_cross_scale.py +++ b/resources/tester/test_180_2_b07_cross_scale.py @@ -14,7 +14,7 @@ from pathlib import Path import pytest -from B07_DesignDetail.B07_DesignDetail_Engine_Cad import DRAWING_FORMAT, GROUND_LAYER_ID +from B07_DesignDetail.B07_DesignDetail_Engine_Cad import DRAWING_FORMAT, GROUND_COLOR from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Sheet import ( CELL_TABLE_PAD_MM, build_cross_sheet, @@ -81,7 +81,9 @@ def test_배율_15_표_크기와_쌓기() -> None: bottom = shape["origin"]["y"] - sum(shape["rowHeights"]) assert bottom == pytest.approx(slot[1] - h / 4 + CELL_TABLE_PAD_MM) # 표 아래선 그대로 grounds = [ - entities_bbox([e]) for e in drawing["entities"] if e.get("layerId") == GROUND_LAYER_ID + entities_bbox([e]) + for e in drawing["entities"] + if e.get("type") == "PolyLine" and e.get("lineColor") == GROUND_COLOR ] # 글 2 줄 × 3.0 × 1.5 = 9 mm · 간격 8 mm 는 배율 안 탐 tops = [t["shapeData"]["origin"]["y"] for t in tables] diff --git a/resources/tester/test_180_b07_cross_group.py b/resources/tester/test_180_b07_cross_group.py index 4feffb1a1..d98296baa 100644 --- a/resources/tester/test_180_b07_cross_group.py +++ b/resources/tester/test_180_b07_cross_group.py @@ -10,6 +10,7 @@ from B07_DesignDetail.B07_DesignDetail_Engine_Cad import ( FRAME_LAYER_ID, + GROUND_COLOR, GROUND_LAYER_ID, build_cross_drawing, ) @@ -57,7 +58,9 @@ def _ground_locked(drawing: dict) -> bool: def test_원지반_층_안_잠김() -> None: - assert _ground_locked(_drawing()) is False + # 장 = 원지반이 측점 층에(212-2) · 도각 말고 잠긴 층 없음 + layers = _drawing()["layers"] + assert not any(layer["isLocked"] for layer in layers if layer["id"] != FRAME_LAYER_ID) single = build_cross_drawing(_source(0.0), "cross_00000m", _design_line(), None, None, "") assert _ground_locked(single) is False @@ -72,9 +75,9 @@ def test_측점마다_groupId_하나() -> None: assert {e["groupId"] for e in grouped} == set(group_ids) for group_id in group_ids: members = [e for e in grouped if e["groupId"] == group_id] - layers = {e["layerId"] for e in members} types = {e["type"] for e in members} - assert GROUND_LAYER_ID in layers and "Table" in types and "Text" in types + ground = any(e["type"] == "PolyLine" and e["lineColor"] == GROUND_COLOR for e in members) + assert ground and "Table" in types and "Text" in types # 격자선 · 도각은 묶지 않음 assert all("groupId" not in e for e in drawing["entities"] if e["layerId"] == FRAME_LAYER_ID) assert all(e["layerId"] != FRAME_LAYER_ID for e in grouped) diff --git a/resources/tester/test_212_b07_cross_station_layers.py b/resources/tester/test_212_b07_cross_station_layers.py new file mode 100644 index 000000000..baa293a31 --- /dev/null +++ b/resources/tester/test_212_b07_cross_station_layers.py @@ -0,0 +1,185 @@ +# -*- coding: utf-8 -*- +"""212-1 · 212-2 B07 횡단 장 — 원지반 고르기 · 측점별 도면층. + +못박는 것 + - 212-1 옛 확정 장(원지반 층 잠금째 저장)도 열 때 원지반 잠금 풂 · 측점 층 없으면 stale_layers. + - 212-2 장의 측점마다 층 하나(`b08-station-{측점}` · 이름 「횡단 {제목}」) = 원지반 · 계획선 · + 암 그림(자식 선까지) · 표 · 글은 수량표 층 · 격자선 · 도각은 도각 층 · 종류 층 없음. + - 개체 id 는 그대로(층만 바뀜) · placement 에 layer_id · design_ids(화면 덧그림 갈아 끼우기). + - DXF 층 이름 = 측점 층 id 그대로(금지 문자 없음). + - 화면 덧그림도 측점 층 · design_ids 로 서버 설계선 걷음(소스 확인 · typecheck 는 따로). +""" + +import json +from pathlib import Path +from uuid import uuid5 + +import ezdxf + +from B07_DesignDetail.B07_DesignDetail_Engine_Cad import ( + _POLY_NS, + CROSS_TABLE_LAYER_ID, + DESIGN_COLOR, + DESIGN_LAYER_ID, + DRAWING_FORMAT, + FRAME_LAYER_ID, + GROUND_COLOR, + GROUND_LAYER_ID, + ROCK_LAYER_ID, + STRUCTURE_LAYER_ID, +) +from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Sheet import ( + STATION_LAYER_PREFIX, + build_cross_sheet, + plan_cross_sheets, +) +from B07_DesignDetail.B07_DesignDetail_Engine_Frame_Export import _layer_name, drawing_to_dxf +from B07_DesignDetail.B07_DesignDetail_Engine_Template import use_project_templates +from B07_DesignDetail.B07_DesignDetail_Router_Support import CROSS_SHEET_LAYOUT, _read_drawing + +ROOT = Path(__file__).resolve().parents[2] +KIND_LAYERS = {GROUND_LAYER_ID, DESIGN_LAYER_ID, STRUCTURE_LAYER_ID, ROCK_LAYER_ID} + + +def _source(chainage: float) -> dict: + return { + "chainage_m": chainage, + "samples": [ + {"valid": True, "offset_m": float(x), "elevation_m": 100.0 + 0.1 * x} + for x in range(-5, 6) + ], + } + + +def _sheet() -> tuple[dict, dict]: + use_project_templates(None) + chainages = [0.0, 20.0, 40.0, 60.0] + sheet = plan_cross_sheets(chainages, {"default": [2, 2]})[0] + sections = [ + { + "chainage": c, + "source": _source(c), + # 암 지반 = 암 경계선도 측점 층으로 + "design": {"rock_boundary_offset_m": -1.0} if c == 20.0 else None, + "design_line": [{"offset_m": x, "elevation_m": 100.0} for x in (-3.0, 0.0, 3.0)], + "quantity_table": {"ground": 1.0, "planned": 0.5}, + "title": f"No.{int(c // 20)}", + } + for c in chainages + ] + return sheet, build_cross_sheet(sheet, sections) + + +def _flat(entities: list[dict]) -> list[dict]: + out = [] + for entity in entities: + out.append(entity) + out.extend(_flat(entity.get("children") or [])) + return out + + +def test_측점마다_층_하나_이름_횡단_No(): + _sheet_, drawing = _sheet() + layers = drawing["layers"] + ids = [layer["id"] for layer in layers] + assert ids[:4] == [f"{STATION_LAYER_PREFIX}{c}" for c in (0.0, 20.0, 40.0, 60.0)] + assert [layer["name"] for layer in layers[:4]] == [ + "횡단 No.0", + "횡단 No.1", + "횡단 No.2", + "횡단 No.3", + ] + assert ids[4:] == [CROSS_TABLE_LAYER_ID, FRAME_LAYER_ID] + assert not KIND_LAYERS & set(ids) # 종류 층 없음 — 빈 층이 안 남음 + assert all(layer["isVisible"] and not layer["isLocked"] for layer in layers[:4]) + + +def test_그림은_측점_층_표_글은_수량표_층_격자는_도각(): + _sheet_, drawing = _sheet() + flat = _flat(drawing["entities"]) + assert not any(e["layerId"] in KIND_LAYERS for e in flat) # 자식 선까지 + by_layer: dict[str, list[dict]] = {} + for entity in drawing["entities"]: + by_layer.setdefault(entity["layerId"], []).append(entity) + for chainage in (0.0, 20.0, 40.0, 60.0): + members = by_layer[f"{STATION_LAYER_PREFIX}{chainage}"] + colors = {e["lineColor"] for e in members} + assert GROUND_COLOR in colors and DESIGN_COLOR in colors + assert all(e["type"] == "PolyLine" for e in members) + assert len({e["groupId"] for e in members}) == 1 # 180-1 groupId 그대로 + # 암 지반 측점만 점선 암 경계선(종류 = 선 꼴) + rock = [e for e in by_layer[f"{STATION_LAYER_PREFIX}20.0"] if e.get("lineDash")] + assert len(rock) == 1 + assert not any(e.get("lineDash") for e in by_layer[f"{STATION_LAYER_PREFIX}0.0"]) + assert {e["type"] for e in by_layer[CROSS_TABLE_LAYER_ID]} <= {"Table", "Text"} + assert all("groupId" not in e for e in by_layer[FRAME_LAYER_ID]) + + +def test_id_그대로_placement_layer_id_design_ids(): + sheet, drawing = _sheet() + by_id = {e["id"]: e for e in drawing["entities"]} + for placement in drawing["cross_placements"]: + chainage = placement["chainage_m"] + layer_id = f"{STATION_LAYER_PREFIX}{chainage}" + assert placement["layer_id"] == layer_id + seed = f"{sheet['id']}:{chainage}" + # 개체 id 는 종류 층 씨앗 그대로 — 저장본 · 덧그림 짝이 안 흔들림 + ground = by_id[str(uuid5(_POLY_NS, f"{seed}:{GROUND_LAYER_ID}"))] + assert ground["layerId"] == layer_id and ground["lineColor"] == GROUND_COLOR + design_ids = placement["design_ids"] + assert design_ids == [str(uuid5(_POLY_NS, f"{seed}:{DESIGN_LAYER_ID}"))] + assert all(by_id[i]["lineColor"] == DESIGN_COLOR for i in design_ids) + + +def test_DXF_층_이름_측점_층_id(tmp_path: Path): + _sheet_, drawing = _sheet() + for layer in drawing["layers"]: + assert _layer_name(layer["id"]) == layer["id"] + data, _skipped = drawing_to_dxf(drawing) + (tmp_path / "sheet.dxf").write_bytes(data) + names = {layer.dxf.name for layer in ezdxf.readfile(tmp_path / "sheet.dxf").layers} + assert {f"{STATION_LAYER_PREFIX}{c}" for c in (0.0, 20.0, 40.0, 60.0)} <= names + assert not KIND_LAYERS & names + + +def test_옛_확정_장_원지반_잠금_풂_측점_층_안내(tmp_path: Path): + stage = tmp_path / "B07_DesignDetail" + (stage / "drawings").mkdir(parents=True) + layers = [ + {"id": GROUND_LAYER_ID, "name": "원지반", "isVisible": True, "isLocked": True}, + {"id": FRAME_LAYER_ID, "name": "도각", "isVisible": True, "isLocked": True}, + ] + saved = {"format": DRAWING_FORMAT, "entities": [], "layers": layers} + path = stage / "drawings" / "cross_s00000m.json" + path.write_text(json.dumps(saved), encoding="utf-8") + entry = {"kind": "cross", "label": "1장", "confirmed": True, "layout": CROSS_SHEET_LAYOUT} + (stage / "manifest.json").write_text( + json.dumps({"drawings": {"cross_s00000m": entry}}), encoding="utf-8" + ) + + def read() -> dict: + _k, _l, drawing, confirmed, _t = _read_drawing( + tmp_path, tmp_path / "x.json", "cross_s00000m" + ) + assert confirmed + return drawing + + drawing = read() + locked = {layer["id"]: layer["isLocked"] for layer in drawing["layers"]} + assert locked == {GROUND_LAYER_ID: False, FRAME_LAYER_ID: True} # 도각은 그대로 잠금 + assert drawing.get("stale_layers") is True + # 측점 층으로 확정한 장은 안내 없음 + saved["layers"] = [{"id": f"{STATION_LAYER_PREFIX}0", "name": "횡단 No.0"}, layers[1]] + path.write_text(json.dumps(saved), encoding="utf-8") + assert "stale_layers" not in read() + + +def test_화면_덧그림_측점_층_design_ids(): + struct = (ROOT / "B07_DesignDetail/B07_DesignDetail_UI_Cad_Structures.ts").read_text( + encoding="utf-8" + ) + assert "layer_id?: string;" in struct and "design_ids?: string[];" in struct + assert "moveToLayer(entity, placement.layer_id)" in struct + assert "!designIds.has(entity.id as string)" in struct + page = (ROOT / "B07_DesignDetail/B07_DesignDetail_UI_Page.ts").read_text(encoding="utf-8") + assert "response.drawing.stale_layers" in page From 473e3532e887b31e6a19b0e6bedb25f0775d8fee Mon Sep 17 00:00:00 2001 From: umsangdon Date: Sat, 10 Oct 2026 15:32:00 +0900 Subject: [PATCH 2/2] =?UTF-8?q?style(b07):=20=ED=9A=A1=EB=8B=A8=EB=8F=84?= =?UTF-8?q?=20=EB=B0=B0=EC=B9=98=20=EC=B9=B8=20=EB=8B=A8=EC=B6=94=20=C2=B7?= =?UTF-8?q?=20=EC=88=AB=EC=9E=90=20=EC=B9=B8=20=ED=95=9C=20=EA=B7=9C?= =?UTF-8?q?=EA=B2=A9=20=C2=B7=20=ED=95=9C=20=EC=A4=84=EC=97=90=20=ED=95=9C?= =?UTF-8?q?=20=EC=9D=BC=20=C2=B7=20=EA=B2=80=EC=9D=80=20=EC=84=A0=20=3D=20?= =?UTF-8?q?=EC=9D=B8=EC=87=84=20=EC=B9=B8=EC=84=A0=20=ED=8C=90=EC=A0=95(21?= =?UTF-8?q?2-3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 줄 = 배치 열 · 행 / [이 장] [모든 장] / 표 배율 [배율 적용] / [안내선 숨기기] · 한 줄 안 같은 너비 - 단추 · 숫자 칸 · 이름 = 줄 위 작은 단추 토큰(--btn-bar-* · 높이 16) · 옛 한 줄 감기 · 48px 고정 지움 - 안내선 숨김 뒤 남는 검은 선 = 인쇄 칸선(도각 층 · #8ea0b5 · 밝은 바탕에서 짙게) — 지우지 않음 - 새 시험 test_212_3 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01TNMXVCZXMpHpVvqmFkeChL --- .../B07_DesignDetail_UI_Panels.ts | 22 ++++-- .../B07_DesignDetail_UI_Style.css | 37 +++++++-- .../test_212_3_b07_cross_layout_buttons.py | 79 +++++++++++++++++++ 3 files changed, 123 insertions(+), 15 deletions(-) create mode 100644 resources/tester/test_212_3_b07_cross_layout_buttons.py diff --git a/B07_DesignDetail/B07_DesignDetail_UI_Panels.ts b/B07_DesignDetail/B07_DesignDetail_UI_Panels.ts index 0f214f7c5..68426a2fa 100644 --- a/B07_DesignDetail/B07_DesignDetail_UI_Panels.ts +++ b/B07_DesignDetail/B07_DesignDetail_UI_Panels.ts @@ -185,8 +185,9 @@ export interface CrossLayoutExtras { } /** - * 횡단 장 배치 칸(140-3 · 153-1) — 「배치 열 [4] 행 [4] [이 장] [모든 장]」 + 「표 배율 [1] [적용]」. - * `onApply` 가 없으면(장이 아닌 도면) [이 장]을 끔. + * 횡단 장 배치 칸(140-3 · 153-1) — 줄마다 한 일(212-3): + * 「배치 열 [4] 행 [4]」 · 「[이 장] [모든 장]」 · 「표 배율 [1] [배율 적용]」 · (부르는 쪽이 붙이는 [안내선 숨기기]). + * 단추 · 숫자 칸 = 줄 위 작은 단추 한 규격(`--btn-bar-*`) · `onApply` 가 없으면(장이 아닌 도면) [이 장]을 끔. */ export function buildCrossLayoutControls( grid: [number, number], @@ -196,6 +197,12 @@ export function buildCrossLayoutControls( ): HTMLElement { const box = document.createElement("div"); box.className = "b07-cross-layout"; + const row = (...items: HTMLElement[]): HTMLElement => { + const line = document.createElement("div"); + line.className = "b07-cross-layout__row"; + line.append(...items); + return line; + }; const number = (value: number, label: string) => createInputField({ label, @@ -227,10 +234,11 @@ export function buildCrossLayoutControls( return button; }; box.append( - cols.root, - rows.root, - action("이 장", "이 장만 이 배치로", onApply), - action("모든 장", "모든 장을 이 배치로(장마다 값 지움)", onAllDefault), + row(cols.root, rows.root), + row( + action("이 장", "이 장만 이 배치로", onApply), + action("모든 장", "모든 장을 이 배치로(장마다 값 지움)", onAllDefault), + ), ); if (extras.scale) { const { onApply: applyScale } = extras.scale; @@ -255,7 +263,7 @@ export function buildCrossLayoutControls( }, }); button.title = "모든 장의 표 · 표 위 글 크기(기본 1)"; - box.append(scale.root, button); + box.append(row(scale.root, button)); } return box; } diff --git a/B07_DesignDetail/B07_DesignDetail_UI_Style.css b/B07_DesignDetail/B07_DesignDetail_UI_Style.css index e99f64b41..71c501fb3 100644 --- a/B07_DesignDetail/B07_DesignDetail_UI_Style.css +++ b/B07_DesignDetail/B07_DesignDetail_UI_Style.css @@ -225,8 +225,9 @@ color: var(--color-text-muted); } -/* 횡단 장 배치(153-1) — 횡단도 묶음 맨 아래 전체 폭: 배치 열 [4] 행 [4] [이 장] [모든 장]. - 좌측이 182px 까지 줄어드니 줄바꿈 허용 · 공용 칸의 오류 자리는 접음. */ +/* 횡단 장 배치(153-1 · 212-3) — 횡단도 묶음 맨 아래 전체 폭 · 한 줄에 한 일: + 배치 열 · 행 / [이 장] [모든 장] / 표 배율 [배율 적용] / [안내선 숨기기]. + 단추 · 숫자 칸 = 줄 위 작은 단추 한 규격(`--btn-bar-*` · 높이 16) · 한 줄 안 같은 너비 · 오류 자리는 접음. */ .b07-cross-layout-slot { grid-column: 1 / -1; } @@ -237,25 +238,45 @@ .b07-cross-layout { display: flex; - flex-wrap: wrap; - align-items: center; - gap: var(--spacing-4) var(--spacing-8); + flex-direction: column; + gap: var(--spacing-4); } -.b07-cross-layout > .ui-field { +.b07-cross-layout__row { + display: flex; + align-items: center; + gap: var(--spacing-8); +} + +.b07-cross-layout__row > * { + flex: 1 1 0; + min-width: 0; +} + +.b07-cross-layout .ui-field { display: flex; flex-direction: row; align-items: center; gap: var(--spacing-4); } +.b07-cross-layout .ui-btn, +.b07-cross-layout .ui-field .ui-input { + height: auto; + padding: var(--btn-bar-padding); + font-size: var(--btn-bar-font-size); + line-height: 1; +} + .b07-cross-layout .ui-field__label { margin: 0; + font-size: var(--btn-bar-font-size); white-space: nowrap; } -.b07-cross-layout .ui-input { - width: 48px; +.b07-cross-layout .ui-field .ui-input { + width: 100%; + min-width: 0; } .b07-cross-layout .ui-field__error { diff --git a/resources/tester/test_212_3_b07_cross_layout_buttons.py b/resources/tester/test_212_3_b07_cross_layout_buttons.py new file mode 100644 index 000000000..3b51c0f18 --- /dev/null +++ b/resources/tester/test_212_3_b07_cross_layout_buttons.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +"""212-3 B07 좌측 「횡단도」 배치 칸 — 단추 · 숫자 칸 한 규격 · 한 줄에 한 일 · 남는 검은 선 판정. + +못박는 것 + - 줄 = 「배치 열 · 행」 · 「[이 장] [모든 장]」 · 「표 배율 [배율 적용]」 + · [안내선 숨기기](부르는 쪽). + - 단추 · 숫자 칸 · 이름 = 줄 위 작은 단추 토큰(187 `--btn-bar-*` · 높이 16) · 한 줄 안 같은 너비. + - 옛 한 줄 감기(flex-wrap) · 숫자 칸 48px 고정 없음. + - [안내선 숨기기] 뒤 남는 검은 선 = 인쇄 칸선(도각 층 도면 개체 · 회청 `#8ea0b5` + · 밝은 바탕에서 짙게 그려짐) — 안내선(겹판)과 다른 것이라 지우지 않음 · 단추는 겹판만 끔. +""" + +import re +from pathlib import Path + +from B07_DesignDetail.B07_DesignDetail_Engine_Cad import FRAME_LAYER_ID, TABLE_LINE_COLOR +from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Sheet import _grid_lines +from B07_DesignDetail.B07_DesignDetail_Engine_Template import use_project_templates + +ROOT = Path(__file__).resolve().parents[2] +CSS = (ROOT / "B07_DesignDetail/B07_DesignDetail_UI_Style.css").read_text(encoding="utf-8") +PANELS = (ROOT / "B07_DesignDetail/B07_DesignDetail_UI_Panels.ts").read_text(encoding="utf-8") +PAGE = (ROOT / "B07_DesignDetail/B07_DesignDetail_UI_Page.ts").read_text(encoding="utf-8") +GUIDE = (ROOT / "B07_DesignDetail/openwebcad/src/integration/guide-area.ts").read_text( + encoding="utf-8" +) +THEME = (ROOT / "ui_template/ui_template_theme.css").read_text(encoding="utf-8") + + +def _block(selector: str) -> str: + m = re.search(r"(?:^|\n)" + re.escape(selector) + r"\s*\{([^}]*)\}", CSS) + assert m, selector + return m.group(1) + + +def _decl(block: str, prop: str) -> str: + m = re.search(r"(?:^|;|\s)" + re.escape(prop) + r"\s*:\s*([^;]+);", block) + assert m, prop + return m.group(1).strip() + + +def test_단추_숫자_칸_한_규격_토큰(): + shared = _block(".b07-cross-layout .ui-btn,\n.b07-cross-layout .ui-field .ui-input") + assert _decl(shared, "padding") == "var(--btn-bar-padding)" + assert _decl(shared, "font-size") == "var(--btn-bar-font-size)" + assert _decl(shared, "line-height") == "1" + assert _decl(shared, "height") == "auto" # 공용 작은 칸 30px 를 풀어 단추 높이에 맞춤 + label = _block(".b07-cross-layout .ui-field__label") + assert _decl(label, "font-size") == "var(--btn-bar-font-size)" + # 토큰은 theme 한 곳(187) + assert "--btn-bar-padding: 1px var(--spacing-8);" in THEME + assert "--btn-bar-font-size: var(--text-caption);" in THEME + + +def test_한_줄에_한_일_같은_너비(): + box = _block(".b07-cross-layout") + assert _decl(box, "flex-direction") == "column" + assert "flex-wrap" not in box + assert _decl(_block(".b07-cross-layout__row > *"), "flex") == "1 1 0" + assert "width: 48px" not in CSS + assert 'line.className = "b07-cross-layout__row"' in PANELS + assert "row(cols.root, rows.root)" in PANELS + assert re.search(r"row\(\s*action\(\"이 장\"[^;]*action\(\"모든 장\"", PANELS, re.S) + assert "box.append(row(scale.root, button));" in PANELS + # 안내선 단추 = 배치 칸 맨 아래 한 줄(전체 폭) + assert "controls.append(guideToggle);" in PAGE + + +def test_남는_검은_선은_인쇄_칸선_지우지_않음(): + use_project_templates(None) + lines = _grid_lines("cross_s00000m", 4, 4) + assert len(lines) == 10 # 세로 5 · 가로 5 그대로 + assert all(e["layerId"] == FRAME_LAYER_ID for e in lines) + assert all(e["lineColor"] == TABLE_LINE_COLOR == "#8ea0b5" for e in lines) + # 안내선 단추는 겹판(점선 영역 + 붉은 틀)만 — 도면 개체를 안 건드림 + draw = GUIDE[GUIDE.index("export function drawGuide") :] + draw = draw[: draw.index("\n}\n")] + assert "if (!guide || !guideVisible) return;" in draw + assert "getEntities" not in draw and "setEntities" not in draw