Makie.jl icon indicating copy to clipboard operation
Makie.jl copied to clipboard

Add clipping planes

Open ffreyer opened this issue 8 months ago • 7 comments

Description

Redo/Continuation of #2783.

Adds a clip_planes attribute to plots, allowing for up to 8 clipping planes to be defined (hard limit set in OpenGL). This will allow for Axis3 to clip a world space rectangle, which is the main blocker for zooming (and camera translation?) in Axis3.

Example Rect-based clip:

f = Figure()
a = LScene(f[1, 1])

# inherit from scene by default for Axis3
a.scene.theme[:clip_planes][] = Makie.planes(Rect3f(Point3f(-0.75), Vec3f(1.5)))

# allow overwrite to e.g. visualize planes
linesegments!(
    a, Rect3f(Point3f(-0.75), Vec3f(1.5)), clip_planes = Plane3f[],
    fxaa = true, transparency = false, linewidth = 3)

p = mesh!(Sphere(Point3f(0,0,1), 1f0), transparency = false, color = :orange, backlight = 1.0)
r = range(-pi, pi, length = 101)
surface!(-pi..pi, -pi..pi, [sin(x + y) for x in r, y in r], transparency = false)
scatter!(r, r)
f

Screenshot 2024-06-13 150140

TODO:

  • [x] basic GLMakie implementation
  • [x] basic WGLMakie implementation
  • [x] basic CairoMakie implementation
  • [x] use parent plot instead of parent scene for automatic replacement for simpler attribute handling (i.e. avoid every plot needing to inherit explicitly)
  • [x] include clipping planes in boundingbox calculation
  • [x] fix volume
  • [x] fix line clipping (inconsistent length)
  • [x] fix line flickering in WGLMakie
  • [x] maybe adjust voxels to clip full voxels
  • [x] care for space (ignore anything but :data?)
  • [x] CairoMakie overrides
  • [x] fix boundingboxes clipping (see voxel example)
  • [ ] fix line color interpolation

Related #1655, #1667 Closes #3908

Type of change

  • [x] New feature (non-breaking change which adds functionality)

Checklist

  • [ ] Added an entry in CHANGELOG.md (for new features and breaking changes)
  • [ ] Added or changed relevant sections in the documentation
  • [ ] Added unit tests for new algorithms, conversion methods, etc.
  • [ ] Added reference image tests for new plotting functions, recipes, visual options, etc.

ffreyer avatar Jun 13 '24 13:06 ffreyer