Skip to content

Commit

Permalink
Merge branch 'master' into sd/axis-converts
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch authored Jan 30, 2024
2 parents c2d173f + 6b7377b commit 5d2b355
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 28 deletions.
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 <[email protected]>"]
version = "0.11.5"
version = "0.11.6"

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

Expand Down
10 changes: 5 additions & 5 deletions CairoMakie/src/overrides.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end
function draw_poly(scene::Scene, screen::Screen, poly, points::Vector{<:Point2}, color::Union{Colorant, Cairo.CairoPattern},
model, strokecolor, strokestyle, strokewidth)
space = to_value(get(poly, :space, :data))
points = project_position.(Ref(scene), space, points, Ref(model))
points = project_position.(Ref(poly), space, points, Ref(model))
Cairo.move_to(screen.context, points[1]...)
for p in points[2:end]
Cairo.line_to(screen.context, p...)
Expand Down Expand Up @@ -78,7 +78,7 @@ draw_poly(scene::Scene, screen::Screen, poly, bezierpath::BezierPath) = draw_pol
function draw_poly(scene::Scene, screen::Screen, poly, shapes::Vector{<:Union{Rect2,BezierPath}})
model = poly.model[]
space = to_value(get(poly, :space, :data))
projected_shapes = project_shape.(Ref(scene), space, shapes, Ref(model))
projected_shapes = project_shape.(Ref(poly), space, shapes, Ref(model))

color = to_cairo_color(poly.color[], poly)

Expand Down Expand Up @@ -175,7 +175,7 @@ end
function draw_poly(scene::Scene, screen::Screen, poly, polygons::AbstractArray{<: MultiPolygon})
model = poly.model[]
space = to_value(get(poly, :space, :data))
projected_polys = project_multipolygon.(Ref(scene), space, polygons, Ref(model))
projected_polys = project_multipolygon.(Ref(poly), space, polygons, Ref(model))

color = to_cairo_color(poly.color[], poly)
strokecolor = to_cairo_color(poly.strokecolor[], poly)
Expand Down Expand Up @@ -211,7 +211,7 @@ function draw_plot(scene::Scene, screen::Screen,
points = vcat(lowerpoints, reverse(upperpoints))
model = band.model[]
space = to_value(get(band, :space, :data))
points = project_position.(Ref(scene), space, points, Ref(model))
points = project_position.(Ref(band), space, points, Ref(model))
Cairo.move_to(screen.context, points[1]...)
for p in points[2:end]
Cairo.line_to(screen.context, p...)
Expand Down Expand Up @@ -249,7 +249,7 @@ function draw_plot(scene::Scene, screen::Screen, tric::Tricontourf)
polygons = pol[1][]
model = pol.model[]
space = to_value(get(pol, :space, :data))
projected_polys = project_polygon.(Ref(scene), space, polygons, Ref(model))
projected_polys = project_polygon.(Ref(tric), space, polygons, Ref(model))

function draw_tripolys(polys, colornumbers, colors)
for (i, (pol, colnum, col)) in enumerate(zip(polys, colornumbers, colors))
Expand Down
6 changes: 3 additions & 3 deletions CairoMakie/src/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio
end

if primitive isa Lines && to_value(primitive.args[1]) isa BezierPath
return draw_bezierpath_lines(ctx, to_value(primitive.args[1]), scene, color, space, model, linewidth)
return draw_bezierpath_lines(ctx, to_value(primitive.args[1]), primitive, color, space, model, linewidth)
end

if color isa AbstractArray || linewidth isa AbstractArray
Expand Down Expand Up @@ -728,8 +728,8 @@ function draw_atomic(scene::Scene, screen::Screen, @nospecialize(primitive::Unio
# find projected image corners
# this already takes care of flipping the image to correct cairo orientation
space = to_value(get(primitive, :space, :data))
xy = project_position(scene, space, Point2f(first.(imsize)), model)
xymax = project_position(scene, space, Point2f(last.(imsize)), model)
xy = project_position(primitive, space, Point2f(first.(imsize)), model)
xymax = project_position(primitive, space, Point2f(last.(imsize)), model)
w, h = xymax .- xy

can_use_fast_path = !(is_vector && !interpolate) && regular_grid && identity_transform &&
Expand Down
8 changes: 4 additions & 4 deletions CairoMakie/src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function _project_position(scene::Scene, space, point, model, yflip::Bool)
return p_0_to_1 .* res
end

function project_position(scenelike, space, point, model, yflip::Bool = true)
function project_position(@nospecialize(scenelike), space, point, model, yflip::Bool = true)
scene = Makie.get_scene(scenelike)
project_position(scene, Makie.transform_func(scenelike), space, point, model, yflip)
end
Expand All @@ -47,13 +47,13 @@ function project_scale(scene::Scene, space, s, model = Mat4f(I))
end
end

function project_shape(scenelike, space, rect::Rect, model)
function project_shape(@nospecialize(scenelike), space, rect::Rect, model)
mini = project_position(scenelike, space, minimum(rect), model)
maxi = project_position(scenelike, space, maximum(rect), model)
return Rect(mini, maxi .- mini)
end

function project_polygon(scenelike, space, poly::P, model) where P <: Polygon
function project_polygon(@nospecialize(scenelike), space, poly::P, model) where P <: Polygon
ext = decompose(Point2f, poly.exterior)
interiors = decompose.(Point2f, poly.interiors)
Polygon(
Expand All @@ -62,7 +62,7 @@ function project_polygon(scenelike, space, poly::P, model) where P <: Polygon
)
end

function project_multipolygon(scenelike, space, multipoly::MP, model) where MP <: MultiPolygon
function project_multipolygon(@nospecialize(scenelike), space, multipoly::MP, model) where MP <: MultiPolygon
return MultiPolygon(project_polygon.(Ref(scenelike), Ref(space), multipoly.polygons, Ref(model)))
end

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.9.5"
version = "0.9.6"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand Down Expand Up @@ -30,7 +30,7 @@ FreeTypeAbstraction = "0.10"
GLFW = "3.3"
GeometryBasics = "0.4.1"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.20.4"
Makie = "=0.20.5"
Markdown = "1.0, 1.6"
MeshIO = "0.4"
ModernGL = "1"
Expand Down
4 changes: 4 additions & 0 deletions GLMakie/src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ function Base.display(screen::Screen, scene::Scene; connect=true)
# So, the GLFW window events are not guarantee to fire
# when we close a window, so we ensure this here!
if !Makie.is_displayed(screen, scene)
if !isnothing(screen.root_scene)
delete!(screen, screen.root_scene)
screen.root_scene = nothing
end
display_scene!(screen, scene)
else
@assert screen.root_scene === scene "internal error. Scene already displayed by screen but not as root scene"
Expand Down
5 changes: 3 additions & 2 deletions GLMakie/src/drawing_primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,9 @@ function draw_atomic(screen::Screen, scene::Scene, plot::Surface)
end

space = plot.space

gl_attributes[:image] = img
interp = to_value(pop!(gl_attributes, :interpolate, true))
interp = interp ? :linear : :nearest
gl_attributes[:image] = Texture(img; minfilter=interp)

@assert to_value(plot[3]) isa AbstractMatrix
types = map(v -> typeof(to_value(v)), plot[1:2])
Expand Down
2 changes: 1 addition & 1 deletion MakieCore/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MakieCore"
uuid = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
authors = ["Simon Danisch"]
version = "0.7.2"
version = "0.7.3"

[deps]
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

## master

## 0.20.5

- Use plot plot instead of scene transform functions in CairoMakie, fixing missplaced h/vspan. [#3552](https://github.com/MakieOrg/Makie.jl/pull/3552)
- Fix error printing on shader error [#3530](https://github.com/MakieOrg/Makie.jl/pull/3530).
- Update pagefind to 1.0.4 for better headline search [#3534](https://github.com/MakieOrg/Makie.jl/pull/3534).
- Remove unecessary deps, e.g. Setfield [3546](https://github.com/MakieOrg/Makie.jl/pull/3546).
- Don't clear args, rely on delete deregister_callbacks [#3543](https://github.com/MakieOrg/Makie.jl/pull/3543).
- Add interpolate keyword for Surface [#3541](https://github.com/MakieOrg/Makie.jl/pull/3541).
- Fix a DataInspector bug if inspector_label is used with RGB images [#3468](https://github.com/MakieOrg/Makie.jl/pull/3468).

## 0.20.4

- Changes for Bonito rename and WGLMakie docs improvements [#3477](https://github.com/MakieOrg/Makie.jl/pull/3477).
Expand Down
4 changes: 2 additions & 2 deletions 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.20.4"
version = "0.20.5"

[deps]
Animations = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
Expand Down Expand Up @@ -88,7 +88,7 @@ KernelDensity = "0.5, 0.6"
LaTeXStrings = "1.2"
LinearAlgebra = "1.0, 1.6"
MacroTools = "0.5"
MakieCore = "=0.7.2"
MakieCore = "=0.7.3"
Markdown = "1.0, 1.6"
MathTeXEngine = "0.5"
Observables = "0.5.5"
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.6.4"
version = "0.6.5"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand All @@ -16,7 +16,7 @@ RadeonProRender = "27029320-176d-4a42-b57d-56729d2ad457"
Colors = "0.9, 0.10, 0.11, 0.12"
FileIO = "1.6"
GeometryBasics = "0.4.1"
Makie = "=0.20.4"
Makie = "=0.20.5"
RadeonProRender = "0.3.0"
julia = "1.3"
LinearAlgebra = "1.0, 1.6"
Expand Down
27 changes: 27 additions & 0 deletions ReferenceTests/src/tests/primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,30 @@ end

fig
end

@reference_test "Plot transform overwrite" begin
# Tests that (primitive) plots can have different transform function to their
# parent scene (identity in this case)
fig = Figure()

ax = Axis(fig[1, 1], xscale = log10, yscale = log10, backgroundcolor = :transparent)
xlims!(ax, 1, 10)
ylims!(ax, 1, 10)
empty!(ax.scene.lights)
hidedecorations!(ax)

heatmap!(ax, 0..0.5, 0..0.5, [i+j for i in 1:10, j in 1:10], transformation = Transformation())
image!(ax, 0..0.5, 0.5..1, [i+j for i in 1:10, j in 1:10], transformation = Transformation())
mesh!(ax, Rect2f(0.5, 0.0, 1.0, 0.25), transformation = Transformation(), color = :green)
p = surface!(ax, 0.5..1, 0.25..0.75, [i+j for i in 1:10, j in 1:10], transformation = Transformation())
translate!(p, Vec3f(0, 0, -20))
poly!(ax, Rect2f(0.5, 0.75, 1.0, 1.0), transformation = Transformation(), color = :blue)

lines!(ax, [0, 1], [0, 0.1], linewidth = 10, color = :red, transformation = Transformation())
linesegments!(ax, [0, 1], [0.2, 0.3], linewidth = 10, color = :red, transformation = Transformation())
scatter!(ax, [0.1, 0.9], [0.4, 0.5], markersize = 50, color = :red, transformation = Transformation())
text!(ax, Point2f(0.5, 0.45), text = "Test", fontsize = 50, color = :red, align = (:center, :center), transformation = Transformation())
meshscatter!(ax, [0.1, 0.9], [0.6, 0.7], markersize = 0.05, color = :red, transformation = Transformation())

fig
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 <[email protected]>"]
version = "0.9.4"
version = "0.9.5"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand All @@ -27,7 +27,7 @@ GeometryBasics = "0.4.1"
Hyperscript = "0.0.3, 0.0.4, 0.0.5"
Bonito = "3.0.0"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.20.4"
Makie = "=0.20.5"
Observables = "0.5.1"
PNGFiles = "0.3, 0.4"
PrecompileTools = "1.0"
Expand Down
3 changes: 2 additions & 1 deletion src/interaction/inspector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ function show_imagelike(inspector, plot, name, edge_based)
end

if haskey(plot, :inspector_label)
tt.text[] = plot[:inspector_label][](plot, (i, j), Point3f(pos[1], pos[2], z))
ins_p = z isa Colorant ? (pos[1], pos[2], z) : Point3f(pos[1], pos[2], z)
tt.text[] = plot[:inspector_label][](plot, (i, j), ins_p)
else
tt.text[] = color2text(name, x, y, z)
end
Expand Down
6 changes: 4 additions & 2 deletions src/makielayout/blocks/axis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1372,8 +1372,10 @@ function limits!(ax::Axis, rect::Rect2)
Makie.ylims!(ax, ymin, ymax)
end

function limits!(args...)
limits!(current_axis(), args...)
function limits!(args::Union{Nothing, Real, HyperRectangle}...)
axis = current_axis()
axis isa Nothing && error("There is no currently active axis!")
limits!(axis, args...)
end

Makie.transform_func(ax::Axis) = Makie.transform_func(ax.scene)
Expand Down
1 change: 1 addition & 0 deletions test/makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ end
@test ax.limits[] == (nothing, [5, 7])
@test ax.targetlimits[] == BBox(-5, 11, 5, 7)
@test ax.finallimits[] == BBox(-5, 11, 5, 7)
@test_throws MethodError limits!(f[1,1], -1, 1, -1, 1)
end

# issue 3240
Expand Down

0 comments on commit 5d2b355

Please sign in to comment.