From d50c8437095797e094f4fcd4c401b3c6fc76c6da Mon Sep 17 00:00:00 2001 From: Niki Laptop <2212719@stud.hs-mannheim.de> Date: Wed, 11 Jun 2025 11:19:59 +0200 Subject: [PATCH] add textbox for setting stepsize and some documentation --- scripts/run_simulation.jl | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/scripts/run_simulation.jl b/scripts/run_simulation.jl index 99c13a4..effc9a6 100644 --- a/scripts/run_simulation.jl +++ b/scripts/run_simulation.jl @@ -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