From 951f9281a54d98926aedfb52f94803a7506385b9 Mon Sep 17 00:00:00 2001 From: Niki Laptop <2212719@stud.hs-mannheim.de> Date: Mon, 9 Jun 2025 12:49:50 +0200 Subject: [PATCH] remove stop button, and replace with start/pause combined into one button --- scripts/run_simulation.jl | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/scripts/run_simulation.jl b/scripts/run_simulation.jl index 8bd6c69..af80c61 100644 --- a/scripts/run_simulation.jl +++ b/scripts/run_simulation.jl @@ -88,12 +88,11 @@ hm = Makie.heatmap!(ax, heat_obs, colormap=:viridis) ax.aspect = DataAspect() # # Controls - +run_label = Observable("Run") fig[2, 1] = buttongrid = GridLayout(tellwidth=false) btn_step = Button(buttongrid[1, 1], label="Step") -btn_start = Button(buttongrid[1, 2], label="Start") -btn_stop = Button(buttongrid[1, 3], label="Stop") -btn_reset = Button(buttongrid[1, 4], label="Reset") +btn_start = Button(buttongrid[1, 2], width=50, label=run_label) +btn_reset = Button(buttongrid[1, 3], label="Reset") gh[1, 2] = textboxgrid = GridLayout(tellwidth=false) rowsize!(gh, 1, Relative(1.0)) @@ -134,29 +133,24 @@ function animation_loop() sleep(0.05) # ~20 FPS end end -on(box_u.stored_string) do s - try - Du[] = parse(Float64, s) - println("Change Du ", Du[]) - catch - @warn "Invalid input for Du: $s" + +on(running) do r + run_label[] = r ? "Pause" : "Run" end -end + on(btn_step.clicks) do _ multi_step!((U, V), 30) end - on(btn_start.clicks) do _ - if !running[] - running[] = true - @async animation_loop() + running[] = !running[] +end +on(btn_start.clicks) do _ + @async while running[] + animation_loop() end end -on(btn_stop.clicks) do _ - running[] = false -end on(btn_reset.clicks) do _ running[] = false