"""이관한 표가 예전 선·문자 그림과 같은 자리를 그리는지 확인 (수동 실행).""" import sys sys.path.insert(0, ".") from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Table import ( _cross_table_entities, extract_quantity_table, QUANTITY_VALUE_KEYS, cross_table_height, cross_table_width, ) from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Basin import _info_box_entities qt = {key: float(index + 1) for index, key in enumerate(QUANTITY_VALUE_KEYS)} entities = _cross_table_entities("draw1", qt, 0.0, "No.10", center_x=0.0) assert len(entities) == 1 and entities[0]["type"] == "Table", entities shape = entities[0]["shapeData"] widths = shape["columnWidths"] heights = shape["rowHeights"] print("cross columns:", len(widths), "rows:", len(heights)) print("width:", round(sum(widths), 6), "expected:", cross_table_width()) print("height:", round(sum(heights), 6), "expected:", cross_table_height()) print("origin:", shape["origin"]) titles = [c for row in shape["cells"] for c in row if c and c.get("colSpan", 1) == len(widths)] print("title cell:", titles[0]["text"], "align", titles[0]["align"]) keyed = {c["key"]: c["text"] for row in shape["cells"] for c in row if c and c.get("key")} print("keyed cells:", len(keyed), "of", len(QUANTITY_VALUE_KEYS)) missing = [k for k in QUANTITY_VALUE_KEYS if k not in keyed and k not in ("cut", "fill")] print("missing keys:", missing) back = extract_quantity_table("draw1", {"entities": entities}) same = all( back.get(k) == qt[k] for k in QUANTITY_VALUE_KEYS if k not in ("cut", "fill") ) print("round-trip values equal:", same) box = _info_box_entities("draw1", 1, {"chainage_m": 100.0, "area_m2": 12345.0, "relief_m": 12.0, "flow_length_m": 34.0}, "#fff", (0.0, 0.0), 20.0) assert len(box) == 1 and box[0]["type"] == "Table" bs = box[0]["shapeData"] print("basin columns:", bs["columnWidths"], "rows:", len(bs["rowHeights"])) print("basin cells:", [[c["text"] if c else None for c in row] for row in bs["cells"]])