- 00_template_A1.json 에 drawing_area [42, 47, 812, 567] - Engine_Template drawing_area(이름) · 칸이 없거나 어긋나면 A1 기본값 · usable_area · usable_bbox · frame_entities 가 씀 - 도각 저장은 고치기 전 양식의 작도 영역을 이어 받음 - 시험 test_m02_drawing_area.py Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PxvYb5ufV1kWdBvZbpDfu6
66 lines
2.4 KiB
Python
66 lines
2.4 KiB
Python
"""M02 도면 양식 작도 영역 칸(`drawing_area`) — 양식이 정본 · 없으면 A1 기본값 (PLAN 10-3)."""
|
|
|
|
import json
|
|
|
|
from B07_DesignDetail import B07_DesignDetail_Engine_Template as engine
|
|
|
|
|
|
def _company_template(tmp_path, document):
|
|
path = engine.company_template_path(tmp_path)
|
|
path.parent.mkdir(parents=True)
|
|
path.write_text(json.dumps(document), encoding="utf-8")
|
|
return path
|
|
|
|
|
|
def test_system_a1_reads_drawing_area():
|
|
engine.use_company_templates(None)
|
|
assert engine.drawing_area() == (42.0, 47.0, 812.0, 567.0)
|
|
# 도각 배치는 옮기기 전 박힌 값과 같다 — 콘텐츠 중심 = 작도 영역 중심.
|
|
frame = engine.frame_entities("t", (0.0, 0.0, 100.0, 100.0), fit=False)
|
|
assert frame
|
|
|
|
|
|
def test_missing_area_falls_back_to_a1(tmp_path):
|
|
_company_template(tmp_path, {"format": 6, "entities": [], "layers": []})
|
|
engine.use_company_templates(tmp_path)
|
|
try:
|
|
assert engine.drawing_area() == engine._A1_INNER
|
|
finally:
|
|
engine.use_company_templates(None)
|
|
|
|
|
|
def test_template_area_moves_content(tmp_path):
|
|
line = {
|
|
"id": "a",
|
|
"type": "Line",
|
|
"shapeData": {"startPoint": {"x": 0, "y": 0}, "endPoint": {"x": 10, "y": 0}},
|
|
}
|
|
_company_template(
|
|
tmp_path,
|
|
{"format": 6, "drawing_area": [0, 0, 400, 200], "entities": [line], "layers": []},
|
|
)
|
|
engine.use_company_templates(tmp_path)
|
|
try:
|
|
assert engine.drawing_area() == (0.0, 0.0, 400.0, 200.0)
|
|
assert engine.usable_area() == (400 * 0.96, 200 * 0.96)
|
|
# 콘텐츠 중심(500, 500) 이 작도 영역 중심(200, 100) 에 온다 — 이동량 (300, 400).
|
|
placed = engine.frame_entities("t", (490.0, 490.0, 510.0, 510.0), fit=False)
|
|
assert placed[0]["shapeData"]["startPoint"] == {"x": 300.0, "y": 400.0}
|
|
finally:
|
|
engine.use_company_templates(None)
|
|
|
|
|
|
def test_bad_area_falls_back(tmp_path):
|
|
_company_template(tmp_path, {"drawing_area": [10, 10, 5, 5], "entities": []})
|
|
engine.use_company_templates(tmp_path)
|
|
try:
|
|
assert engine.drawing_area() == engine._A1_INNER
|
|
finally:
|
|
engine.use_company_templates(None)
|
|
|
|
|
|
def test_save_keeps_area(tmp_path):
|
|
# 편집본(CAD)에는 작도 영역 칸이 없다 — 저장이 시스템 양식 값을 이어 받는다.
|
|
path = engine.save_company_template(tmp_path, [])
|
|
assert json.loads(path.read_text(encoding="utf-8"))["drawing_area"] == [42, 47, 812, 567]
|