From f39c85a0adc4eb3537217db7471ccfa909c45226 Mon Sep 17 00:00:00 2001 From: Nikola <2212719@stud.hs-mannheim.de> Date: Thu, 12 Jun 2025 18:22:55 +0200 Subject: [PATCH] add functionality to add concentration at clickend spots dynamically --- src/visualization.jl | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/visualization.jl b/src/visualization.jl index ec4e778..7d1a066 100644 --- a/src/visualization.jl +++ b/src/visualization.jl @@ -76,6 +76,8 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs) run_label = Observable{String}("Run") stepsize = Observable(30) + spoint = select_point(ax.scene) + # # Controls fig[2, 1] = buttongrid = GridLayout(ax.scene, tellwidth=false) btn_step = Button(buttongrid[1, 1], width=50, label="Step") @@ -130,6 +132,27 @@ function build_ui(U, V, Du, Dv, F, k, params_obs, heat_obs) reset!(U, V, heat_obs) end + on(spoint) do pt + r = 5 + if pt === nothing + return + end + x, y = pt + println("params_obs[].N, ", params_obs[].N) + i, j = coord_to_index(x, y, params_obs[].N) + + # get corners of square that will get filled with concentration + imin = max(i - r, 1) + imax = min(i + r, params_obs[].N) + jmin = max(j - r, 1) + jmax = min(j + r, params_obs[].N) + + # set disbalanced concentration of U and V + U[imin:imax, jmin:jmax] .= 0.5 + V[imin:imax, jmin:jmax] .= 0.25 + + heat_obs[] = copy(U) + end return fig end