From 1eecd5251e80c5e3c062fef3db4a5fc95d127523 Mon Sep 17 00:00:00 2001 From: Juergen Fuhrmann Date: Thu, 20 May 2021 21:16:39 +0200 Subject: [PATCH] Adaptations for removal of AbstractPlotting, see https://discourse.julialang.org/t/ann-makie-v-0-13/61522 --- Project.toml | 2 +- src/dispatch.jl | 2 +- src/flippablelayout.jl | 10 ++++++++-- src/makie.jl | 28 +++++++++++++++++++--------- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Project.toml b/Project.toml index 3a4d8d6..79893eb 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GridVisualize" uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8" authors = ["Juergen Fuhrmann "] -version = "0.2.4" +version = "0.2.5" [deps] ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" diff --git a/src/dispatch.jl b/src/dispatch.jl index 569eac5..6d124d2 100644 --- a/src/dispatch.jl +++ b/src/dispatch.jl @@ -51,7 +51,7 @@ $(SIGNATURES) Heuristically check if Plotter is Makie/WGLMakie """ -ismakie(Plotter)= (typeof(Plotter)==Module)&&isdefined(Plotter,:AbstractPlotting) +ismakie(Plotter)= (typeof(Plotter)==Module)&&isdefined(Plotter,:Makie) """ $(SIGNATURES) diff --git a/src/flippablelayout.jl b/src/flippablelayout.jl index 55188d2..c73428d 100644 --- a/src/flippablelayout.jl +++ b/src/flippablelayout.jl @@ -143,7 +143,10 @@ function flayoutscene(;blocked=false, # Watch mouse position mouseposition=Makie.Node((0,0)) - Makie.on(m->mouseposition[]=m, parent.events.mouseposition) + Makie.on(parent.events.mouseposition) do m + mouseposition[]=m + false + end # Switch focus to subscene at pos function _focus(focus) @@ -180,7 +183,7 @@ function flayoutscene(;blocked=false, # Handle global key events for `,` (focus/gallery view) # and space (toggle blocking) - Makie.on(parent.events.keyboardbuttons) do buttons + Makie.on(parent.events.keyboardbutton) do buttons if Makie.ispressed(parent, focuskey) if gallery_view[] pos=_subscene(mouseposition[]) @@ -192,10 +195,13 @@ function flayoutscene(;blocked=false, _showall(flayout) gallery_view[]=true end + return true end if Makie.ispressed(parent, blockingkey) _toggle_block(flayout) + return true end + return false end parent,flayout end diff --git a/src/makie.jl b/src/makie.jl index 787de68..76ec78d 100644 --- a/src/makie.jl +++ b/src/makie.jl @@ -5,17 +5,17 @@ function initialize!(p::GridVisualizer,::Type{MakieType}) Makie=p.context[:Plotter] # Check for version compatibility - version_min=v"0.17.4" - version_max=v"0.18.99" + version_min=v"0.13" + version_max=v"0.13.99" - version_installed=PkgVersion.Version(Makie.AbstractPlotting) + version_installed=PkgVersion.Version(Makie.Makie) if version_installedversion_max - @warn("Possibly breaking version $(version_installed) of AbstractPlotting.") + @warn("Possibly breaking version $(version_installed) of Makie.") end # Prepare flippable layout @@ -92,31 +92,41 @@ function scene_interaction(update_scene,scene,Makie,switchkeys::Vector{Symbol}=[ # Handle mouse position within scene mouseposition=Makie.Node((0,0)) - Makie.on(m->mouseposition[]=m, scene.events.mouseposition) + + Makie.on(scene.events.mouseposition) do m + mouseposition[]=m + false + end + # Set keyboard event callback - Makie.on(scene.events.keyboardbuttons) do buttons + Makie.on(scene.events.keyboardbutton) do buttons if _inscene(scene,mouseposition[]) # On pressing a switch key, pass control for i=1:length(switchkeys) if switchkeys[i]!=:nothing && Makie.ispressed(scene,getproperty(Makie.Keyboard,switchkeys[i])) activeswitch[]=switchkeys[i] update_scene(0,switchkeys[i]) - return + return true end end # Handle change values via up/down control if Makie.ispressed(scene, Makie.Keyboard.up) update_scene(1,activeswitch[]) + return true elseif Makie.ispressed(scene, Makie.Keyboard.down) update_scene(-1,activeswitch[]) + return true elseif Makie.ispressed(scene, Makie.Keyboard.page_up) update_scene(10,activeswitch[]) + return true elseif Makie.ispressed(scene, Makie.Keyboard.page_down) update_scene(-10,activeswitch[]) + return true end end + return false end end @@ -811,7 +821,7 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid , func) make_mesh(pts,fcs)=Mesh(pts,fcs) function make_mesh(pts,fcs,vals) - colors = Makie.AbstractPlotting.interpolated_getindex.((cmap,), vals, (fminmax,)) + colors = Makie.Makie.interpolated_getindex.((cmap,), vals, (fminmax,)) GeometryBasics.Mesh(meta(pts, color=colors,normals=normals(pts, fcs)), fcs) end