Skip to content

Commit e1aa9f9

Browse files
fix(preview): adjust figure padding and size calculations to avoid image cropping
1 parent eeb34de commit e1aa9f9

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/datamodel/preview.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,9 @@ function preview(design::CableDesign;
401401
backgroundcolor = (_is_static_backend() ? :white : :gray90)
402402
set_theme!(backgroundcolor = backgroundcolor)
403403

404-
fig = isnothing(axis) ? Makie.Figure(size = size) : nothing
404+
fig =
405+
isnothing(axis) ? Makie.Figure(size = size, figure_padding = (10, 10, 10, 10)) :
406+
nothing
405407

406408
# ── 2 columns: left = main axis, right = container (button + legend + bars)
407409
local ax
@@ -415,15 +417,14 @@ function preview(design::CableDesign;
415417

416418
ax.xlabel = "y [m]"
417419
ax.ylabel = "z [m]"
418-
n = next_fignum()
419420

420421
ax.title =
421422
display_id ? "Cable design preview: $(design.cable_id)" :
422423
"Cable design preview"
423424

424425
avail_w = size[1] * (1 - side_frac)
425426
avail_h = size[2]
426-
s = floor(Int, min(avail_w, avail_h))
427+
s = floor(Int, min(avail_w, avail_h)*0.9)
427428
Makie.colsize!(fig.layout, 1, Makie.Fixed(s))
428429
Makie.rowsize!(fig.layout, 1, Makie.Fixed(s))
429430
else
@@ -595,7 +596,9 @@ function preview(system::LineCableSystem;
595596

596597
set_theme!(backgroundcolor = backgroundcolor)
597598

598-
fig = isnothing(axis) ? Makie.Figure(size = size) : nothing
599+
fig =
600+
isnothing(axis) ? Makie.Figure(size = size, figure_padding = (10, 10, 10, 10)) :
601+
nothing
599602

600603
# Layout: left = main axis, right = legend/colorbars (only if we own the axis)
601604
local ax
@@ -617,7 +620,7 @@ function preview(system::LineCableSystem;
617620
# Make the plotting canvas square if we own the axis
618621
avail_w = size[1] * (1 - side_frac)
619622
avail_h = size[2]
620-
s = floor(Int, min(avail_w, avail_h))
623+
s = floor(Int, min(avail_w, avail_h)*0.9)
621624
Makie.colsize!(fig.layout, 1, Makie.Fixed(s))
622625
Makie.rowsize!(fig.layout, 1, Makie.Fixed(s))
623626
else

0 commit comments

Comments
 (0)