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

larva decorating from larva filter

parent 89ae3cb0
No related branches found
No related tags found
1 merge request!15Set of commits to be tagged v0.17
Pipeline #117213 passed
...@@ -158,6 +158,7 @@ function timecontroller(times::Vector{Float64}; speed=1.0) ...@@ -158,6 +158,7 @@ function timecontroller(times::Vector{Float64}; speed=1.0)
stepmin = Observable(1) stepmin = Observable(1)
stepmax = Observable(nsteps) stepmax = Observable(nsteps)
boundreached = Observable(true) boundreached = Observable(true)
initialized = Ref(false) # useful for skipping a "Time bound reached" message at startup
# #
on(timestep) do step on(timestep) do step
min, max = stepmin[], stepmax[] min, max = stepmin[], stepmax[]
...@@ -177,7 +178,8 @@ function timecontroller(times::Vector{Float64}; speed=1.0) ...@@ -177,7 +178,8 @@ function timecontroller(times::Vector{Float64}; speed=1.0)
end end
end end
on(boundreached) do b on(boundreached) do b
b && @info "Time bound reached" b && initialized[] && @info "Time bound reached"
initialized[] = true
end end
on(stepmin) do bound on(stepmin) do bound
0 < bound || throw(DomainError("stepmin < 1")) 0 < bound || throw(DomainError("stepmin < 1"))
......
...@@ -528,13 +528,7 @@ function Makie.plot!(plot::LarvaPlot{Tuple{DecoratedLarva}}) ...@@ -528,13 +528,7 @@ function Makie.plot!(plot::LarvaPlot{Tuple{DecoratedLarva}})
# decoration # decoration
p = Makie.Point2f coordinates p = Makie.Point2f coordinates
outline = p.(Vector(vertices(decoratedlarva.activearea))) outline = p.(Vector(vertices(decoratedlarva.activearea)))
# TODO: design a more systematic way to prevent path closing of spine, i.e. when outline close!(path) = push!(path, path[1])
# data is not available and `outline` is actually a spine
close!(path) = if 7 < length(path)
push!(path, path[1])
else
path
end
lines!(plot, close!(outline); lines!(plot, close!(outline);
color=theme[:DecoratedLarva][:hover_color], color=theme[:DecoratedLarva][:hover_color],
linewidth=theme[:DecoratedLarva][:hover_linewidth], linewidth=theme[:DecoratedLarva][:hover_linewidth],
...@@ -599,7 +593,7 @@ function DecoratedLarvae(larvae::Vector{DecoratedLarva}) ...@@ -599,7 +593,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) - please file an issue at https://gitlab.pasteur.fr/nyx/larvatagger.jl/-/issues" "Cannot decorate invisible larva #$(j_id)"
end end
hovered_larva.val = 0 hovered_larva.val = 0
end end
......
...@@ -118,6 +118,7 @@ struct AssayPlot ...@@ -118,6 +118,7 @@ struct AssayPlot
end end
function AssayPlot(ctrl, larvae::DecoratedLarvae; size=FIGSIZE) function AssayPlot(ctrl, larvae::DecoratedLarvae; size=FIGSIZE)
gethub(ctrl)[:decoratedlarvae] = larvae
fig = Figure(resolution=size) fig = Figure(resolution=size)
width = 0.1f0 # try to get 1px width = 0.1f0 # try to get 1px
color = RGBAf(0, 0, 0, 0.36) color = RGBAf(0, 0, 0, 0.36)
...@@ -448,14 +449,41 @@ end ...@@ -448,14 +449,41 @@ end
struct LarvaInfo struct LarvaInfo
controller controller
id::LarvaID id::LarvaID
hovered::AbstractObservable{Bool}
reviewed::AbstractObservable{Bool} reviewed::AbstractObservable{Bool}
edited::AbstractObservable{Bool} edited::AbstractObservable{Bool}
included::AbstractObservable{Bool} included::AbstractObservable{Bool}
end end
function larvainfo(controller, id) function larvainfo(controller, id)
hovered = Observable(false)
reviewed = Observable(false) reviewed = Observable(false)
edited = Observable(false) edited = Observable(false)
#
larvae = gethub(controller)[:decoratedlarvae]
larvaindex = nothing
for (i, larva) in enumerate(larvae.larvae)
larva = larva.larva
if larva.model.id == id
larvaindex = i
end
end
larvavisible = larvae.larvae[larvaindex].larva.visible
on(hovered) do b
if larvae.hovering_active[]
if b
if larvavisible[]
larvae.hovered_larva[] = larvaindex
end
else
i = larvae.hovered_larva[]
if i != 0
i == larvaindex || @warn "Larva #$(larvae.larvae[i].larva.model.id) unexpectedly decorated"
larvae.hovered_larva[] = 0
end
end
end
end
on(edited) do b on(edited) do b
if b if b
#@assert reviewed[] #@assert reviewed[]
...@@ -474,6 +502,7 @@ function larvainfo(controller, id) ...@@ -474,6 +502,7 @@ function larvainfo(controller, id)
included = Observable(false) included = Observable(false)
LarvaInfo(controller, LarvaInfo(controller,
id, id,
hovered,
reviewed, reviewed,
edited, edited,
included) included)
...@@ -482,7 +511,9 @@ end ...@@ -482,7 +511,9 @@ end
JSServe.jsrender(session::Session, li::LarvaInfo) = r(session, prerender(li)) JSServe.jsrender(session::Session, li::LarvaInfo) = r(session, prerender(li))
function prerender(li::LarvaInfo) function prerender(li::LarvaInfo)
label = "#$(li.id)" label = DOM.label("#$(li.id)",
onmouseenter=js"JSServe.update_obs($(li.hovered), true)",
onmouseleave=js"JSServe.update_obs($(li.hovered), false)")
discard_larva_edits = js"LarvaTagger.discardLarvaEdits(this, $(li.edited), $label)" discard_larva_edits = js"LarvaTagger.discardLarvaEdits(this, $(li.edited), $label)"
reviewed_checkbox = DOM.input(type="checkbox", reviewed_checkbox = DOM.input(type="checkbox",
checked=li.reviewed, checked=li.reviewed,
......
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