- 길: GET · PUT · DELETE /api/m02/templates* · structure-combos · structures/numbers · POST structures/{열} · structures/{열}/copy · area/{열}/copy — 화면은 모두 /layers/{층}/… (Api_Fetch scoped) · TS · 다른 서버 모듈 · B0x 부르는 곳 0
- main.py 등록 두 줄 지움
- 시험 여섯(store · structure · structure_combo · combo_branch · empty_master · spreadsheet_store)은 같은 저장소를 살아 있는 /layers/system 길로 보게 옮김 — 도우미 helper_m02_system_client(시스템 관리자 세션) · 층 길과 다른 점만 고침(목록 = 양식 칸 · 지우기 = 판 대조 · 없는 종류 400 · 묶음 아닌 몸 422)
- 검증: /openapi.json 508 → 499(뜻한 9 만) · 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 245 통과
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
"""M02 구조물 도면에 얹는 도각 길(`/structure-frame` · 56장) — B07 시스템 양식 도각을 그대로 다시 쓴다.
|
|
|
|
양식을 읽고 쓰는 길은 `_Router_Layers.py`(층 · 시스템 층 포함)가 맡는다.
|
|
"""
|
|
|
|
from fastapi import APIRouter
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from B07_DesignDetail.B07_DesignDetail_Engine_Template import (
|
|
entities_bbox,
|
|
frame_entities,
|
|
frame_guide_area,
|
|
usable_bbox,
|
|
)
|
|
|
|
router = APIRouter(prefix="/api/m02", tags=["M02 MasterTemplete"])
|
|
|
|
# 얹은 도각 층 — 화면이 돌려줄 때 이 층을 통째로 뺌 · 불러온 DXF 층(`b08-frame`)과 갈라 둠
|
|
STRUCTURE_FRAME_LAYER = "m02-structure-frame"
|
|
|
|
|
|
def _on_frame_layer(entity: dict) -> dict:
|
|
children = entity.get("children")
|
|
return {
|
|
**entity,
|
|
"layerId": STRUCTURE_FRAME_LAYER,
|
|
**({"children": [_on_frame_layer(c) for c in children]} if children else {}),
|
|
}
|
|
|
|
|
|
def structure_frame(number: str | None = None, name: str | None = None) -> dict:
|
|
"""구조물 도면에 얹는 도각 — B07 시스템 양식 1:1 · 외곽 좌하단 (0,0) · 보여주기 층 ·
|
|
`number` = 장 도번(82-2 · 도각 `{{도면번호}}`) · `name` = 도면명(376 · B07 구조물 도면)."""
|
|
fields = {
|
|
**({"도면번호": number} if number else {}),
|
|
**({"도면명": name} if name else {}),
|
|
} or None
|
|
placed = frame_entities("m02-structure", usable_bbox(), fit=False)
|
|
box = entities_bbox(placed)
|
|
if not box:
|
|
return {"entities": [], "layer": None}
|
|
ox, oy = box[0], box[1]
|
|
x0, y0, x1, y1 = usable_bbox()
|
|
entities = frame_entities(
|
|
"m02-structure", (x0 - ox, y0 - oy, x1 - ox, y1 - oy), fit=False, fields=fields
|
|
)
|
|
return {
|
|
"entities": [_on_frame_layer(entity) for entity in entities],
|
|
# 작도 영역(도각과 같은 좌표) — CAD 가이드 선(169-4 · 보기만)
|
|
"area": frame_guide_area(entities),
|
|
"layer": {
|
|
"id": STRUCTURE_FRAME_LAYER,
|
|
"name": "도각(보기)",
|
|
"isVisible": True,
|
|
"isLocked": True,
|
|
},
|
|
}
|
|
|
|
|
|
@router.get("/structure-frame")
|
|
async def get_structure_frame(number: str | None = None) -> JSONResponse:
|
|
"""구조물 도면 상세 · 카드 미리보기가 얹는 도각(56장) · `number` = 장 도번(82-2)."""
|
|
return JSONResponse({"status": "success", **structure_frame(number)})
|