Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Jul 7, 2024
2 parents c7232e7 + 604ba5d commit d7e37e1
Show file tree
Hide file tree
Showing 29 changed files with 352 additions and 251 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
## [Unreleased]

- validate plot attributes later, for axis specific plot attributes [#3974](https://github.com/MakieOrg/Makie.jl/pull/3974).
- Add line-loop detection and rendering to GLMakie and WGLMakie [#3907](https://github.com/MakieOrg/Makie.jl/pull/3907)

## [0.21.4] - 2024-07-02

- Fixed support for GLFW 3.4 on OSX [#3999](https://github.com/MakieOrg/Makie.jl/issues/3999).
- Changed camera variables to Float64 for increased accuracy [#3984](https://github.com/MakieOrg/Makie.jl/pull/3984)
- Allow CairoMakie to render `poly` overloads that internally don't use two child plots [#3986](https://github.com/MakieOrg/Makie.jl/pull/3986).
- Fixes for Menu and DataInspector [#3975](https://github.com/MakieOrg/Makie.jl/pull/3975).
- Add line-loop detection and rendering to GLMakie and WGLMakie [#3907](https://github.com/MakieOrg/Makie.jl/pull/3907).

## [0.21.3] - 2024-06-17

- Fix stack overflows when using `markerspace = :data` with `scatter` [#3960](https://github.com/MakieOrg/Makie.jl/issues/3960).
- CairoMakie: Fix broken SVGs when using non-interpolated image primitives, for example Colorbars, with recent Cairo versions [#3967](https://github.com/MakieOrg/Makie.jl/pull/3967).
- CairoMakie: Add argument `pdf_version` to restrict the PDF version when saving a figure as a PDF [#3845](https://github.com/MakieOrg/Makie.jl/pull/3845).
- Fix DataInspector using invalid attribute strokewidth for plot type Wireframe [#3917](https://github.com/MakieOrg/Makie.jl/pull/3917).
- CairoMakie: Fix incorrect scaling factor for SVGs with Cairo_jll 1.18 [#3964](https://github.com/MakieOrg/Makie.jl/pull/3964).
- Fixed use of Textbox from Bonito [#3924](https://github.com/MakieOrg/Makie.jl/pull/3924)

Expand Down Expand Up @@ -516,7 +524,8 @@ All other changes are collected [in this PR](https://github.com/MakieOrg/Makie.j
- Fixed rendering of `heatmap`s with one or more reversed ranges in CairoMakie, as in `heatmap(1:10, 10:-1:1, rand(10, 10))` [#1100](https://github.com/MakieOrg/Makie.jl/pull/1100).
- Fixed volume slice recipe and added docs for it [#1123](https://github.com/MakieOrg/Makie.jl/pull/1123).

[Unreleased]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.3...HEAD
[Unreleased]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.4...HEAD
[0.21.4]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.3...v0.21.4
[0.21.3]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.2...v0.21.3
[0.21.2]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.1...v0.21.2
[0.21.1]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.0...v0.21.1
Expand Down
4 changes: 2 additions & 2 deletions CairoMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CairoMakie"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
author = ["Simon Danisch <sdanisch@gmail.com>"]
version = "0.12.3"
version = "0.12.4"

[deps]
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
Expand All @@ -24,7 +24,7 @@ FileIO = "1.1"
FreeType = "3, 4.0"
GeometryBasics = "0.4.11"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.3"
Makie = "=0.21.4"
PrecompileTools = "1.0"
julia = "1.3"

Expand Down
5 changes: 3 additions & 2 deletions CairoMakie/src/overrides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ is_cairomakie_atomic_plot(plot::Poly) = true


function draw_poly_as_mesh(scene, screen, poly)
draw_plot(scene, screen, poly.plots[1])
draw_plot(scene, screen, poly.plots[2])
for i in eachindex(poly.plots)
draw_plot(scene, screen, poly.plots[i])
end
end

# As a general fallback, draw all polys as meshes.
Expand Down
4 changes: 2 additions & 2 deletions GLMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GLMakie"
uuid = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
version = "0.10.3"
version = "0.10.4"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand Down Expand Up @@ -30,7 +30,7 @@ FreeTypeAbstraction = "0.10"
GLFW = "3.3"
GeometryBasics = "0.4.11"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.3"
Makie = "=0.21.4"
Markdown = "1.0, 1.6"
MeshIO = "0.4"
ModernGL = "1"
Expand Down
18 changes: 9 additions & 9 deletions GLMakie/src/drawing_primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ function to_glvisualize_key(k)
end

function connect_camera!(plot, gl_attributes, cam, space = gl_attributes[:space])
for key in (:pixel_space, :eyeposition)
# Overwrite these, user defined attributes shouldn't use those!
gl_attributes[key] = lift(identity, plot, getfield(cam, key))
end
# Overwrite these, user defined attributes shouldn't use those!
gl_attributes[:pixel_space] = lift(Mat4f, plot, cam.pixel_space)
gl_attributes[:eyeposition] = lift(identity, plot, cam.eyeposition)

get!(gl_attributes, :view) do
# get!(cam.calculated_values, Symbol("view_$(space[])")) do
return lift(plot, cam.view, space) do view, space
return is_data_space(space) ? view : Mat4f(I)
return is_data_space(space) ? Mat4f(view) : Mat4f(I)
end
# end
end
Expand All @@ -169,14 +169,14 @@ function connect_camera!(plot, gl_attributes, cam, space = gl_attributes[:space]
get!(gl_attributes, :projection) do
# return get!(cam.calculated_values, Symbol("projection_$(space[])")) do
return lift(plot, cam.projection, cam.pixel_space, space) do _, _, space
return Makie.space_to_clip(cam, space, false)
return Mat4f(Makie.space_to_clip(cam, space, false))
end
# end
end
get!(gl_attributes, :projectionview) do
# get!(cam.calculated_values, Symbol("projectionview_$(space[])")) do
return lift(plot, cam.projectionview, cam.pixel_space, space) do _, _, space
Makie.space_to_clip(cam, space, true)
return Mat4f(Makie.space_to_clip(cam, space, true))
end
# end
end
Expand Down Expand Up @@ -391,7 +391,7 @@ function draw_atomic(screen::Screen, scene::Scene, @nospecialize(plot::Union{Sca
cam = scene.camera
gl_attributes[:preprojection] = lift(plot, space, mspace, cam.projectionview,
cam.resolution) do space, mspace, _, _
return Makie.clip_to_space(cam, mspace) * Makie.space_to_clip(cam, space)
return Mat4f(Makie.clip_to_space(cam, mspace) * Makie.space_to_clip(cam, space))
end
# fast pixel does its own setup
if !(marker[] isa FastPixel)
Expand Down Expand Up @@ -574,7 +574,7 @@ function draw_atomic(screen::Screen, scene::Scene,
cam = scene.camera
# gl_attributes[:preprojection] = Observable(Mat4f(I))
gl_attributes[:preprojection] = lift(plot, space, markerspace, cam.projectionview, cam.resolution) do s, ms, pv, res
Makie.clip_to_space(cam, ms) * Makie.space_to_clip(cam, s)
Mat4f(Makie.clip_to_space(cam, ms) * Makie.space_to_clip(cam, s))
end

return draw_scatter(screen, (DISTANCEFIELD, positions), gl_attributes)
Expand Down
5 changes: 4 additions & 1 deletion GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ function empty_screen(debugging::Bool; reuse=true)
rethrow(e)
end

GLFW.SetWindowIcon(window, Makie.icon())
# GLFW doesn't support setting the icon on OSX
if !Sys.isapple()
GLFW.SetWindowIcon(window, Makie.icon())
end

# tell GLAbstraction that we created a new context.
# This is important for resource tracking, and only needed for the first context
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Makie"
uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
authors = ["Simon Danisch", "Julius Krumbiegel"]
version = "0.21.3"
version = "0.21.4"

[deps]
Animations = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
Expand Down
4 changes: 2 additions & 2 deletions RPRMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RPRMakie"
uuid = "22d9f318-5e34-4b44-b769-6e3734a732a6"
authors = ["Simon Danisch"]
version = "0.7.3"
version = "0.7.4"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand All @@ -17,7 +17,7 @@ Colors = "0.9, 0.10, 0.11, 0.12"
FileIO = "1.6"
GeometryBasics = "0.4.11"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.3"
Makie = "=0.21.4"
Printf = "1.0, 1.6"
RadeonProRender = "0.3.0"
julia = "1.3"
Expand Down
2 changes: 1 addition & 1 deletion RPRMakie/src/scene.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function to_rpr_light(context::RPR.Context, rpr_scene, light::Makie.DirectionalL
else
dir = normalize(dir)
end
quart = Makie.rotation_between(dir, Vec3f(0,0,-1))
quart = Makie.rotation_between(Vec3f(dir), Vec3f(0,0,-1))
transform!(directionallight, Makie.rotationmatrix4(quart))
end
map(light.color) do c
Expand Down
8 changes: 7 additions & 1 deletion ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1353,10 +1353,15 @@ end
fig
end

#=
After DelaunayTriangulation@1.0.4, this test started to show slightly randomized triangulations.
Until this gets fixed, we're disabling it.
@reference_test "Voronoiplot with a nonlinear transform" begin
f = Figure()
ax = PolarAxis(f[1, 1], theta_as_x = false)
points = Point2f[(r, phi) for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
points = Point2d[(r, phi) for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
polygon_color = [r for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
polygon_color_2 = [phi for r in 1:10 for phi in range(0, 2pi, length=36)[1:35]]
tr = voronoiplot!(ax, points, smooth = false, show_generators = false, color = polygon_color)
Expand All @@ -1366,6 +1371,7 @@ end
Makie.rlims!(ax, 12)
f
end
=#

@reference_test "Voronoiplot with some custom bounding boxes may not contain all data sites" begin
points = [(-3.0, 7.0), (1.0, 6.0), (-1.0, 3.0), (-2.0, 4.0), (3.0, -2.0), (5.0, 5.0), (-4.0, -3.0), (3.0, 8.0)]
Expand Down
2 changes: 1 addition & 1 deletion ReferenceTests/src/tests/short_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,4 @@ end
# f.scene.events.scroll[] = (0, -10)
# # reference test the zoomed out plot
# f
# end
# end
4 changes: 2 additions & 2 deletions WGLMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "WGLMakie"
uuid = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"
authors = ["SimonDanisch <sdanisch@gmail.com>"]
version = "0.10.3"
version = "0.10.4"

[deps]
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
Expand All @@ -27,7 +27,7 @@ FreeTypeAbstraction = "0.10"
GeometryBasics = "0.4.11"
Hyperscript = "0.0.3, 0.0.4, 0.0.5"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.3"
Makie = "=0.21.4"
Observables = "0.5.1"
PNGFiles = "0.3, 0.4"
PrecompileTools = "1.0"
Expand Down
3 changes: 2 additions & 1 deletion WGLMakie/assets/sprites.frag
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,12 @@ void main() {
if (picking) {
if (final_color.a > 0.1) {
fragment_color = pack_int(object_id, frag_instance_id);
} else {
discard;
}
return;
}


if (final_color.a <= 0.0){
discard;
}
Expand Down
7 changes: 4 additions & 3 deletions WGLMakie/src/picking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ function pick_native(screen::Screen, rect::Rect2i)
if isempty(matrix)
return empty
else
all_children = Makie.collect_atomic_plots(scene)
lookup = Dict(Pair.(js_uuid.(all_children), all_children))
lookup = plot_lookup(scene)
return map(matrix) do (uuid, index)
!haskey(lookup, uuid) && return (nothing, 0)
return (lookup[uuid], Int(index) + 1)
Expand All @@ -40,6 +39,7 @@ function Makie.pick_closest(scene::Scene, screen::Screen, xy, range::Integer)
Promise.all([$(WGL), $(scene)]).then(([WGL, scene]) => WGL.pick_closest(scene, $(xy_vec), $(range)))
""")
lookup = plot_lookup(scene)
!haskey(lookup, selection[1]) && return (nothing, 0)
return (lookup[selection[1]], selection[2] + 1)
end

Expand All @@ -55,11 +55,12 @@ function Makie.pick_sorted(scene::Scene, screen::Screen, xy, range)
isnothing(selection) && return Tuple{Union{Nothing,AbstractPlot},Int}[]
lookup = plot_lookup(scene)
return map(selection) do (plot_id, index)
!haskey(lookup, plot_id) && return (nothing, 0)
return (lookup[plot_id], index + 1)
end
end

function Makie.pick(scene::Scene, screen::Screen, xy)
function Makie.pick(::Scene, screen::Screen, xy)
plot_matrix = pick_native(screen, Rect2i(xy..., 1, 1))
return plot_matrix[1, 1]
end
Expand Down
4 changes: 2 additions & 2 deletions WGLMakie/src/serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function serialize_scene(scene::Scene)

cam3d_state = if cam_controls isa Camera3D
fields = (:lookat, :upvector, :eyeposition, :fov, :near, :far)
dict = Dict((f => lift(serialize_three, scene, getfield(cam_controls, f)) for f in fields))
dict = Dict((f => lift(x -> serialize_three(Float32.(x)), scene, getfield(cam_controls, f)) for f in fields))
dict[:resolution] = lift(res -> Int32[res...], scene, scene.camera.resolution)
dict
else
Expand Down Expand Up @@ -377,6 +377,6 @@ function serialize_camera(scene::Scene)
# eyeposition updates with viewmatrix, since an eyepos change will trigger
# a view matrix change!
ep = cam.eyeposition[]
return [vec(collect(view)), vec(collect(proj)), Int32[res...], Float32[ep...]]
return [vec(collect(Mat4f(view))), vec(collect(Mat4f(proj))), Int32[res...], Float32[ep...]]
end
end
30 changes: 30 additions & 0 deletions WGLMakie/src/wglmakie.bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -23124,6 +23124,35 @@ function pick_native(scene, _x, _y, _w, _h) {
plots
];
}
function get_picking_buffer(scene) {
const { renderer , picking_target } = scene.screen;
const [w, h] = [
picking_target.width,
picking_target.height
];
renderer.setRenderTarget(picking_target);
set_picking_uniforms(scene, 1, true);
render_scene(scene, true);
renderer.setRenderTarget(null);
const nbytes = w * h * 4;
const pixel_bytes = new Uint8Array(nbytes);
renderer.readRenderTargetPixels(picking_target, 0, 0, w, h, pixel_bytes);
const reinterpret_view = new DataView(pixel_bytes.buffer);
const picked_plots_array = [];
for(let i = 0; i < pixel_bytes.length / 4; i++){
const id = reinterpret_view.getUint16(i * 4);
const index = reinterpret_view.getUint16(i * 4 + 2);
picked_plots_array.push([
id,
index
]);
}
return {
picked_plots_array,
w,
h
};
}
function pick_closest(scene, xy, range) {
const { renderer } = scene.screen;
const [width, height] = [
Expand Down Expand Up @@ -23282,6 +23311,7 @@ export { deserialize_scene as deserialize_scene, threejs_module as threejs_modul
export { render_scene as render_scene };
export { wglerror as wglerror };
export { pick_native as pick_native };
export { get_picking_buffer as get_picking_buffer };
export { pick_closest as pick_closest };
export { pick_sorted as pick_sorted };
export { pick_native_uuid as pick_native_uuid };
Expand Down
30 changes: 30 additions & 0 deletions WGLMakie/src/wglmakie.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,36 @@ export function pick_native(scene, _x, _y, _w, _h) {
return [plot_matrix, plots];
}

// For debugging the pixelbuffer
export function get_picking_buffer(scene) {
const { renderer, picking_target } = scene.screen;
const [w, h] = [picking_target.width, picking_target.height];
// render the scene
renderer.setRenderTarget(picking_target);
set_picking_uniforms(scene, 1, true);
render_scene(scene, true);
renderer.setRenderTarget(null); // reset render target
const nbytes = w * h * 4;
const pixel_bytes = new Uint8Array(nbytes);
//read the pixel
renderer.readRenderTargetPixels(
picking_target,
0, // x
0, // y
w, // width
h, // height
pixel_bytes
);
const reinterpret_view = new DataView(pixel_bytes.buffer);
const picked_plots_array = []
for (let i = 0; i < pixel_bytes.length / 4; i++) {
const id = reinterpret_view.getUint16(i * 4);
const index = reinterpret_view.getUint16(i * 4 + 2);
picked_plots_array.push([id, index]);
}
return {picked_plots_array, w, h};
}

export function pick_closest(scene, xy, range) {
const { renderer } = scene.screen;
const [ width, height ] = [renderer._width, renderer._height];
Expand Down
4 changes: 2 additions & 2 deletions src/basic_recipes/contours.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ with z-elevation for each level.
MakieCore.documented_attributes(Contour)...
end

angle(p1::Union{Vec2f,Point2f}, p2::Union{Vec2f,Point2f})::Float32 =
atan(p2[2] - p1[2], p2[1] - p1[1]) # result in [-π, π]
# result in [-π, π]
angle(p1::VecTypes{2}, p2::VecTypes{2}) = Float32(atan(p2[2] - p1[2], p2[1] - p1[1]))

function label_info(lev, vertices, col)
mid = ceil(Int, 0.5f0 * length(vertices))
Expand Down
Loading

0 comments on commit d7e37e1

Please sign in to comment.