Skip to content

Commit

Permalink
Adaptations for removal of AbstractPlotting, see
Browse files Browse the repository at this point in the history
  • Loading branch information
j-fu committed May 20, 2021
1 parent af75993 commit 1eecd52
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 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.2.4"
version = "0.2.5"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions src/flippablelayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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[])
Expand All @@ -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
Expand Down
28 changes: 19 additions & 9 deletions src/makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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_installed<version_min
error("Outdated version $(version_installed) of AbstractPlotting. Please upgrade to at least $(version_min)")
error("Outdated version $(version_installed) of Makie. Please upgrade to at least $(version_min)")
end

if version_installed>version_max
@warn("Possibly breaking version $(version_installed) of AbstractPlotting.")
@warn("Possibly breaking version $(version_installed) of Makie.")
end

# Prepare flippable layout
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

2 comments on commit 1eecd52

@j-fu
Copy link
Member Author

@j-fu j-fu commented on 1eecd52 May 20, 2021

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/37149

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.2.5 -m "<description of version>" 1eecd5251e80c5e3c062fef3db4a5fc95d127523
git push origin v0.2.5

Please sign in to comment.