Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Makie to 0.21 #36

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Distributions = "0.24, 0.25"
FileIO = "1.4"
Format = "1.3"
ForwardDiff = "0.10"
GLMakie = "0.9"
GLMakie = "0.10"
GeometryBasics = "0.3, 0.4"
HTTP = "0.8, 0.9, 1"
ImageView = "0.10, 0.11, 0.12"
Expand All @@ -75,7 +75,7 @@ Ipopt = "0.6, 0.7, 0.8, 0.9, 1"
JuMP = "0.21, 0.22, 1"
LazySets = "1, 2"
Luxor = "2.10, 3"
Makie = "0.20"
Makie = "0.21"
MeshIO = "0.4"
NLopt = "0.6, 1"
Optim = "1.2"
Expand All @@ -94,7 +94,7 @@ StaticArrays = "1.0"
Statistics = "1"
StringEncodings = "0.3"
Unitful = "1.6"
WGLMakie = "0.9"
WGLMakie = "0.10"
ZipFile = "0.9, 0.10"
Zygote = "0.6"
julia = "1.10"
5 changes: 4 additions & 1 deletion src/Vis/Emitters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ end
#-------------------------------------
# draw optical rays
#-------------------------------------
function OpticSim.Vis.draw!(scene::Makie.LScene, rays::AbstractVector{OpticSim.OpticalRay{T, 3}}; kwargs...) where {T<:Real}
function OpticSim.Vis.draw!(scene::Makie.LScene, rays::AbstractVector{OpticSim.OpticalRay{T, 3}};
debug::Bool = false, # make sure debug does not end up in kwargs (Makie would error)
kwargs...
) where {T<:Real}
m = zeros(T, length(rays)*2, 3)
for (index, optical_ray) in enumerate(rays)
ray = OpticSim.ray(optical_ray)
Expand Down
45 changes: 39 additions & 6 deletions src/Vis/Visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,16 @@ Base.:*(a::Transform, p::GeometryBasics.PointMeta) = a * p.main
Base.:*(a::Real, p::GeometryBasics.PointMeta{N,S}) where {S<:Real,N} = GeometryBasics.Point{N,S}((a * SVector{N,S}(p))...)
Base.:*(a::Transform, p::GeometryBasics.Point{N,S}) where {S<:Real,N} = GeometryBasics.Point{N,S}((a.rotation * SVector{N,S}(p) + a.translation)...)

function draw!(scene::Makie.LScene, ob::AbstractString; color = :gray, linewidth = 3, shaded::Bool = true, wireframe::Bool = false, transform::Transform{Float64} = identitytransform(Float64), scale::Float64 = 1.0, kwargs...)
function draw!(scene::Makie.LScene, ob::AbstractString;
color = :gray,
debug::Bool = false, # make sure debug does not end up in kwargs (Makie would error)
linewidth = 3,
shaded::Bool = true,
wireframe::Bool = false,
transform::Transform{Float64} = identitytransform(Float64),
scale::Float64 = 1.0,
kwargs...
)
if any(endswith(lowercase(ob), x) for x in [".obj", "ply", ".2dm", ".off", ".stl"])
meshdata = FileIO.load(ob)
if transform != identitytransform(Float64) || scale != 1.0
Expand Down Expand Up @@ -370,7 +379,17 @@ end

Draw a [`TriangleMesh`](@ref), optionially with a visible `wireframe`. `kwargs` are passed on to [`Makie.mesh`](http://makie.juliaplots.org/stable/plotting_functions.html#mesh).
"""
function draw!(scene::Makie.LScene, tmesh::TriangleMesh{T}; linewidth = 3, shaded::Bool = true, wireframe::Bool = false, color = :orange, normals::Bool = false, normalcolor = :blue, transparency::Bool = false, kwargs...) where {T<:Real}
function draw!(scene::Makie.LScene, tmesh::TriangleMesh{T};
debug::Bool = false, # make sure debug does not end up in kwargs (Makie would error)
linewidth = 3,
shaded::Bool = true,
wireframe::Bool = false,
color = :orange,
normals::Bool = false,
normalcolor = :blue,
transparency::Bool = false,
kwargs...
) where {T<:Real}
points, indices = makiemesh(tmesh)
if length(points) > 0 && length(indices) > 0
shading = default_shading(shaded)
Expand Down Expand Up @@ -512,7 +531,7 @@ drawtracerays!(system::Q; kwargs...) where {T<:Real,Q<:AbstractOpticalSystem{T}}
function drawtracerays!(scene::Makie.LScene, system::Q; raygenerator::S = Source(transform = translation(0.0,0.0,10.0), origins = Origins.RectGrid(10.0,10.0,25,25),directions = Constant(0.0,0.0,-1.0)), test::Bool = false, trackallrays::Bool = false, colorbysourcenum::Bool = false, colorbynhits::Bool = false, rayfilter::Union{Nothing,Function} = onlydetectorrays, verbose::Bool = false, drawsys::Bool = false, drawgen::Bool = false, kwargs...) where {T<:Real,Q<:AbstractOpticalSystem{T},S<:AbstractRayGenerator{T}}
raylines = Vector{LensTrace{T,3}}(undef, 0)

drawgen && draw!(scene, raygenerator, norays = true; kwargs...)
drawgen && draw!(scene, raygenerator; kwargs...)
drawsys && draw!(scene, system; kwargs...)

verbose && println("Tracing...")
Expand Down Expand Up @@ -634,7 +653,12 @@ end
Draw a [`Ray`](@ref) in a given `color` optionally scaling the size using `rayscale`.
`kwargs` are passed to [`Makie.arrows`](http://makie.juliaplots.org/stable/plotting_functions.html#arrows).
"""
function draw!(scene::Makie.LScene, ray::AbstractRay{T,N}; color = :yellow, rayscale = 1.0, kwargs...) where {T<:Real,N}
function draw!(scene::Makie.LScene, ray::AbstractRay{T,N};
color = :yellow,
debug::Bool = false, # make sure debug does not end up in kwargs (Makie would error)
rayscale = 1.0,
kwargs...
) where {T<:Real,N}
arrow_size = min(0.05, rayscale * 0.05)
Makie.arrows!(scene, [Makie.Point3f(origin(ray))], [Makie.Point3f(rayscale * direction(ray))]; kwargs..., arrowsize = arrow_size, arrowcolor = color, linecolor = color, linewidth=arrow_size * 0.5)
end
Expand Down Expand Up @@ -712,7 +736,11 @@ end

Draw a line between two points, `kwargs` are passed to [`Makie.linesegments`](http://makie.juliaplots.org/stable/plotting_functions.html#linesegments).
"""
function draw!(scene::Makie.LScene, line::Tuple{P,P}; color = :yellow, kwargs...) where {T<:Real,P<:AbstractVector{T}}
function draw!(scene::Makie.LScene, line::Tuple{P,P};
debug::Bool = false, # make sure debug does not end up in kwargs (Makie would error)
color = :yellow,
kwargs...
) where {T<:Real,P<:AbstractVector{T}}
Makie.linesegments!(scene, [line[1], line[2]]; kwargs..., color = color)
end

Expand All @@ -731,7 +759,12 @@ end
Draw a vector of points.
`kwargs` are passed to [`Makie.scatter`](http://makie.juliaplots.org/stable/plotting_functions.html#scatter).
"""
function draw!(scene::Makie.LScene, points::AbstractVector{P}; markersize = 20, color = :black, kwargs...) where {T<:Real,P<:AbstractVector{T}}
function draw!(scene::Makie.LScene, points::AbstractVector{P};
debug::Bool = false, # make sure debug does not end up in kwargs (Makie would error)
markersize = 20,
color = :black,
kwargs...
) where {T<:Real,P<:AbstractVector{T}}
Makie.scatter!(scene, points, markersize = markersize, color = color, strokewidth = 0; kwargs...)
end

Expand Down
Loading