Skip to content

Commit

Permalink
Require Makie 0.16 (Node->Observable switch)
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed Jan 29, 2022
1 parent 3af864a commit aff6d1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GridVisualize"
uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8"
authors = ["Juergen Fuhrmann <[email protected]>"]
version = "0.4.7"
version = "0.5.0"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Expand Down
5 changes: 3 additions & 2 deletions src/flippablelayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ As a consequence, we can't use Makie types at compile time.
"""
module FlippableLayout
using DocStringExtensions
using Observables


Makie=nothing
Expand Down Expand Up @@ -138,10 +139,10 @@ function flayoutscene(;blocked=false,

flayout=FLayout(layout,blocked=blocked)

gallery_view=Makie.Node(true)
gallery_view=Observable(true)

# Watch mouse position
mouseposition=Makie.Node((0.0,0.0))
mouseposition=Observable((0.0,0.0))

Makie.on(parent.events.mouseposition) do m
mouseposition[]=m
Expand Down
34 changes: 17 additions & 17 deletions src/makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function initialize!(p::GridVisualizer,::Type{MakieType})
Makie=p.context[:Plotter]

# Check for version compatibility
version_min=v"0.15"
version_max=v"0.15.99"
version_min=v"0.16"
version_max=v"0.16.99"

version_installed=PkgVersion.Version(Makie.Makie)

Expand Down Expand Up @@ -91,10 +91,10 @@ function scene_interaction(update_scene,scene,Makie,switchkeys::Vector{Symbol}=[
end

# Initial active switch key is the first in the vector passed
activeswitch=Makie.Node(switchkeys[1])
activeswitch=Observable(switchkeys[1])

# Handle mouse position within scene
mouseposition=Makie.Node((0.0,0.0))
mouseposition=Observable((0.0,0.0))


Makie.on(scene.events.mouseposition) do m
Expand Down Expand Up @@ -221,7 +221,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid)
title=ctx[:title],
scenekwargs(ctx)...)

ctx[:grid]=Makie.Node(grid)
ctx[:grid]=Observable(grid)
cmap=region_cmap(nregions)
bcmap=bregion_cmap(nbregions)

Expand Down Expand Up @@ -372,7 +372,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid,func)

if !haskey(ctx,:scene)

ctx[:xtitle]=Makie.Node(ctx[:title])
ctx[:xtitle]=Observable(ctx[:title])

# Axis
ctx[:scene]=Makie.Axis(ctx[:figure];
Expand All @@ -390,7 +390,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid,func)

# ctx[:lines] is an array of lines to draw
# Here, we start just with the first one.
ctx[:lines]=[Makie.Node(polyline(grid,func))]
ctx[:lines]=[Observable(polyline(grid,func))]

update_lines(ctx)

Expand All @@ -415,7 +415,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{1}}, grid,func)
if ctx[:nlines]<=length(ctx[:lines])
ctx[:lines][ctx[:nlines]][]=p
else
push!(ctx[:lines],Makie.Node(p))
push!(ctx[:lines],Observable(p))
update_lines(ctx)
end

Expand Down Expand Up @@ -452,7 +452,7 @@ end


# Put all data which could be updated in to one plot.
set_plot_data!(ctx,m,key,data) = haskey(ctx,key) ? ctx[key][]=data : ctx[key]=m.Node(data)
set_plot_data!(ctx,key,data) = haskey(ctx,key) ? ctx[key][]=data : ctx[key]=Observable(data)



Expand All @@ -465,7 +465,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}},grid)

nbregions=num_bfaceregions(grid)

set_plot_data!(ctx,Makie,:grid,grid)
set_plot_data!(ctx,:grid,grid)

if !haskey(ctx,:gridplot)

Expand All @@ -476,7 +476,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}},grid)
makie_aspect=1.0/(data_aspect*ctx[:aspect])
ctx[:scene]=Makie.Axis(ctx[:figure];
title=ctx[:title],
aspect=Makie.makie_aspect,
aspect=makie_aspect,
scenekwargs(ctx)...)
end

Expand Down Expand Up @@ -561,7 +561,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}},grid, func)



set_plot_data!(ctx,Makie,:contourdata,(g=grid,f=func,e=ctx[:elevation],t=ctx[:title],l=levels,c=crange))
set_plot_data!(ctx,:contourdata,(g=grid,f=func,e=ctx[:elevation],t=ctx[:title],l=levels,c=crange))

if !haskey(ctx,:contourplot)
if !haskey(ctx,:scene)
Expand Down Expand Up @@ -604,7 +604,7 @@ function vectorplot!(ctx, TP::Type{MakieType}, ::Type{Val{2}},grid, func)
qc,qv=quiverdata(rc,rv;vscale=ctx[:vscale],vnormalize=ctx[:vnormalize])


set_plot_data!(ctx,Makie,:arrowdata,(qc=qc,qv=qv))
set_plot_data!(ctx,:arrowdata,(qc=qc,qv=qv))

if !haskey(ctx,:arrowplot)
if !haskey(ctx,:scene)
Expand Down Expand Up @@ -750,7 +750,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid)

if !haskey(ctx,:scene)

ctx[:data]=Makie.Node((g=grid,x=ctx[:xplanes][1],y=ctx[:yplanes][1],z=ctx[:zplanes][1],t=ctx[:title]))
ctx[:data]=Observable((g=grid,x=ctx[:xplanes][1],y=ctx[:yplanes][1],z=ctx[:zplanes][1],t=ctx[:title]))

ctx[:scene]=makeaxis3d(ctx)

Expand Down Expand Up @@ -851,7 +851,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid)
ctx[:data][]=(g=grid,x=ctx[:xplanes][1],y=ctx[:yplanes][1],z=ctx[:zplanes][1],t=ctx[:title])
end

ctx[:status]=Makie.Node(" ")
ctx[:status]=Observable(" ")

add_scene!(ctx,makescene3d(ctx))

Expand Down Expand Up @@ -923,7 +923,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid , func)

if !haskey(ctx,:scene)

ctx[:data]=Makie.Node((g=grid,f=func,x=ctx[:xplanes],y=ctx[:yplanes],z=ctx[:zplanes],l=ctx[:levels],t=ctx[:title]))
ctx[:data]=Observable((g=grid,f=func,x=ctx[:xplanes],y=ctx[:yplanes],z=ctx[:zplanes],l=ctx[:levels],t=ctx[:title]))

ctx[:scene]=makeaxis3d(ctx)

Expand Down Expand Up @@ -980,7 +980,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid , func)
# adjust_planes()
ctx[:data][]=(g=grid,f=func,x=ctx[:xplanes],y=ctx[:yplanes],z=ctx[:zplanes],l=ctx[:levels],t=ctx[:title])
end
ctx[:status]=Makie.Node(" ")
ctx[:status]=Observable(" ")
add_scene!(ctx,makescene3d(ctx))
else
ctx[:data][]=(g=grid,f=func,x=ctx[:xplanes],y=ctx[:yplanes],z=ctx[:zplanes],l=ctx[:levels],t=ctx[:title])
Expand Down

2 comments on commit aff6d1e

@j-fu
Copy link
Member Author

@j-fu j-fu commented on aff6d1e Jan 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/53453

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.0 -m "<description of version>" aff6d1ee9c1baed076fe6ba64538ef048c62e99d
git push origin v0.5.0

Please sign in to comment.