Skip to content

Commit

Permalink
add clip_planes attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Jun 12, 2024
1 parent 61f1ecd commit a77b876
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion MakieCore/src/basic_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ default_theme(scene) = generic_plot_attributes!(Attributes())
- `depth_shift::Float32 = 0f0` adjusts the depth value of a plot after all other transformations, i.e. in clip space, where `0 <= depth <= 1`. This only applies to GLMakie and WGLMakie and can be used to adjust render order (like a tunable overdraw).
- `model::Makie.Mat4f` sets a model matrix for the plot. This replaces adjustments made with `translate!`, `rotate!` and `scale!`.
- `space::Symbol = :data` sets the transformation space for box encompassing the volume plot. See `Makie.spaces()` for possible inputs.
- `clip_planes`: TODO: docs
"""
function generic_plot_attributes!(attr)
attr[:transformation] = automatic
Expand All @@ -26,6 +27,7 @@ function generic_plot_attributes!(attr)
attr[:inspector_label] = automatic
attr[:inspector_clear] = automatic
attr[:inspector_hover] = automatic
attr[:clip_planes] = automatic
return attr
end

Expand All @@ -42,7 +44,9 @@ function generic_plot_attributes(attr)
space = attr[:space],
inspector_label = attr[:inspector_label],
inspector_clear = attr[:inspector_clear],
inspector_hover = attr[:inspector_hover]
inspector_hover = attr[:inspector_hover],
clip_planes = attr[:clip_planes]

)
end

Expand Down Expand Up @@ -73,6 +77,8 @@ function mixin_generic_plot_attributes()
inspector_clear = automatic
"Sets a callback function `(inspector, plot, index) -> ...` which replaces the default `show_data` methods."
inspector_hover = automatic
"TODO: docs"
clip_planes = automatic
end
end

Expand Down
5 changes: 5 additions & 0 deletions src/interfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,12 @@ function connect_plot!(parent::SceneLike, plot::Plot{F}) where {F}
plot.model = transformationmatrix(plot)
calculated_attributes!(Plot{F}, plot)
default_shading!(plot, parent_scene(parent))
if to_value(get(attributes(plot), :clip_planes, automatic)) === automatic
attributes(plot)[:clip_planes] = map(identity, plot, scene.theme[:clip_planes])
end

plot!(plot)

conversions = get_conversions(plot)
if !isnothing(conversions)
connect_conversions!(scene.conversions, conversions)
Expand Down
1 change: 1 addition & 0 deletions src/theming.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const MAKIE_DEFAULT_THEME = Attributes(
# N_samples = 64, # number of samples (requires shader reload)
),
inspectable = true,
clip_planes = Vector{Plane3f}(),

# Vec is equvalent to 36° right/east, 39° up/north from camera position
# The order here is Vec3f(right of, up from, towards) viewer/camera
Expand Down

0 comments on commit a77b876

Please sign in to comment.