Skip to main content

Plot3DUi

Struct Plot3DUi 

Source
pub struct Plot3DUi<'ui> { /* private fields */ }
Expand description

Per-frame access helper mirroring dear-implot

This provides access to all 3D plotting functions. It is tied to the lifetime of the current ImGui frame and should be obtained via Plot3DContext::get_plot_ui().

§Example

use dear_implot3d::*;

if let Some(_token) = plot_ui.begin_plot("My 3D Plot").build() {
    plot_ui.setup_axes("X", "Y", "Z", Axis3DFlags::NONE, Axis3DFlags::NONE, Axis3DFlags::NONE);

    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);
}

Implementations§

Source§

impl Plot3DUi<'_>

Source

pub fn show_all_demos(&self)

Show upstream ImPlot3D demos (from C++ demo).

This displays all available ImPlot3D demos in a single window. Useful for learning and testing the library.

Source

pub fn show_demo_window(&self)

Show the main ImPlot3D demo window (C++ upstream).

This displays the main demo window with tabs for different plot types.

Source

pub fn show_demo_window_with_flag(&self, p_open: &mut bool)

Show the main ImPlot3D demo window with a visibility flag.

Source

pub fn show_style_editor(&self)

Show the ImPlot3D style editor window.

This displays a window for editing ImPlot3D style settings in real time.

Source

pub fn show_metrics_window(&self)

Show the ImPlot3D metrics/debugger window.

This displays performance metrics and debugging information.

Source

pub fn show_metrics_window_with_flag(&self, p_open: &mut bool)

Show the ImPlot3D metrics/debugger window with a visibility flag.

Source§

impl<'ui> Plot3DUi<'ui>

Source

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

pub fn image_by_corners<'tex, T: Into<TextureRef<'tex>>>( &'ui self, label: impl Into<Cow<'ui, str>>, tex: T, p0: [f32; 3], p1: [f32; 3], p2: [f32; 3], p3: [f32; 3], ) -> Image3DByCornersBuilder<'ui, 'tex>

Image by 4 corner points (p0..p3)

Source§

impl<'ui> Plot3DUi<'ui>

Source

pub fn mesh( &'ui self, label: impl Into<Cow<'ui, str>>, vertices: &'ui [[f32; 3]], indices: &'ui [u32], ) -> Mesh3DBuilder<'ui>

Start a mesh plot from vertices (x,y,z) and triangle indices

Source§

impl<'ui> Plot3DUi<'ui>

Source

pub fn push_colormap(&self, cmap: impl Into<ColormapIndex>) -> ColormapToken<'_>

Source

pub fn push_colormap_name(&self, name: &str) -> ColormapToken<'_>

Source§

impl Plot3DUi<'_>

Source

pub fn colormap_color(&self, index: ColormapColorIndex) -> [f32; 4]

Return a color from this UI’s active ImPlot3D colormap.

Source

pub fn next_colormap_color(&self) -> [f32; 4]

Return the next color from this UI’s current colormap and advance its color cursor.

Source§

impl<'ui> Plot3DUi<'ui>

Source

pub fn with_next_plot3d_item_array_style<'a, R>( &self, style: Plot3DItemArrayStyle<'a>, f: impl FnOnce(&Plot3DUi<'ui>) -> 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.

Source§

impl<'ui> Plot3DUi<'ui>

Source

pub fn push_style_color( &self, element: Plot3DColorElement, col: [f32; 4], ) -> StyleColorToken<'_>

Push a style color override to this ImPlot3D context’s stack.

Source

pub fn push_style_color_element( &self, element: Plot3DColorElement, col: [f32; 4], ) -> StyleColorToken<'_>

Push a typed style color override.

Source

pub fn push_style_var_f32( &self, var: Plot3DStyleVar, val: f32, ) -> StyleVarToken<'_>

Push a style variable (float variant).

Source

pub fn push_style_var_marker(&self, marker: Marker3D) -> StyleVarToken<'_>

Push the default marker style variable.

Source

pub fn push_style_var_vec2( &self, var: Plot3DStyleVar, val: [f32; 2], ) -> StyleVarToken<'_>

Push a style variable (Vec2 variant).

Source§

impl Plot3DUi<'_>

Source

pub fn set_next_line_style(&self, col: [f32; 4], weight: f32)

Set the line style for the next ImPlot3D item submitted through this context.

Source

pub fn set_next_fill_style(&self, col: [f32; 4], alpha_mod: f32)

Set the fill style for the next ImPlot3D item submitted through this context.

Source

pub fn set_next_marker_style( &self, marker: Marker3D, size: f32, fill: [f32; 4], weight: f32, outline: [f32; 4], )

Set the marker style for the next ImPlot3D item submitted through this context.

Source§

impl<'ui> Plot3DUi<'ui>

Source

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)

Source

pub fn surface_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], scale_min: f64, scale_max: f64, flags: Surface3DFlags, layout: Plot3DDataLayout, )

Raw surface plot (f32) with an explicit data layout.

Source

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, layout: Plot3DDataLayout, )

Plot a surface with already flattened per-vertex X/Y arrays (no internal allocation)

Use this when you already have per-vertex xs_flat and ys_flat of length x_count * y_count, matching the layout of zs. This avoids per-frame allocations for large dynamic grids.

Source§

impl<'ui> Plot3DUi<'ui>

Source

pub fn begin_plot<S: AsRef<str>>(&self, title: S) -> Plot3DBuilder<'ui>

Builder to configure and begin a 3D plot

Returns a Plot3DBuilder that allows you to configure the plot before calling .build().

§Example
use dear_implot3d::*;

if let Some(_token) = plot_ui
    .begin_plot("My Plot")
    .size([600.0, 400.0])
    .flags(Plot3DFlags::NO_LEGEND)
    .build()
{
    // Plot content here
}
Source

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 legend
  • xs - X coordinates
  • ys - Y coordinates
  • zs - Z coordinates
  • flags - 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);
Source

pub 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.

Source

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)

Source

pub 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.

Source

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)

Source

pub 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.

Source

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)

Source

pub 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.

Source

pub fn plot_triangles_f32<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Triangle3DFlags, )

Convenience: plot triangles from interleaved xyz arrays (count must be multiple of 3)

Source

pub fn plot_triangles_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Triangle3DFlags, layout: Plot3DDataLayout, )

Source

pub fn plot_quads_f32<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Quad3DFlags, )

Convenience: plot quads from interleaved xyz arrays (count must be multiple of 4)

Source

pub fn plot_quads_f32_raw<S: AsRef<str>>( &self, label: S, xs: &[f32], ys: &[f32], zs: &[f32], flags: Quad3DFlags, layout: Plot3DDataLayout, )

Source

pub fn plot_triangles_f64<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Triangle3DFlags, )

Convenience: plot triangles from interleaved xyz arrays (f64)

Source

pub fn plot_triangles_f64_raw<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Triangle3DFlags, layout: Plot3DDataLayout, )

Source

pub fn plot_quads_f64<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Quad3DFlags, )

Convenience: plot quads from interleaved xyz arrays (f64)

Source

pub fn plot_quads_f64_raw<S: AsRef<str>>( &self, label: S, xs: &[f64], ys: &[f64], zs: &[f64], flags: Quad3DFlags, layout: Plot3DDataLayout, )

Source§

impl<'ui> Plot3DUi<'ui>

Axis helpers

Source

pub fn setup_axes( &self, x_label: &str, y_label: &str, z_label: &str, x_flags: Axis3DFlags, y_flags: Axis3DFlags, z_flags: Axis3DFlags, )

Source

pub fn setup_axis(&self, axis: Axis3D, label: &str, flags: Axis3DFlags)

Source

pub fn setup_axis_limits( &self, axis: Axis3D, min: f64, max: f64, cond: Plot3DCond, )

Source

pub fn setup_axes_limits( &self, x_min: f64, x_max: f64, y_min: f64, y_max: f64, z_min: f64, z_max: f64, cond: Plot3DCond, )

Source

pub fn setup_axis_limits_constraints( &self, axis: Axis3D, v_min: f64, v_max: f64, )

Source

pub fn setup_axis_zoom_constraints(&self, axis: Axis3D, z_min: f64, z_max: f64)

Source

pub fn setup_axis_ticks_values( &self, axis: Axis3D, values: &[f64], labels: Option<&[&str]>, keep_default: bool, )

Setup axis ticks using explicit positions and optional labels.

If labels is provided, it must have the same length as values.

Source

pub fn setup_axis_ticks_range( &self, axis: Axis3D, v_min: f64, v_max: f64, n_ticks: usize, labels: Option<&[&str]>, keep_default: bool, )

Source

pub fn setup_box_scale(&self, x: f32, y: f32, z: f32)

Source

pub fn setup_box_rotation( &self, elevation: f32, azimuth: f32, animate: bool, cond: Plot3DCond, )

Source

pub fn setup_box_initial_rotation(&self, elevation: f32, azimuth: f32)

Source

pub fn plot_text( &self, text: &str, x: f32, y: f32, z: f32, angle: f32, pix_offset: [f32; 2], )

Source

pub fn plot_to_pixels(&self, point: [f32; 3]) -> [f32; 2]

Source

pub fn get_frame_pos(&self) -> [f32; 2]

Source

pub fn get_frame_size(&self) -> [f32; 2]

Auto Trait Implementations§

§

impl<'ui> !RefUnwindSafe for Plot3DUi<'ui>

§

impl<'ui> !Send for Plot3DUi<'ui>

§

impl<'ui> !Sync for Plot3DUi<'ui>

§

impl<'ui> !UnwindSafe for Plot3DUi<'ui>

§

impl<'ui> Freeze for Plot3DUi<'ui>

§

impl<'ui> Unpin for Plot3DUi<'ui>

§

impl<'ui> UnsafeUnpin for Plot3DUi<'ui>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more