diff --git a/B07_DesignDetail/B07_DesignDetail_Engine_Cad_PlanKinds.py b/B07_DesignDetail/B07_DesignDetail_Engine_Cad_PlanKinds.py index e3058d46a..25d6bbc54 100644 --- a/B07_DesignDetail/B07_DesignDetail_Engine_Cad_PlanKinds.py +++ b/B07_DesignDetail/B07_DesignDetail_Engine_Cad_PlanKinds.py @@ -146,6 +146,8 @@ _COLORS = { "emd": "#2f7d4f", "sgg": "#a63d3d", } +# 글 · 지시선만 조각 색과 다름 — IP 글 = 기준 형상(노선 중심선) 색(153-2) +_TEXT_COLORS = {"ip": _COLORS["centerline"]} # 행정 · 지적 경계 (선굵기, 파선) _BOUNDARY_STYLE: dict[str, tuple[int, list[int] | None]] = { "parcel": (1, None), @@ -274,7 +276,7 @@ def _piece_entities( "label": label, "size": size, "layer": layer, - "color": color, + "color": _TEXT_COLORS.get(piece, color), "anchor": anchor, "candidates": spots, } diff --git a/resources/tester/test_141_b07_plan_labels.py b/resources/tester/test_141_b07_plan_labels.py index 6e9c426f1..c57df105f 100644 --- a/resources/tester/test_141_b07_plan_labels.py +++ b/resources/tester/test_141_b07_plan_labels.py @@ -152,3 +152,32 @@ def test_blocked_spots_push_farther_with_leader() -> None: entities = label_entities("d", placed) assert [e["type"] for e in entities] == ["Text", "Text", "PolyLine"] + + +def test_ip_text_takes_centerline_color() -> None: + """153-2 — IP 글 · 지시선 = 노선 중심선 색 · 교각선 · 원 · R 글은 조각 색 그대로.""" + from B07_DesignDetail.B07_DesignDetail_Engine_Cad_PlanKinds import _COLORS, _piece_entities + from B07_DesignDetail.B07_DesignDetail_Engine_Cad_PlanLabels import label_entities + + item = {"name": "IP1", "apex": [100.0, 100.0], "start": [90.0, 100.0], "end": [100.0, 110.0]} + pieces = { + "ip": {"items": [item]}, + "radius": {"items": [{"label": "R=12", "middle": [100.0, 98.0], "dir": [0.0, -1.0]}]}, + } + drawing = build_plan_kind_drawing("plan_x", "시험", (0.0, 0.0, 300.0, 200.0), pieces) + texts = {e["shapeData"]["label"]: e for e in _texts(drawing)} + ip_text = texts["IP1"] + assert ip_text["lineColor"] == _COLORS["centerline"] + assert ip_text["shapeData"]["options"]["textColor"] == _COLORS["centerline"] + assert texts["R=12"]["shapeData"]["options"]["textColor"] == _COLORS["radius"] + marks = [ + e for e in drawing["entities"] if e["layerId"] == "b07-plan-ip" and e["type"] == "PolyLine" + ] + assert len(marks) == 2 # 교각선 · 원 + assert {e["lineColor"] for e in marks} == {_COLORS["ip"]} + + labels: list = [] + _piece_entities("d", "ip", {"items": [item]}, lambda p: (p[0], p[1]), labels=labels) + far = [{**labels[0], "spot": {"x": 0.0, "y": 0.0, "far": True}, "rect": (0, 0, 1, 1)}] + leader = label_entities("d", far)[1] + assert leader["lineColor"] == _COLORS["centerline"]