Skip to content
Snippets Groups Projects
Commit cc58a842 authored by François  LAURENT's avatar François LAURENT
Browse files

largely improves #20

parent 045ffe55
No related branches found
No related tags found
No related merge requests found
Pipeline #82933 passed
...@@ -145,7 +145,7 @@ function SingleLarvaView(larvae::Vector{LarvaModel}, controller; editabletags::B ...@@ -145,7 +145,7 @@ function SingleLarvaView(larvae::Vector{LarvaModel}, controller; editabletags::B
# TODO: move the callbacks to `plot!` # TODO: move the callbacks to `plot!`
# callbacks # callbacks
on(async_latest(getactivelarva(controller))) do id on(getactivelarva(controller)) do id
if isnothing(id) if isnothing(id)
visible[] = false visible[] = false
else else
...@@ -184,8 +184,7 @@ function SingleLarvaView(larvae::Vector{LarvaModel}, controller; editabletags::B ...@@ -184,8 +184,7 @@ function SingleLarvaView(larvae::Vector{LarvaModel}, controller; editabletags::B
) do larva, timestep, tag_lut, usertags ) do larva, timestep, tag_lut, usertags
first_timestep = larva.alignedsteps[1] first_timestep = larva.alignedsteps[1]
last_timestep = larva.alignedsteps[end] last_timestep = larva.alignedsteps[end]
if (first_timestep<=timestep && if (first_timestep <= timestep <= last_timestep &&
timestep<=last_timestep &&
getactivelarva(controller)[] == model[].id getactivelarva(controller)[] == model[].id
) )
step = timestep - first_timestep + 1 step = timestep - first_timestep + 1
...@@ -514,7 +513,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva}) ...@@ -514,7 +513,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva})
@assert hovering_active[] @assert hovering_active[]
i = current_larva[] i = current_larva[]
if i == j if i == j
@warn "moving too fast?" @warn "moving too fast? - please file an issue at https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/issues"
end end
if 0 < i if 0 < i
i_decorated = larvae[i].decorated i_decorated = larvae[i].decorated
...@@ -523,7 +522,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva}) ...@@ -523,7 +522,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva})
else else
@warn begin @warn begin
i_id = larvae[i].larva.model.id i_id = larvae[i].larva.model.id
"larva #$(i_id)'s decorations already removed" "Larva #$(i_id)'s decorations already removed"
end end
end end
end end
...@@ -534,7 +533,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva}) ...@@ -534,7 +533,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva})
else else
@error begin @error begin
j_id = larvae[j].larva.model.id j_id = larvae[j].larva.model.id
"cannot decorate invisible larva #$(j_id)" "cannot decorate invisible larva #$(j_id) - please file an issue at https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/issues"
end end
hovered_larva.val = 0 hovered_larva.val = 0
end end
...@@ -570,6 +569,7 @@ function Makie.plot!(plot::LarvaPlot{Tuple{DecoratedLarvae}}) ...@@ -570,6 +569,7 @@ function Makie.plot!(plot::LarvaPlot{Tuple{DecoratedLarvae}})
if content.hovering_active[] if content.hovering_active[]
#pos = Makie.to_world(scene, Makie.screen_relative(scene, mp)) #pos = Makie.to_world(scene, Makie.screen_relative(scene, mp))
pos = mouseposition(scene) pos = mouseposition(scene)
# both `find` and `hovered_larva` return larva indices (not IDs)
larva = find(content, pos) larva = find(content, pos)
if larva != content.hovered_larva[] if larva != content.hovered_larva[]
content.hovered_larva[] = larva content.hovered_larva[] = larva
...@@ -584,7 +584,7 @@ Meshes.boundingbox(larva::DecoratedLarva) = Meshes.boundingbox(larva.larva) ...@@ -584,7 +584,7 @@ Meshes.boundingbox(larva::DecoratedLarva) = Meshes.boundingbox(larva.larva)
Meshes.boundingbox(larvae::DecoratedLarvae) = Meshes.boundingbox(map(Meshes.boundingbox, larvae.larvae)) Meshes.boundingbox(larvae::DecoratedLarvae) = Meshes.boundingbox(map(Meshes.boundingbox, larvae.larvae))
function setmouseevents!(scene, plot::DecoratedLarvae, ctrl; consume=false) function setmouseevents!(scene, plot::DecoratedLarvae, ctrl; consume=false)
on(async_latest(events(scene).mousebutton)) do mb on(events(scene).mousebutton) do mb
consumed = consume consumed = consume
if mb.button == Mouse.left && mb.action == Mouse.release if mb.button == Mouse.left && mb.action == Mouse.release
larva_ix = plot.hovered_larva[] larva_ix = plot.hovered_larva[]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment