"""B07 표지 도면 — 템플릿 한 장을 그대로 도면으로 낸다 (2026-08-31 신설). 다른 도면과 다르게 **설계 자료가 없다**. 표지는 A1 종이에 고정 배치된 글자와 띠뿐이라 콘텐츠를 감쌀 일도, 척도를 맞출 일도 없다. 그래서 도각(`frame_entities()`)을 두르지 않고 `00_template_cover.json` 을 실치수 1:1 로 싣는다 — 사용자 확정(2026-08-31) "표지를 일단 전체가 템플릿이 되면 좋겠어" · "도각 없는 전면 디자인". `frame_entities()` 를 재사용하지 않는 이유는 두 가지다. ① 표지는 변환이 필요 없다(A1 실치수 고정). ② `_transform_entity()` 가 옮기는 좌표 키는 `startPoint·endPoint·basePoint·point· center` 뿐이라 표지의 굵은 띠(`Hatch`)가 쓰는 `points` 배열을 **못 옮긴다**. 띠를 `Hatch` 로 낸 것은 `lineWidth` 가 캔버스 화면 픽셀이라 실치수 두께를 못 내기 때문이다(`screenCanvas.drawController.ts:261`). """ from __future__ import annotations from typing import Any from uuid import uuid5 from B07_DesignDetail.B07_DesignDetail_Engine_Cad import ( _ENTITY_NS, DRAWING_FORMAT, FRAME_LAYER_ID, _layer, ) from B07_DesignDetail.B07_DesignDetail_Engine_Template import ( _fill_placeholders, _load_template, frame_entities, usable_bbox, ) COVER_TEMPLATE = "00_template_cover" # 빈 도면(준비 중)이 그림을 얹을 자유 도면층 — 도각만으로는 그릴 자리가 없다. BLANK_LAYER_ID = "b08-blank-draft" # 표지는 엔티티가 전부 도각(잠금)이라 그대로 두면 덧그릴 자리가 없다 — 잠금 아닌 # 도면층을 하나 실어 사용자가 적을 자리를 준다(2026-09-01). NOTE_LAYER_ID = "b08-cover-note" def build_cover_drawing(drawing_id: str, fields: dict[str, str] | None = None) -> dict[str, Any]: """표지 도면 문서. 템플릿이 없으면 빈 도면을 낸다. `{{키}}` 는 도각과 같은 규약으로 치환한다 — 값은 요청 문맥(`use_title_fields`)에서 오고, `fields` 로 준 것이 그 위에 얹힌다. 값이 없으면 빈칸(남의 값이 남지 않는다). """ template = _load_template(COVER_TEMPLATE) or {} entities: list[dict[str, Any]] = [] for index, entity in enumerate(template.get("entities", [])): placed = dict(entity) placed["id"] = str(uuid5(_ENTITY_NS, f"{drawing_id}:cover:{index}")) placed["layerId"] = FRAME_LAYER_ID shape = entity.get("shapeData") if isinstance(shape, dict): placed["shapeData"] = dict(shape) entities.append(placed) return { "format": DRAWING_FORMAT, "entities": _fill_placeholders(entities, fields or {}), "layers": [ _layer(NOTE_LAYER_ID, "주기"), _layer(FRAME_LAYER_ID, "도각", locked=True), ], } def build_blank_drawing(drawing_id: str, label: str) -> dict[str, Any]: """아직 내용을 만들지 않은 도면 — **도각만 실어** 연다 (2026-09-01 사용자 지시). 목록의 절반이 눌리지 않는 회색 버튼이면 고장난 것처럼 보인다. 도각이라도 열어 두면 사용자가 직접 그려 넣을 수도 있다. 도면명은 도각 표제란에 채운다. """ return { "format": DRAWING_FORMAT, # fit=False — 담을 콘텐츠가 없으니 A1 실치수 그대로 둔다. bbox는 작도 영역이 # 아니라 **수용 한도**를 준다(`_A1_INNER`를 주면 여백만큼 넘쳐 경고가 뜬다). "entities": frame_entities(drawing_id, usable_bbox(), fit=False, fields={"도면명": label}), "layers": [ _layer(BLANK_LAYER_ID, "작도"), _layer(FRAME_LAYER_ID, "도각", locked=True), ], }