Merge pull request #233 from Jud/fix/board-view-frame-to-board
fix(board-view): frame get_board_2d_view to the board, not the A4 sheet
This commit is contained in:
@@ -198,6 +198,14 @@ class BoardViewCommands:
|
||||
output_svg,
|
||||
"--mode-single",
|
||||
"--black-and-white",
|
||||
# Render the board, not the drawing sheet. kicad-cli's
|
||||
# default (page-size-mode 0) plots only the area inside the
|
||||
# sheet, so board geometry past the page edge is left out.
|
||||
# Mode 2 sizes the output to the board's bounding box;
|
||||
# --exclude-drawing-sheet drops the title block.
|
||||
"--exclude-drawing-sheet",
|
||||
"--page-size-mode",
|
||||
"2",
|
||||
]
|
||||
if layers:
|
||||
cmd += ["--layers", ",".join(layers)]
|
||||
|
||||
@@ -79,6 +79,19 @@ def test_inline_png_returns_base64_image_data(tmp_path):
|
||||
assert "filePath" not in result
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_export_frames_to_board_area(tmp_path):
|
||||
"""The export drops the drawing sheet and crops to the board area, so a small
|
||||
board isn't rendered on a mostly-empty A4 page (kicad-cli's default)."""
|
||||
cmd, root, board_path = _make_view_cmd(tmp_path)
|
||||
w1, w2, w3 = _patch_kicad_cli(root)
|
||||
with w1, w2 as run, w3, patch("commands.board.view._svg_to_png", return_value=_FAKE_PNG):
|
||||
cmd.get_board_2d_view({"pcbPath": str(board_path), "format": "png"})
|
||||
argv = run.call_args[0][0]
|
||||
assert "--exclude-drawing-sheet" in argv
|
||||
assert argv[argv.index("--page-size-mode") + 1] == "2"
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_inline_svg_returns_base64_image_data(tmp_path):
|
||||
"""responseMode='inline' with format='svg' returns base64-encoded SVG in imageData."""
|
||||
|
||||
Reference in New Issue
Block a user