add textbox for setting stepsize and some documentation

pull/3/head
Nikola Sebastian Munder 2025-06-11 11:19:59 +02:00
parent 5140a2f32c
commit d50c843709
1 changed files with 19 additions and 4 deletions

View File

@ -2,7 +2,7 @@ using GLMakie, Observables
include("../src/constants.jl")
using .Constants
# # Gray Scott Model Parameters
# Parameters and initial conditions
N = 128
dx = 1.0
@ -13,6 +13,12 @@ F, k = Observable(0.060), Observable(0.062)
dt = 1.0
params_obs = Observable(GSParams(N, dx, Du[], Dv[], F[], k[]))
# # GUI Parameters
run_label = Observable{String}("Run")
stepsize = Observable{Int}(30)
function update_params!(params_obs, u, v, feed, kill)
old = params_obs[]
params_obs[] = GSParams(old.N, old.dx, u, v, feed, kill)
@ -122,11 +128,11 @@ on(spoint) do pt
end
# # Controls
run_label = Observable("Run")
fig[2, 1] = buttongrid = GridLayout(ax.scene, tellwidth=false)
btn_step = Button(buttongrid[1, 1], width=50, label="Step")
btn_start = Button(buttongrid[1, 2], width=50, label=run_label)
btn_reset = Button(buttongrid[1, 3], width=50, label="Reset")
step_box = Textbox(buttongrid[1, 4], width=50, validator=Int, placeholder="Stepsize", stored_string="$(stepsize[])")
gh[1, 2] = textboxgrid = GridLayout(ax.scene, tellwidth=false)
rowsize!(gh, 1, Relative(1.0))
@ -164,9 +170,18 @@ on(running) do r
run_label[] = r ? "Pause" : "Run"
end
on(step_box.stored_string) do s
try
stepsize[] = parse(Int, s)
println("Changed stepsize to $s")
catch
@warn "Invalid input for $labeltxt: $s"
end
end
# Button Listeners
on(btn_step.clicks) do _
multi_step!((U, V), 30)
multi_step!((U, V), stepsize[])
end
on(btn_start.clicks) do _
@ -175,7 +190,7 @@ end
on(btn_start.clicks) do _
@async while running[]
multi_step!((U, V), 60)
multi_step!((U, V), stepsize[])
sleep(0.05) # ~20 FPS
end
end