Skip to content

Commit

Permalink
Update Makie recipe.
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion committed Dec 4, 2024
1 parent 06b25d9 commit 085eb26
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LazIO"
uuid = "c3605908-9f0f-11e8-0a72-0d361c15a277"
authors = ["Maarten Pronk <[email protected]>"]
version = "0.4.4"
version = "0.4.5"

[deps]
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
Expand Down
36 changes: 31 additions & 5 deletions ext/MakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@ module MakieExt
using LazIO: Dataset, Point
import Makie

# Workaround Makie bug #4644
Makie.plottype(::AbstractVector{<:Point}) = Makie.Plot{Makie.plot}

Makie.preferred_axis_type(plot::Makie.Plot(AbstractVector{<:Point})) = Makie.LScene
Makie.preferred_axis_type(plot::Makie.Plot(Dataset)) = Makie.LScene
Makie.used_attributes(::Type{<:Makie.Scatter}, ::Dataset) = (:max_points,)

function Makie.convert_arguments(p::Type{<:Makie.Scatter}, geoms::AbstractVector{<:Point})
Makie.convert_arguments(p, [geom.geometry for geom in geoms])
Makie.used_attributes(::Type{<:Makie.Scatter}, ::Dataset) = (:zscale,)
Makie.used_attributes(::Type{<:Makie.Scatter}, ::AbstractVector{<:Point}) = (:zscale,)


function Makie.convert_arguments(p::Type{<:Makie.Scatter}, geoms::AbstractVector{<:Point}; zscale=1, kwargs...)
Makie.convert_arguments(p, [geom.geometry .* (1, 1, zscale) for geom in geoms])
end

function Makie.plot!(plot::Makie.Plot(Dataset))
field = pop!(plot.attributes, :attribute, :intensity)
max_points = pop!(plot.attributes, :max_points, 1_000_000)[]
field = pop!(plot.attributes, :attribute, Makie.Observable(:intensity))[]
max_points = pop!(plot.attributes, :max_points, Makie.Observable(1_000_000))[]

ds = plot[1][]
step = max(1, round(Int, length(ds) / max_points))
Expand All @@ -26,6 +33,25 @@ function Makie.plot!(plot::Makie.Plot(Dataset))
get!(plot.attributes, :ssao, true)

valid_attributes = Makie.shared_attributes(plot, Makie.Scatter)
valid_attributes[:zscale] = get(plot.attributes, :zscale, Makie.Observable(1))[]
Makie.scatter!(plot, valid_attributes, points)
plot
end

function Makie.plot!(plot::Makie.Plot{Makie.plot,<:Tuple{Vector{<:Point}}})
field = pop!(plot.attributes, :attribute, Makie.Observable(:intensity))[]

points = plot[1][]

if !haskey(plot.attributes, :color)
plot.attributes[:color] = Float32.(getfield.(points, field))
end

get!(plot.attributes, :fxaa, true)
get!(plot.attributes, :ssao, true)

valid_attributes = Makie.shared_attributes(plot, Makie.Scatter)
valid_attributes[:zscale] = get(plot.attributes, :zscale, Makie.Observable(1))[]
Makie.scatter!(plot, valid_attributes, points)
plot
end
Expand Down

2 comments on commit 085eb26

@evetion
Copy link
Owner Author

@evetion evetion commented on 085eb26 Dec 4, 2024

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

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.4.5 -m "<description of version>" 085eb26fbfb5d3a3b88872723bb00413a5a1200e
git push origin v0.4.5

Please sign in to comment.