From b971fbb84357ba1e66a17f66b50dda86bea9c8a4 Mon Sep 17 00:00:00 2001 From: James Wrigley Date: Wed, 18 Sep 2024 17:15:48 +0200 Subject: [PATCH 1/6] Use `Base.depwarn()` exclusively, and fix deprecation tests (#4333) * Use `Base.depwarn()` exclusively, and fix deprecation tests A few changes: - Use `Base.depwarn()` instead of `Base.@deprecate_binding` to avoid warnings when importing symbols. - Pass the missing `funcsym` argument to `Base.depwarn()` in `Combined()`. - Fix the deprecation tests. Most of them were actually getting skipped because `@depwarn_message` had a `return` statement, causing the entire testset to return early as soon as the passed expression was evaluated. * fixup! Use `Base.depwarn()` exclusively, and fix deprecation tests --- src/deprecated.jl | 18 +++++++++++++----- test/deprecated.jl | 19 ++++++++----------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/deprecated.jl b/src/deprecated.jl index 5445d523e4a..e03088ea41e 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -1,8 +1,16 @@ ########################################### # v0.20 deprecations: ## -Base.@deprecate_binding DiscreteSurface CellGrid true -Base.@deprecate_binding ContinuousSurface VertexGrid true + +function DiscreteSurface(args...; kwargs...) + @warn "Makie.DiscreteSurface() is deprecated, use Makie.CellGrid() instead" maxlog=1 + CellGrid(args...; kwargs...) +end + +function ContinuousSurface(args...; kwargs...) + @warn "Makie.ContinuousSurface() is deprecated, use Makie.VertexGrid() instead" maxlog=1 + VertexGrid(args...; kwargs...) +end function Base.getproperty(scene::Scene, field::Symbol) if field === :px_area @@ -14,7 +22,7 @@ end @deprecate pixelarea viewport true -function Combined(args...) - Base.depwarn("Makie.Combined(args...) is deprecated, use Makie.Plot(args...) instead") - Plot(args...) +function Combined(args...; kwargs...) + @warn "Makie.Combined() is deprecated, use Makie.Plot() instead" maxlog=1 + Plot(args...; kwargs...) end diff --git a/test/deprecated.jl b/test/deprecated.jl index 8c0ef0db74e..00c2300f922 100644 --- a/test/deprecated.jl +++ b/test/deprecated.jl @@ -6,9 +6,9 @@ macro depwarn_message(expr) $(esc(expr)) end if length(logger.logs) == 1 - return logger.logs[1].message + logger.logs[1].message else - return nothing + nothing end end end @@ -34,17 +34,14 @@ end end @testset "Plot -> Combined" begin logger = Test.TestLogger() - msg = @depwarn_message Combined - @test occursin("Combined is deprecated", msg) - @test Combined == Plot + msg = @depwarn_message Makie.Combined() + @test occursin("Combined() is deprecated", msg) end @testset "Surface Traits" begin - @test DiscreteSurface == CellGrid - @test ContinuousSurface == VertexGrid - msg = @depwarn_message DiscreteSurface() - @test occursin("DiscreteSurface is deprecated", msg) - msg = @depwarn_message ContinuousSurface() - @test occursin("ContinuousSurface is deprecated", msg) + msg = @depwarn_message Makie.DiscreteSurface() + @test occursin("DiscreteSurface() is deprecated", msg) + msg = @depwarn_message Makie.ContinuousSurface() + @test occursin("ContinuousSurface() is deprecated", msg) end @testset "AbstractVector ImageLike" begin msg = @depwarn_message image(1:10, 1..10, zeros(10, 10)) From bd6eb7edbdde35b4c3dd58de4df0cbe01a847e0f Mon Sep 17 00:00:00 2001 From: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:23:59 +0100 Subject: [PATCH 2/6] Actually use `linestyle` in `triplot` (#4332) * Linestyle * Changelog * adjust another refimg test instead of adding a new one --------- Co-authored-by: ffreyer --- CHANGELOG.md | 1 + ReferenceTests/src/tests/examples2d.jl | 2 +- src/basic_recipes/triplot.jl | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f2c7af9a3d..38322c3f439 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - `plotfunc()` and `func2type()` support functions ending with `!` [#4275](https://github.com/MakieOrg/Makie.jl/pull/4275). - Fixed Boundserror in clipped multicolor lines in CairoMakie [#4313](https://github.com/MakieOrg/Makie.jl/pull/4313) - Fix float precision based assertions error in GLMakie.volume [#4311](https://github.com/MakieOrg/Makie.jl/pull/4311) +- Fix `linestyle` not being used in `triplot` [#4332](https://github.com/MakieOrg/Makie.jl/pull/4332) ## [0.21.9] - 2024-08-27 diff --git a/ReferenceTests/src/tests/examples2d.jl b/ReferenceTests/src/tests/examples2d.jl index 7a90787780f..03d41582edf 100644 --- a/ReferenceTests/src/tests/examples2d.jl +++ b/ReferenceTests/src/tests/examples2d.jl @@ -1386,7 +1386,7 @@ end @reference_test "Triplot after adding points and make sure the representative_point_list is correctly updated" begin points = [(0.0,0.0),(0.95,0.0),(1.0,1.4),(0.0,1.0)] # not 1 so that we have a unique triangulation tri = Observable(triangulate(points; delete_ghosts = false)) - fig, ax, sc = triplot(tri, show_points = true, markersize = 14, show_ghost_edges = true, recompute_centers = true) + fig, ax, sc = triplot(tri, show_points = true, markersize = 14, show_ghost_edges = true, recompute_centers = true, linestyle = :dash) for p in [(0.3, 0.5), (-1.5, 2.3), (0.2, 0.2), (0.2, 0.5)] add_point!(tri[], p) end diff --git a/src/basic_recipes/triplot.jl b/src/basic_recipes/triplot.jl index cbaaa32cb39..fa1135fd091 100644 --- a/src/basic_recipes/triplot.jl +++ b/src/basic_recipes/triplot.jl @@ -223,7 +223,7 @@ function Makie.plot!(p::Triplot{<:Tuple{<:DelTri.Triangulation}}) update_plot(p[1][]) poly!(p, points_2f, triangles_3f; strokewidth=p.strokewidth, strokecolor=p.strokecolor, - color=p.triangle_color) + color=p.triangle_color, linestyle=p.linestyle) linesegments!(p, ghost_edges_2f; color=p.ghost_edge_color, linewidth=p.ghost_edge_linewidth, linecap=p.linecap, linestyle=p.ghost_edge_linestyle, xautolimits=false, yautolimits=false) lines!(p, convex_hull_2f; color=p.convex_hull_color, linewidth=p.convex_hull_linewidth, From 899eeb591a151194605d5611232dd9a44d3fc46b Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 19 Sep 2024 10:21:30 +0200 Subject: [PATCH 3/6] Correct CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38322c3f439..334df3a5727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] - Show DataInspector tooltip on NaN values if `nan_color` has been set to other than `:transparent` [#4310](https://github.com/MakieOrg/Makie.jl/pull/4310) +- Fix `linestyle` not being used in `triplot` [#4332](https://github.com/MakieOrg/Makie.jl/pull/4332) ## [0.21.11] - 2024-09-13 @@ -21,7 +22,6 @@ - `plotfunc()` and `func2type()` support functions ending with `!` [#4275](https://github.com/MakieOrg/Makie.jl/pull/4275). - Fixed Boundserror in clipped multicolor lines in CairoMakie [#4313](https://github.com/MakieOrg/Makie.jl/pull/4313) - Fix float precision based assertions error in GLMakie.volume [#4311](https://github.com/MakieOrg/Makie.jl/pull/4311) -- Fix `linestyle` not being used in `triplot` [#4332](https://github.com/MakieOrg/Makie.jl/pull/4332) ## [0.21.9] - 2024-08-27 From efc2fcc321a3496fbd2777102eceed3f134d8315 Mon Sep 17 00:00:00 2001 From: Frederic Freyer Date: Mon, 23 Sep 2024 13:58:03 +0200 Subject: [PATCH 4/6] Cleanup voxel clipping (#4397) * consistently clip based on voxel centers * make test more stable * update changelog --- CHANGELOG.md | 1 + CairoMakie/src/primitives.jl | 11 +++++++++-- GLMakie/assets/shader/voxel.frag | 14 ++++++-------- ReferenceTests/src/tests/examples3d.jl | 2 +- WGLMakie/assets/voxel.frag | 15 ++++++--------- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 334df3a5727..e1f513b6e5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Show DataInspector tooltip on NaN values if `nan_color` has been set to other than `:transparent` [#4310](https://github.com/MakieOrg/Makie.jl/pull/4310) - Fix `linestyle` not being used in `triplot` [#4332](https://github.com/MakieOrg/Makie.jl/pull/4332) +- Fix voxel clipping not being based on voxel centers [#4397](https://github.com/MakieOrg/Makie.jl/pull/4397) ## [0.21.11] - 2024-09-13 diff --git a/CairoMakie/src/primitives.jl b/CairoMakie/src/primitives.jl index f25a58f0213..4048a346b67 100644 --- a/CairoMakie/src/primitives.jl +++ b/CairoMakie/src/primitives.jl @@ -1253,7 +1253,14 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Maki pos = Makie.voxel_positions(primitive) scale = Makie.voxel_size(primitive) colors = Makie.voxel_colors(primitive) - marker = normal_mesh(Rect3f(Point3f(-0.5), Vec3f(1))) + marker = GeometryBasics.normal_mesh(Rect3f(Point3f(-0.5), Vec3f(1))) + + # Face culling + if !isempty(primitive.clip_planes[]) && Makie.is_data_space(primitive.space[]) + valid = [is_visible(primitive.clip_planes[], p) for p in pos] + pos = pos[valid] + colors = colors[valid] + end # For correct z-ordering we need to be in view/camera or screen space model = copy(primitive.model[]) @@ -1271,7 +1278,7 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Maki specular = primitive.specular, shininess = primitive.shininess, faceculling = get(primitive, :faceculling, -10), transformation = Makie.transformation(primitive), - clip_planes = primitive.clip_planes + clip_planes = Plane3f[] ) for i in zorder diff --git a/GLMakie/assets/shader/voxel.frag b/GLMakie/assets/shader/voxel.frag index 71f11e2c356..c9c6873210e 100644 --- a/GLMakie/assets/shader/voxel.frag +++ b/GLMakie/assets/shader/voxel.frag @@ -85,18 +85,16 @@ vec4 get_color(sampler2D color, Nothing color_map, int id) { bool is_clipped() { - float d1, d2; + float d; + // Center of voxel ivec3 size = ivec3(textureSize(voxel_id, 0).xyz); - vec3 xyz = vec3(ivec3(o_uvw * size)); + vec3 xyz = vec3(ivec3(o_uvw * size)) + vec3(0.5); for (int i = 0; i < _num_clip_planes; i++) { - // distance from clip planes with negative clipped - d1 = dot(xyz, clip_planes[i].xyz) - clip_planes[i].w; - d2 = dot(xyz, clip_planes[i].xyz) - clip_planes[i].w; + // distance between clip plane and center + d = dot(xyz, clip_planes[i].xyz) - clip_planes[i].w; - // both outside - clip everything - if (d1 < 0.0 || d2 < 0.0) { + if (d < 0.0) return true; - } } return false; diff --git a/ReferenceTests/src/tests/examples3d.jl b/ReferenceTests/src/tests/examples3d.jl index 494f2fe95f5..949ce6932bf 100644 --- a/ReferenceTests/src/tests/examples3d.jl +++ b/ReferenceTests/src/tests/examples3d.jl @@ -682,7 +682,7 @@ end @reference_test "Clip planes - voxel" begin f = Figure() a = LScene(f[1, 1]) - a.scene.theme[:clip_planes][] = [Plane3f(Vec3f(-2, -1, -0.5), 0.0), Plane3f(Vec3f(-0.5, -1, -2), 0.0)] + a.scene.theme[:clip_planes][] = [Plane3f(Vec3f(-2, -1, -0.5), 0.1), Plane3f(Vec3f(-0.5, -1, -2), 0.1)] r = -10:10 p = voxels!(a, [cos(sin(x+y)+z) for x in r, y in r, z in r]) f diff --git a/WGLMakie/assets/voxel.frag b/WGLMakie/assets/voxel.frag index 3fe7a6dfeee..4e095306341 100644 --- a/WGLMakie/assets/voxel.frag +++ b/WGLMakie/assets/voxel.frag @@ -85,18 +85,15 @@ vec3 blinnphong(vec3 N, vec3 V, vec3 L, vec3 color){ bool is_clipped() { - float d1, d2; + float d; + // get center pos of this voxel vec3 size = vec3(textureSize(voxel_id, 0).xyz); - vec3 xyz = vec3(ivec3(o_uvw * size)); + vec3 xyz = vec3(ivec3(o_uvw * size)) + vec3(0.5); for (int i = 0; i < num_clip_planes; i++) { - // distance from clip planes with negative clipped - d1 = dot(xyz, clip_planes[i].xyz) - clip_planes[i].w; - d2 = dot(xyz, clip_planes[i].xyz) - clip_planes[i].w; - - // both outside - clip everything - if (d1 < 0.0 || d2 < 0.0) { + // distance between clip plane and voxel center + d = dot(xyz, clip_planes[i].xyz) - clip_planes[i].w; + if (d < 0.0) return true; - } } return false; From da86824d2ffa44818f490018382875fe594a9899 Mon Sep 17 00:00:00 2001 From: Alexander Plavin Date: Mon, 23 Sep 2024 10:32:51 -0400 Subject: [PATCH 5/6] support images with reversed axes (#4338) * support images with reversed axes * changelog * add reference tests * fix reverse heatmap * squash refimages and also test surface * fix typo --------- Co-authored-by: Simon Co-authored-by: ffreyer --- CHANGELOG.md | 1 + CairoMakie/src/primitives.jl | 4 ++-- GLMakie/src/drawing_primitives.jl | 4 ++-- ReferenceTests/src/tests/primitives.jl | 28 ++++++++++++++++++++++++++ WGLMakie/src/imagelike.jl | 6 +++--- src/conversions.jl | 11 +++++----- test/boundingboxes.jl | 5 +++++ test/conversions.jl | 4 ++++ 8 files changed, 50 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1f513b6e5e..45f82637f21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - `plotfunc()` and `func2type()` support functions ending with `!` [#4275](https://github.com/MakieOrg/Makie.jl/pull/4275). - Fixed Boundserror in clipped multicolor lines in CairoMakie [#4313](https://github.com/MakieOrg/Makie.jl/pull/4313) - Fix float precision based assertions error in GLMakie.volume [#4311](https://github.com/MakieOrg/Makie.jl/pull/4311) + - Support images with reversed axes [#4338](https://github.com/MakieOrg/Makie.jl/pull/4338) ## [0.21.9] - 2024-08-27 diff --git a/CairoMakie/src/primitives.jl b/CairoMakie/src/primitives.jl index 4048a346b67..a87386c5ce9 100644 --- a/CairoMakie/src/primitives.jl +++ b/CairoMakie/src/primitives.jl @@ -730,14 +730,14 @@ function draw_atomic(scene::Scene, screen::Screen{RT}, @nospecialize(primitive:: image = primitive[3][] xs, ys = primitive[1][], primitive[2][] if xs isa Makie.EndPoints - l, r = extrema(xs) + l, r = xs N = size(image, 1) xs = range(l, r, length = N+1) else xs = regularly_spaced_array_to_range(xs) end if ys isa Makie.EndPoints - l, r = extrema(ys) + l, r = ys N = size(image, 2) ys = range(l, r, length = N+1) else diff --git a/GLMakie/src/drawing_primitives.jl b/GLMakie/src/drawing_primitives.jl index 53bb504c7a6..9147fce4b6d 100644 --- a/GLMakie/src/drawing_primitives.jl +++ b/GLMakie/src/drawing_primitives.jl @@ -691,8 +691,8 @@ end function draw_image(screen::Screen, scene::Scene, plot::Union{Heatmap, Image}) return cached_robj!(screen, scene, plot) do gl_attributes position = lift(plot, plot[1], plot[2]) do x, y - xmin, xmax = extrema(x) - ymin, ymax = extrema(y) + xmin, xmax = x + ymin, ymax = y rect = Rect2(xmin, ymin, xmax - xmin, ymax - ymin) return decompose(Point2d, rect) end diff --git a/ReferenceTests/src/tests/primitives.jl b/ReferenceTests/src/tests/primitives.jl index f514d9de174..87cfce9a10c 100644 --- a/ReferenceTests/src/tests/primitives.jl +++ b/ReferenceTests/src/tests/primitives.jl @@ -818,3 +818,31 @@ end end f end + +@reference_test "Reverse image, heatmap and surface axes" begin + img = [2 0 0 3; 0 0 0 0; 1 1 0 0; 1 1 0 4] + + f = Figure(size = (600, 400)) + + for (i, interp) in enumerate((true, false)) + for (j, plot_func) in enumerate(( + (fp, x, y, cs, interp) -> image(fp, x, y, cs, colormap = :viridis, interpolate = interp), + (fp, x, y, cs, interp) -> heatmap(fp, x, y, cs, colormap = :viridis, interpolate = interp), + (fp, x, y, cs, interp) -> surface(fp, x, y, zeros(size(cs)), color = cs, colormap = :viridis, interpolate = interp, shading = NoShading) + )) + + gl = GridLayout(f[i, j]) + + a, p = plot_func(gl[1, 1], 1:4, 1:4, img, interp) + hidedecorations!(a) + a, p = plot_func(gl[2, 1], 1:4, 4..1, img, interp) + hidedecorations!(a) + a, p = plot_func(gl[1, 2], 4:-1:1, 1:4, img, interp) + hidedecorations!(a) + a, p = plot_func(gl[2, 2], 4:-1:1, [4, 3, 2, 1], img, interp) + hidedecorations!(a) + end + end + + f +end \ No newline at end of file diff --git a/WGLMakie/src/imagelike.jl b/WGLMakie/src/imagelike.jl index 62d365ac929..b286e055e79 100644 --- a/WGLMakie/src/imagelike.jl +++ b/WGLMakie/src/imagelike.jl @@ -129,7 +129,7 @@ end -xy_convert(x::Makie.EndPoints, n) = LinRange(extrema(x)..., n + 1) +xy_convert(x::Makie.EndPoints, n) = LinRange(x..., n + 1) xy_convert(x::AbstractArray, n) = x # TODO, speed up GeometryBasics @@ -166,8 +166,8 @@ function limits_to_uvmesh(plot, f32c) py = lift(identity, plot, py; ignore_equal_values=true) if px[] isa Makie.EndPoints && py[] isa Makie.EndPoints && Makie.is_identity_transform(t) rect = lift(plot, px, py) do x, y - xmin, xmax = extrema(x) - ymin, ymax = extrema(y) + xmin, xmax = x + ymin, ymax = y return Rect2f(xmin, ymin, xmax - xmin, ymax - ymin) end ps = lift(rect -> decompose(Point2f, rect), plot, rect) diff --git a/src/conversions.jl b/src/conversions.jl index 752cb19c38c..6516860f0a5 100644 --- a/src/conversions.jl +++ b/src/conversions.jl @@ -365,12 +365,10 @@ function to_endpoints(x::Tuple{<:Real,<:Real}) T = float_type(x...) return EndPoints(T.(x)) end -to_endpoints(x::ClosedInterval) = to_endpoints(endpoints(x)) -function to_endpoints(x::Union{Interval,AbstractVector,ClosedInterval}) - return to_endpoints((minimum(x), maximum(x))) -end +to_endpoints(x::Interval) = to_endpoints(endpoints(x)) +to_endpoints(x::EndPoints) = x +to_endpoints(x::AbstractVector) = to_endpoints((first(x), last(x))) function to_endpoints(x, dim) - # having minimum and maximum here actually invites bugs x isa AbstractVector && !(x isa EndPoints) && print_range_warning(dim, x) return to_endpoints(x) end @@ -698,7 +696,8 @@ end # Helper Functions # ################################################################################ -to_linspace(interval, N) = range(minimum(interval), stop = maximum(interval), length = N) +to_linspace(interval::Interval, N) = range(leftendpoint(interval), stop = rightendpoint(interval), length = N) +to_linspace(x, N) = range(first(x), stop = last(x), length = N) """ Converts the element array type to `T1` without making a copy if the element type matches diff --git a/test/boundingboxes.jl b/test/boundingboxes.jl index 66897c8444f..88cda42f179 100644 --- a/test/boundingboxes.jl +++ b/test/boundingboxes.jl @@ -92,6 +92,11 @@ end @test bb.origin ≈ Point3f(0) @test bb.widths ≈ Vec3f(10.0, 10.0, 0) + fig, ax, p = image(1..0, 1:10, rand(10, 10)) + bb = boundingbox(p) + @test bb.origin ≈ Point3f(0, 1, 0) + @test bb.widths ≈ Vec3f(1.0, 9.0, 0) + # text transforms to pixel space atm (TODO) fig = Figure(size = (400, 400)) ax = Axis(fig[1, 1]) diff --git a/test/conversions.jl b/test/conversions.jl index 2d60f0cc5d9..118dde2ad66 100644 --- a/test/conversions.jl +++ b/test/conversions.jl @@ -342,9 +342,11 @@ end v1 = collect(1:10) v2 = collect(1:6) + v3 = reverse(v1) i1 = 1 .. 10 i2 = 1 .. 6 + i3 = 10 .. 1 o3 = Float32.(m3) @@ -354,6 +356,8 @@ end @test convert_arguments(Image, m3) == ((0.0f0, 10.0f0), (0.0f0, 6.0f0), o3) @test convert_arguments(Image, v1, r2, m3) == ((1.0f0, 10.0f0), (1.0f0, 6.0f0), o3) @test convert_arguments(Image, i1, v2, m3) == ((1.0f0, 10.0f0), (1.0f0, 6.0f0), o3) + @test convert_arguments(Image, v3, i1, m3) == ((10, 1), (1, 10), o3) + @test convert_arguments(Image, v1, i3, m3) == ((1, 10), (10, 1), o3) @test convert_arguments(Image, m1, m2, m3) === (m1, m2, m3) @test convert_arguments(Heatmap, m1, m2) === (m1, m2) end From bb5cc0afa4a109e0c6948b7ce3d90a431d01d2e5 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 24 Sep 2024 12:28:43 +0200 Subject: [PATCH 6/6] Restricting imageio to 0.5+ (#4401) Closes #3461 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index d34ed86ea0b..dda31584b95 100644 --- a/Project.toml +++ b/Project.toml @@ -85,7 +85,7 @@ FreeTypeAbstraction = "0.10.3" GeometryBasics = "0.4.11" GridLayoutBase = "0.11" ImageBase = "0.1.7" -ImageIO = "0.2, 0.3, 0.4, 0.5, 0.6" +ImageIO = "0.5, 0.6" InteractiveUtils = "1.0, 1.6" Interpolations = "0.15.1" IntervalSets = "0.3, 0.4, 0.5, 0.6, 0.7"