pub struct Plot3DScope<'plot> { /* private fields */ }Expand description
A drawing interface borrowed from an open plot after setup has finished.
use dear_implot3d::Plot3DScope;
fn reconfigure(plot: &Plot3DScope<'_>) { plot.setup_box_scale(1.0, 1.0, 1.0); }use dear_implot3d::{Plot3DScope, Plot3DUi};
fn escape<'a>(ui: &Plot3DUi<'a>) -> &'a Plot3DScope<'a> {
ui.begin_plot("plot").build(|plot| plot).unwrap()
}Implementations§
Source§impl<'ui> Plot3DScope<'ui>
impl<'ui> Plot3DScope<'ui>
Sourcepub fn image_by_axes<'tex, T: Into<TextureRef<'tex>>>(
&'ui self,
label: impl Into<Cow<'ui, str>>,
tex: T,
center: [f32; 3],
axis_u: [f32; 3],
axis_v: [f32; 3],
) -> Image3DByAxesBuilder<'ui, 'tex>
pub fn image_by_axes<'tex, T: Into<TextureRef<'tex>>>( &'ui self, label: impl Into<Cow<'ui, str>>, tex: T, center: [f32; 3], axis_u: [f32; 3], axis_v: [f32; 3], ) -> Image3DByAxesBuilder<'ui, 'tex>
Image oriented by center and axes
Source§impl<'ui> Plot3DScope<'ui>
impl<'ui> Plot3DScope<'ui>
Source§impl Plot3DScope<'_>
impl Plot3DScope<'_>
Sourcepub fn next_colormap_color(&self) -> [f32; 4]
pub fn next_colormap_color(&self) -> [f32; 4]
Return the next color from this plot’s current colormap and advance its color cursor.
Source§impl<'plot> Plot3DScope<'plot>
impl<'plot> Plot3DScope<'plot>
Sourcepub unsafe fn with_next_plot3d_item_array_style<'a, R>(
&self,
style: Plot3DItemArrayStyle<'a>,
f: impl FnOnce(&Plot3DScope<'plot>) -> R,
) -> R
pub unsafe fn with_next_plot3d_item_array_style<'a, R>( &self, style: Plot3DItemArrayStyle<'a>, f: impl FnOnce(&Plot3DScope<'plot>) -> R, ) -> R
Apply array-backed item styling to the next ImPlot3D submission executed inside f.
This is closure-scoped so borrowed slices stay valid for the entire next
plot call and are restored even if f panics before submitting an item.
§Safety
Every non-empty style array must contain enough elements for every index the submitted plot
may read. Upstream accepts only pointers and carries no array lengths, so this cannot be
validated by this method. In particular, a surface’s wireframe can have more edges than
grid points. Only submissions to this plot consume the override. The native item reads
its arrays during submission and releases them in EndItem.
Source§impl Plot3DScope<'_>
impl Plot3DScope<'_>
Sourcepub fn set_next_line_style(&self, col: [f32; 4], weight: f32)
pub fn set_next_line_style(&self, col: [f32; 4], weight: f32)
Set the line style for the next ImPlot3D item submitted to this plot.
Sourcepub fn set_next_fill_style(&self, col: [f32; 4], alpha_mod: f32)
pub fn set_next_fill_style(&self, col: [f32; 4], alpha_mod: f32)
Set the fill style for the next ImPlot3D item submitted to this plot.
Source§impl<'ui> Plot3DScope<'ui>
impl<'ui> Plot3DScope<'ui>
Sourcepub fn surface_f32(
&'ui self,
label: impl Into<Cow<'ui, str>>,
xs: &'ui [f32],
ys: &'ui [f32],
zs: &'ui [f32],
) -> Surface3DBuilder<'ui>
pub fn surface_f32( &'ui self, label: impl Into<Cow<'ui, str>>, xs: &'ui [f32], ys: &'ui [f32], zs: &'ui [f32], ) -> Surface3DBuilder<'ui>
Start a surface plot (f32) from X/Y grid axes. Filled surfaces require finite Z samples.
Sourcepub fn surface_f32_flat<S: AsRef<str>>(
&self,
label: S,
xs_flat: &[f32],
ys_flat: &[f32],
zs: &[f32],
x_count: usize,
y_count: usize,
scale_min: f64,
scale_max: f64,
flags: Surface3DFlags,
) -> Result<(), Plot3DError>
pub fn surface_f32_flat<S: AsRef<str>>( &self, label: S, xs_flat: &[f32], ys_flat: &[f32], zs: &[f32], x_count: usize, y_count: usize, scale_min: f64, scale_max: f64, flags: Surface3DFlags, ) -> Result<(), Plot3DError>
Submit a surface from already flattened, contiguous per-vertex arrays.
xs_flat, ys_flat, and zs must each contain exactly x_count * y_count values. The
contiguous path does not accept an offset or stride; use Self::surface_f32_raw when
the native layout is intentionally non-contiguous.
Filled surfaces require finite Z samples. Pass two zeros for automatic color scaling over their range.
use dear_implot3d::{Plot3DError, Plot3DScope, Surface3DFlags};
fn submit(plot_ui: &Plot3DScope<'_>) -> Result<(), Plot3DError> {
let xs = [0.0, 1.0, 0.0, 1.0];
let ys = [0.0, 0.0, 1.0, 1.0];
let zs = [0.0, 1.0, 1.0, 2.0];
plot_ui.surface_f32_flat(
"surface",
&xs,
&ys,
&zs,
2,
2,
0.0,
0.0,
Surface3DFlags::NONE,
)
}Sourcepub unsafe fn surface_f32_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
x_count: usize,
y_count: usize,
scale_min: f64,
scale_max: f64,
flags: Surface3DFlags,
layout: Plot3DDataLayout,
) -> Result<(), Plot3DError>
pub unsafe fn surface_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], x_count: usize, y_count: usize, scale_min: f64, scale_max: f64, flags: Surface3DFlags, layout: Plot3DDataLayout, ) -> Result<(), Plot3DError>
Submit a surface with an explicitly arbitrary native data layout. Filled surfaces require finite Z samples.
§Safety
For each of the x_count * y_count samples, layout must address an initialized,
properly aligned, readable f32 in each coordinate allocation for the duration of the
call. The slices need not be exactly x_count * y_count elements because a custom stride
may address a larger allocation.
Calling this arbitrary-layout API without an unsafe block is rejected:
use dear_implot3d::{Plot3DDataLayout, Plot3DScope, Surface3DFlags};
fn submit(plot_ui: &Plot3DScope<'_>) {
let values = [0.0; 4];
let _ = plot_ui.surface_f32_raw(
"surface",
&values,
&values,
&values,
2,
2,
0.0,
0.0,
Surface3DFlags::NONE,
Plot3DDataLayout::DEFAULT,
);
}Source§impl Plot3DScope<'_>
impl Plot3DScope<'_>
Sourcepub fn plot_line_f32<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Line3DFlags,
)
pub fn plot_line_f32<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Line3DFlags, )
Convenience: plot a simple 3D line (f32)
This is a quick way to plot a line without using the builder pattern.
For more control, use the plots::Line3D builder.
§Arguments
label- Label for the legendxs- X coordinatesys- Y coordinateszs- Z coordinatesflags- Line flags (e.g.,Line3DFlags::SEGMENTS,Line3DFlags::LOOP)
§Example
use dear_implot3d::*;
let xs = [0.0, 1.0, 2.0];
let ys = [0.0, 1.0, 0.0];
let zs = [0.0, 0.5, 1.0];
plot_ui.plot_line_f32("Line", &xs, &ys, &zs, Line3DFlags::NONE);Sourcepub unsafe fn plot_line_f32_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Line3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_line_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Line3DFlags, layout: Plot3DDataLayout, )
Line plot (f32) with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f32
within each coordinate allocation. All three allocations must remain alive for this call.
Sourcepub fn plot_line_f64<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Line3DFlags,
)
pub fn plot_line_f64<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Line3DFlags, )
Convenience: plot a simple 3D line (f64)
Sourcepub unsafe fn plot_line_f64_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Line3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_line_f64_raw<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Line3DFlags, layout: Plot3DDataLayout, )
Line plot (f64) with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f64
within each coordinate allocation. All three allocations must remain alive for this call.
Sourcepub fn plot_scatter_f32<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Scatter3DFlags,
)
pub fn plot_scatter_f32<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Scatter3DFlags, )
Convenience: plot a 3D scatter (f32)
Sourcepub unsafe fn plot_scatter_f32_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Scatter3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_scatter_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Scatter3DFlags, layout: Plot3DDataLayout, )
Scatter plot (f32) with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f32
within each coordinate allocation. All three allocations must remain alive for this call.
Sourcepub fn plot_scatter_f64<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Scatter3DFlags,
)
pub fn plot_scatter_f64<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Scatter3DFlags, )
Convenience: plot a 3D scatter (f64)
Sourcepub unsafe fn plot_scatter_f64_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Scatter3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_scatter_f64_raw<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Scatter3DFlags, layout: Plot3DDataLayout, )
Scatter plot (f64) with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f64
within each coordinate allocation. All three allocations must remain alive for this call.
Sourcepub fn plot_triangles_f32<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Triangle3DFlags,
)
pub fn plot_triangles_f32<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Triangle3DFlags, )
Convenience: plot triangles from separate X/Y/Z arrays (count must be multiple of 3)
Sourcepub unsafe fn plot_triangles_f32_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Triangle3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_triangles_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Triangle3DFlags, layout: Plot3DDataLayout, )
Plot f32 triangle coordinates with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f32
within each coordinate allocation. All three allocations must remain alive for this call.
Sourcepub fn plot_quads_f32<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Quad3DFlags,
)
pub fn plot_quads_f32<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Quad3DFlags, )
Convenience: plot quads from separate X/Y/Z arrays (count must be multiple of 4)
Sourcepub unsafe fn plot_quads_f32_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f32],
ys: &[f32],
zs: &[f32],
flags: Quad3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_quads_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Quad3DFlags, layout: Plot3DDataLayout, )
Plot f32 quad coordinates with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f32
within each coordinate allocation. All three allocations must remain alive for this call.
Sourcepub fn plot_triangles_f64<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Triangle3DFlags,
)
pub fn plot_triangles_f64<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Triangle3DFlags, )
Convenience: plot triangles from separate X/Y/Z arrays (f64)
Sourcepub unsafe fn plot_triangles_f64_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Triangle3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_triangles_f64_raw<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Triangle3DFlags, layout: Plot3DDataLayout, )
Plot f64 triangle coordinates with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f64
within each coordinate allocation. All three allocations must remain alive for this call.
Sourcepub fn plot_quads_f64<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Quad3DFlags,
)
pub fn plot_quads_f64<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Quad3DFlags, )
Convenience: plot quads from separate X/Y/Z arrays (f64)
Sourcepub unsafe fn plot_quads_f64_raw<S: AsRef<str>>(
&self,
label: S,
xs: &[f64],
ys: &[f64],
zs: &[f64],
flags: Quad3DFlags,
layout: Plot3DDataLayout,
)
pub unsafe fn plot_quads_f64_raw<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Quad3DFlags, layout: Plot3DDataLayout, )
Plot f64 quad coordinates with an explicit data layout.
§Safety
For every submitted index, layout must address an initialized, properly aligned f64
within each coordinate allocation. All three allocations must remain alive for this call.
Source§impl Plot3DScope<'_>
impl Plot3DScope<'_>
Sourcepub fn plot_draw_list(&self) -> DrawListMut<'_>
pub fn plot_draw_list(&self) -> DrawListMut<'_>
Borrows the draw list of the window hosting this plot.