pub struct PlotRenderer {
pub wgpu_renderer: WgpuRenderer,
pub scene: Scene,
pub theme: PlotThemeConfig,
/* private fields */
}Expand description
Unified plot renderer that handles both interactive and static rendering
Fields§
§wgpu_renderer: WgpuRendererWGPU renderer for GPU-accelerated rendering
scene: SceneCurrent scene being rendered
theme: PlotThemeConfigCurrent theme configuration
Implementations§
Source§impl PlotRenderer
impl PlotRenderer
Sourcepub fn on_surface_config_updated(&mut self)
pub fn on_surface_config_updated(&mut self)
Notify the renderer that the underlying surface configuration has changed (e.g. resize). On wasm the canvas is often created at a tiny size and resized shortly after; some CPU-generated geometry (like thick 2D lines) depends on viewport pixels, so we rebuild the scene when the surface extent changes.
Sourcepub async fn new(
device: Arc<Device>,
queue: Arc<Queue>,
surface_config: SurfaceConfiguration,
) -> Result<Self, Box<dyn Error>>
pub async fn new( device: Arc<Device>, queue: Arc<Queue>, surface_config: SurfaceConfiguration, ) -> Result<Self, Box<dyn Error>>
Create a new plot renderer
pub fn axes_has_3d_content(&self, axes_index: usize) -> bool
Sourcepub fn note_camera_interaction(&mut self)
pub fn note_camera_interaction(&mut self)
Mark that the user has interacted with the camera (disable auto-fit-on-update).
pub fn note_axes_camera_interaction(&mut self, axes_index: usize)
Sourcepub fn set_figure(&mut self, figure: Figure)
pub fn set_figure(&mut self, figure: Figure)
Set the figure to render
pub fn ensure_scene_viewport_dependent_geometry_for_axes( &mut self, axes_plot_sizes_px: &[(u32, u32)], )
Sourcepub fn calculate_data_bounds(&mut self) -> Option<(f64, f64, f64, f64)>
pub fn calculate_data_bounds(&mut self) -> Option<(f64, f64, f64, f64)>
Calculate data bounds from scene
Sourcepub fn fit_camera_to_data(&mut self) -> bool
pub fn fit_camera_to_data(&mut self) -> bool
Fit camera to show all data.
Returns true if a fit was applied (i.e. bounds existed).
Sourcepub fn fit_extents(&mut self)
pub fn fit_extents(&mut self)
Explicit “Fit Extents” action (CAD-like). Fits the camera to current data once.
Sourcepub fn reset_camera_position(&mut self)
pub fn reset_camera_position(&mut self)
Explicit “Reset Camera” action. Restores the default orientation without re-framing.
For 3D, this resets the view direction around the current data center (or current target) while preserving the current zoom distance. For 2D, this is equivalent to Fit Extents (since “home” without data bounds is rarely useful).
Sourcepub fn render_to_viewport(
&mut self,
encoder: &mut CommandEncoder,
target_view: &TextureView,
_viewport: (f32, f32, f32, f32),
clear_background: bool,
background_color: Option<Vec4>,
) -> Result<RenderResult, Box<dyn Error>>
pub fn render_to_viewport( &mut self, encoder: &mut CommandEncoder, target_view: &TextureView, _viewport: (f32, f32, f32, f32), clear_background: bool, background_color: Option<Vec4>, ) -> Result<RenderResult, Box<dyn Error>>
Render the current scene to a specific viewport within a texture/surface
Sourcepub fn render(
&mut self,
encoder: &mut CommandEncoder,
target: RenderTarget<'_>,
config: &PlotRenderConfig,
) -> Result<RenderResult, Box<dyn Error>>
pub fn render( &mut self, encoder: &mut CommandEncoder, target: RenderTarget<'_>, config: &PlotRenderConfig, ) -> Result<RenderResult, Box<dyn Error>>
Render the current scene to a texture/surface
Sourcepub fn render_scene_to_target(
&mut self,
encoder: &mut CommandEncoder,
target_view: &TextureView,
config: &PlotRenderConfig,
) -> Result<RenderResult, Box<dyn Error>>
pub fn render_scene_to_target( &mut self, encoder: &mut CommandEncoder, target_view: &TextureView, config: &PlotRenderConfig, ) -> Result<RenderResult, Box<dyn Error>>
Shared scene orchestration for non-overlay render targets.
For single-axes figures this follows the direct full-target render path. For subplot grids, it renders each axes into a deterministic tiled viewport layout.
Sourcepub fn render_camera_to_viewport(
&mut self,
encoder: &mut CommandEncoder,
target_view: &TextureView,
viewport_scissor: (u32, u32, u32, u32),
config: &PlotRenderConfig,
camera: &Camera,
axes_index: usize,
clear_background: bool,
) -> Result<RenderResult, Box<dyn Error>>
pub fn render_camera_to_viewport( &mut self, encoder: &mut CommandEncoder, target_view: &TextureView, viewport_scissor: (u32, u32, u32, u32), config: &PlotRenderConfig, camera: &Camera, axes_index: usize, clear_background: bool, ) -> Result<RenderResult, Box<dyn Error>>
Render using the camera-based pipeline into a viewport region with a scissor rectangle. This preserves existing contents (Load) and draws only inside the viewport rectangle.
Sourcepub fn render_axes_to_viewports(
&mut self,
encoder: &mut CommandEncoder,
target_view: &TextureView,
axes_viewports: &[(u32, u32, u32, u32)],
msaa_samples: u32,
base_config: &PlotRenderConfig,
) -> Result<(), Box<dyn Error>>
pub fn render_axes_to_viewports( &mut self, encoder: &mut CommandEncoder, target_view: &TextureView, axes_viewports: &[(u32, u32, u32, u32)], msaa_samples: u32, base_config: &PlotRenderConfig, ) -> Result<(), Box<dyn Error>>
Render all axes of a subplot grid into their respective viewport rectangles.
axes_viewports is a vector of (x, y, w, h) in physical pixels, length equals rows*cols.
Sourcepub fn camera_mut(&mut self) -> &mut Camera
pub fn camera_mut(&mut self) -> &mut Camera
Get mutable reference to the primary (axes 0) camera.
pub fn axes_camera(&self, axes_index: usize) -> Option<&Camera>
Sourcepub fn scene_statistics(&self) -> SceneStatistics
pub fn scene_statistics(&self) -> SceneStatistics
Get scene statistics
Sourcepub fn view_bounds(&self) -> Option<(f64, f64, f64, f64)>
pub fn view_bounds(&self) -> Option<(f64, f64, f64, f64)>
Get current view bounds (camera frustum) in world/data space for 2D
Sourcepub fn overlay_show_grid(&self) -> bool
pub fn overlay_show_grid(&self) -> bool
Overlay configuration getters
pub fn overlay_show_grid_for_axes(&self, axes_index: usize) -> bool
pub fn overlay_show_box(&self) -> bool
pub fn overlay_show_box_for_axes(&self, axes_index: usize) -> bool
pub fn overlay_title(&self) -> Option<&String>
pub fn overlay_title_for_axes(&self, axes_index: usize) -> Option<&String>
pub fn overlay_x_label(&self) -> Option<&String>
pub fn overlay_x_label_for_axes(&self, axes_index: usize) -> Option<&String>
pub fn overlay_x_label_style_for_axes( &self, axes_index: usize, ) -> Option<&TextStyle>
pub fn overlay_y_label(&self) -> Option<&String>
pub fn overlay_y_label_for_axes(&self, axes_index: usize) -> Option<&String>
pub fn overlay_y_label_style_for_axes( &self, axes_index: usize, ) -> Option<&TextStyle>
pub fn overlay_z_label(&self) -> Option<&String>
pub fn overlay_z_label_for_axes(&self, axes_index: usize) -> Option<&String>
pub fn overlay_z_label_style_for_axes( &self, axes_index: usize, ) -> Option<&TextStyle>
pub fn active_axes_pie_labels(&self) -> Vec<(String, Vec2)>
pub fn pie_labels_for_axes(&self, axes_index: usize) -> Vec<(String, Vec2)>
pub fn world_text_annotations_for_axes( &self, axes_index: usize, ) -> Vec<(Vec3, String, TextStyle)>
pub fn world_axis_label_annotations_for_axes( &self, axes_index: usize, ) -> Vec<(Vec3, String, TextStyle)>
pub fn overlay_show_legend(&self) -> bool
pub fn overlay_show_legend_for_axes(&self, axes_index: usize) -> bool
pub fn overlay_legend_entries(&self) -> &Vec<LegendEntry>
pub fn overlay_legend_entries_for_axes( &self, axes_index: usize, ) -> Vec<LegendEntry>
pub fn overlay_x_log(&self) -> bool
pub fn overlay_x_log_for_axes(&self, axes_index: usize) -> bool
pub fn overlay_y_log(&self) -> bool
pub fn overlay_y_log_for_axes(&self, axes_index: usize) -> bool
pub fn overlay_colormap(&self) -> ColorMap
pub fn overlay_colorbar_enabled(&self) -> bool
Sourcepub fn figure_axes_grid(&self) -> (usize, usize)
pub fn figure_axes_grid(&self) -> (usize, usize)
Subplot grid
Sourcepub fn overlay_categorical_labels(&self) -> Option<(bool, &Vec<String>)>
pub fn overlay_categorical_labels(&self) -> Option<(bool, &Vec<String>)>
Return categorical labels if any (is_x_axis, &labels)
pub fn overlay_categorical_labels_for_axes( &self, axes_index: usize, ) -> Option<(bool, Vec<String>)>
pub fn overlay_histogram_edges_for_axes( &self, axes_index: usize, ) -> Option<(bool, Vec<f64>)>
Sourcepub fn overlay_display_bounds_for_axes(
&self,
axes_index: usize,
) -> Option<(f64, f64, f64, f64)>
pub fn overlay_display_bounds_for_axes( &self, axes_index: usize, ) -> Option<(f64, f64, f64, f64)>
Get stable display bounds for an axes (data/explicit limits), excluding transient pan/zoom.
Sourcepub fn data_bounds(&self) -> Option<(f64, f64, f64, f64)>
pub fn data_bounds(&self) -> Option<(f64, f64, f64, f64)>
Get bounds used for display (manual axis limits override data bounds when provided)
Sourcepub fn axes_camera_mut(&mut self, idx: usize) -> Option<&mut Camera>
pub fn axes_camera_mut(&mut self, idx: usize) -> Option<&mut Camera>
Get mutable reference to a specific axes camera when using subplots
Sourcepub fn view_bounds_for_axes(&self, idx: usize) -> Option<(f64, f64, f64, f64)>
pub fn view_bounds_for_axes(&self, idx: usize) -> Option<(f64, f64, f64, f64)>
Get view bounds for a specific axes camera (l, r, b, t)
pub fn axes_bounds(&self, axes_index: usize) -> Option<BoundingBox>
Sourcepub fn export_figure_clone(&self) -> Figure
pub fn export_figure_clone(&self) -> Figure
Prefer exporting the original figure if available
Auto Trait Implementations§
impl !Freeze for PlotRenderer
impl !RefUnwindSafe for PlotRenderer
impl Send for PlotRenderer
impl !Sync for PlotRenderer
impl Unpin for PlotRenderer
impl UnsafeUnpin for PlotRenderer
impl !UnwindSafe for PlotRenderer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more