Skip to content

Commit

Permalink
Update to Makie.jl v0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Nov 22, 2023
1 parent 37d7c66 commit c482118
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Bessels = "0.2"
CircularArrays = "1.3"
Distances = "0.10"
LinearAlgebra = "1.9"
Makie = "0.19"
Makie = "0.20"
NearestNeighbors = "0.4"
Random = "1.9"
Rotations = "1.5.1"
Expand Down
14 changes: 7 additions & 7 deletions ext/geometryset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function Makie.plot!(plot::Viz{<:Tuple{GeometrySet}})
color = plot[:color]
alpha = plot[:alpha]
colorscheme = plot[:colorscheme]
facetcolor = plot[:facetcolor]
showfacets = plot[:showfacets]
pointsize = plot[:pointsize]
segmentsize = plot[:segmentsize]
showfacets = plot[:showfacets]
facetcolor = plot[:facetcolor]

# process color spec into colorant
colorant = Makie.@lift process($color, $colorscheme, $alpha)
Expand Down Expand Up @@ -41,10 +41,10 @@ function Makie.plot!(plot::Viz{<:Tuple{GeometrySet}})
inds = Makie.@lift findall(g -> paramdim(g) == rank, $geoms)
if !isempty(inds[])
rset = Makie.@lift GeometrySet($geoms[$inds])
if colorant[] isa AbstractVector
cset = Makie.@lift $colorant[$inds]
cset = if colorant[] isa AbstractVector
Makie.@lift $colorant[$inds]
else
cset = colorant
colorant
end
viz!(plot, rset, color=cset)
end
Expand All @@ -58,10 +58,10 @@ function Makie.plot!(plot::Viz{<:Tuple{GeometrySet}})
elseif all(ranks[] .== 1)
# all boundaries are point sets
points = Makie.@lift mapreduce(collect, vcat, $bounds)
viz!(plot, (Makie.@lift GeometrySet($points)), color=facetcolor, showfacets=false, pointsize=pointsize)
viz!(plot, (Makie.@lift GeometrySet($points)), color=facetcolor, pointsize=pointsize)
elseif all(ranks[] .== 2)
# all boundaries are geometries
viz!(plot, (Makie.@lift GeometrySet($bounds)), color=facetcolor, showfacets=false, segmentsize=segmentsize)
viz!(plot, (Makie.@lift GeometrySet($bounds)), color=facetcolor, segmentsize=segmentsize)
elseif all(ranks[] .== 3)
# we already visualized the boundaries because
# that is all we can do with 3D geometries
Expand Down
6 changes: 3 additions & 3 deletions ext/optimized.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ function Makie.plot!(plot::Viz{<:Tuple{SubCartesianGrid}})
# retrieve grid paramaters
gparams = Makie.@lift let
grid, _ = unview($subgrid)
dims = embeddim(grid)
dim = embeddim(grid)
sp = spacing(grid)

# coordinates of centroids
coord(e) = coordinates(centroid(e))
coords = [coord(e) .+ sp ./ 2 for e in $subgrid]

# rectangle marker
marker = Makie.Rect{dims}(-1 .* sp, sp)
marker = Makie.Rect{dim}(-1 .* sp, sp)

# enable shading in 3D
shading = dims == 3
shading = dim == 3 ? Makie.FastShading : Makie.NoShading

coords, marker, shading
end
Expand Down
6 changes: 3 additions & 3 deletions ext/simplemesh.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ function vizmesh2D!(plot)
color = plot[:color]
alpha = plot[:alpha]
colorscheme = plot[:colorscheme]
facetcolor = plot[:facetcolor]
showfacets = plot[:showfacets]
segmentsize = plot[:segmentsize]
showfacets = plot[:showfacets]
facetcolor = plot[:facetcolor]

# process color spec into colorant
colorant = Makie.@lift process($color, $colorscheme, $alpha)
Expand Down Expand Up @@ -136,7 +136,7 @@ function vizmesh2D!(plot)
tmatrix = reduce(hcat, tconnec) |> transpose

# enable shading in 3D
tshading = dim == 3
tshading = dim == 3 ? Makie.FastShading : Makie.NoShading

tcoords, tmatrix, tcolors, tshading
end
Expand Down
7 changes: 5 additions & 2 deletions ext/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function vizmany!(plot, objs)
colorscheme = plot[:colorscheme]
pointsize = plot[:pointsize]
segmentsize = plot[:segmentsize]
showfacets = plot[:showfacets]
facetcolor = plot[:facetcolor]

object = Makie.@lift reduce(concat, $objs)
colors = Makie.@lift mayberepeat($color, $objs)
Expand All @@ -27,8 +29,9 @@ function vizmany!(plot, objs)
color=colors,
alpha=alphas,
colorscheme=colorscheme,
showfacets=false,
pointsize=pointsize,
segmentsize=segmentsize
segmentsize=segmentsize,
showfacets=showfacets,
facetcolor=facetcolor
)
end

0 comments on commit c482118

Please sign in to comment.