Skip to main content

dear_implot3d/
lib.rs

1//! Dear ImPlot3D - Rust bindings (high level)
2//!
3//! Safe wrapper over `dear-implot3d-sys`, designed to integrate with
4//! `dear-imgui-rs`. Mirrors `dear-implot` design: context + Ui facade,
5//! builder-style helpers, optional `mint` inputs.
6//!
7//! # Quick Start
8//!
9//! ```no_run
10//! use dear_imgui_rs::*;
11//! use dear_implot3d::*;
12//!
13//! let mut imgui_ctx = Context::create();
14//! let plot3d_ctx = Plot3DContext::create(&imgui_ctx);
15//!
16//! // In your main loop:
17//! let ui = imgui_ctx.frame();
18//! let plot_ui = plot3d_ctx.get_plot_ui(&ui);
19//!
20//! if let Some(_token) = plot_ui.begin_plot("3D Plot").build() {
21//!     let xs = [0.0, 1.0, 2.0];
22//!     let ys = [0.0, 1.0, 0.0];
23//!     let zs = [0.0, 0.5, 1.0];
24//!     plot_ui.plot_line_f32("Line", &xs, &ys, &zs, Line3DFlags::NONE);
25//! }
26//! ```
27//!
28//! # Features
29//!
30//! - **mint**: Enable support for `mint` math types (Point3, Vector3)
31//!
32//! # Architecture
33//!
34//! This crate follows the same design patterns as `dear-implot`:
35//! - `Plot3DContext`: Manages the ImPlot3D context (create once)
36//! - `Plot3DUi`: Per-frame access to plotting functions
37//! - RAII tokens: `Plot3DToken` automatically calls `EndPlot` on drop
38//! - Builder pattern: Fluent API for configuring plots
39//! - Type-safe flags: Using `bitflags!` for compile-time safety
40
41pub(crate) use dear_imgui_rs::sys as imgui_sys;
42pub use dear_imgui_rs::{Context, Ui};
43pub(crate) use dear_implot3d_sys as sys;
44
45mod builder;
46mod context;
47mod debug_state;
48mod demos;
49mod flags;
50mod image_builder;
51mod item_style;
52mod layout;
53mod mesh_builder;
54pub mod meshes;
55pub mod plots;
56mod style;
57mod surface_builder;
58mod ui;
59
60mod axis;
61
62pub use builder::Plot3DBuilder;
63pub use context::Plot3DContext;
64pub use flags::*;
65pub use image_builder::{Image3DByAxesBuilder, Image3DByCornersBuilder};
66pub use item_style::*;
67pub use layout::{Plot3DDataLayout, Plot3DDataOffset, Plot3DDataStride};
68pub use mesh_builder::Mesh3DBuilder;
69pub use plots::*;
70pub use style::*;
71pub use surface_builder::Surface3DBuilder;
72pub use ui::{Plot3DToken, Plot3DUi};
73
74pub(crate) use debug_state::{
75    debug_before_plot, debug_before_setup, debug_begin_plot, debug_end_plot,
76};
77pub(crate) use layout::{
78    axis_tick_count_to_i32, default_plot3d_spec, imvec2, imvec4, len_i32, plot3d_spec_from,
79    set_next_plot3d_spec, take_next_plot3d_spec, update_next_plot3d_spec,
80};