diff --git a/Project.toml b/Project.toml index 1fa324e..691bd8b 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LazIO" uuid = "c3605908-9f0f-11e8-0a72-0d361c15a277" authors = ["Maarten Pronk "] -version = "0.4.4" +version = "0.4.5" [deps] CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298" diff --git a/ext/MakieExt.jl b/ext/MakieExt.jl index 4672eeb..3a7a506 100644 --- a/ext/MakieExt.jl +++ b/ext/MakieExt.jl @@ -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)) @@ -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