Skip to main content

PlotRenderer

Struct PlotRenderer 

Source
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: WgpuRenderer

WGPU renderer for GPU-accelerated rendering

§scene: Scene

Current scene being rendered

§theme: PlotThemeConfig

Current theme configuration

Implementations§

Source§

impl PlotRenderer

Source

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.

Source

pub async fn new( device: Arc<Device>, queue: Arc<Queue>, surface_config: SurfaceConfiguration, ) -> Result<Self, Box<dyn Error>>

Create a new plot renderer

Source

pub fn axes_has_3d_content(&self, axes_index: usize) -> bool

Source

pub fn note_camera_interaction(&mut self)

Mark that the user has interacted with the camera (disable auto-fit-on-update).

Source

pub fn note_axes_camera_interaction(&mut self, axes_index: usize)

Source

pub fn set_figure(&mut self, figure: Figure)

Set the figure to render

Source

pub fn ensure_scene_viewport_dependent_geometry_for_axes( &mut self, axes_plot_sizes_px: &[(u32, u32)], )

Source

pub fn calculate_data_bounds(&mut self) -> Option<(f64, f64, f64, f64)>

Calculate data bounds from scene

Source

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

Source

pub fn fit_extents(&mut self)

Explicit “Fit Extents” action (CAD-like). Fits the camera to current data once.

Source

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

Source

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

Source

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

Source

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.

Source

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.

Source

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.

Source

pub fn camera(&self) -> &Camera

Get the primary (axes 0) camera.

Source

pub fn camera_mut(&mut self) -> &mut Camera

Get mutable reference to the primary (axes 0) camera.

Source

pub fn axes_camera(&self, axes_index: usize) -> Option<&Camera>

Source

pub fn scene(&self) -> &Scene

Get scene reference

Source

pub fn scene_statistics(&self) -> SceneStatistics

Get scene statistics

Source

pub fn view_bounds(&self) -> Option<(f64, f64, f64, f64)>

Get current view bounds (camera frustum) in world/data space for 2D

Source

pub fn overlay_show_grid(&self) -> bool

Overlay configuration getters

Source

pub fn overlay_show_grid_for_axes(&self, axes_index: usize) -> bool

Source

pub fn overlay_show_box(&self) -> bool

Source

pub fn overlay_show_box_for_axes(&self, axes_index: usize) -> bool

Source

pub fn overlay_title(&self) -> Option<&String>

Source

pub fn overlay_title_for_axes(&self, axes_index: usize) -> Option<&String>

Source

pub fn overlay_x_label(&self) -> Option<&String>

Source

pub fn overlay_x_label_for_axes(&self, axes_index: usize) -> Option<&String>

Source

pub fn overlay_x_label_style_for_axes( &self, axes_index: usize, ) -> Option<&TextStyle>

Source

pub fn overlay_y_label(&self) -> Option<&String>

Source

pub fn overlay_y_label_for_axes(&self, axes_index: usize) -> Option<&String>

Source

pub fn overlay_y_label_style_for_axes( &self, axes_index: usize, ) -> Option<&TextStyle>

Source

pub fn overlay_z_label(&self) -> Option<&String>

Source

pub fn overlay_z_label_for_axes(&self, axes_index: usize) -> Option<&String>

Source

pub fn overlay_z_label_style_for_axes( &self, axes_index: usize, ) -> Option<&TextStyle>

Source

pub fn active_axes_pie_labels(&self) -> Vec<(String, Vec2)>

Source

pub fn pie_labels_for_axes(&self, axes_index: usize) -> Vec<(String, Vec2)>

Source

pub fn world_text_annotations_for_axes( &self, axes_index: usize, ) -> Vec<(Vec3, String, TextStyle)>

Source

pub fn world_axis_label_annotations_for_axes( &self, axes_index: usize, ) -> Vec<(Vec3, String, TextStyle)>

Source

pub fn overlay_show_legend(&self) -> bool

Source

pub fn overlay_show_legend_for_axes(&self, axes_index: usize) -> bool

Source

pub fn overlay_legend_entries(&self) -> &Vec<LegendEntry>

Source

pub fn overlay_legend_entries_for_axes( &self, axes_index: usize, ) -> Vec<LegendEntry>

Source

pub fn overlay_x_log(&self) -> bool

Source

pub fn overlay_x_log_for_axes(&self, axes_index: usize) -> bool

Source

pub fn overlay_y_log(&self) -> bool

Source

pub fn overlay_y_log_for_axes(&self, axes_index: usize) -> bool

Source

pub fn overlay_colormap(&self) -> ColorMap

Source

pub fn overlay_colorbar_enabled(&self) -> bool

Source

pub fn figure_axes_grid(&self) -> (usize, usize)

Subplot grid

Source

pub fn overlay_categorical_labels(&self) -> Option<(bool, &Vec<String>)>

Return categorical labels if any (is_x_axis, &labels)

Source

pub fn overlay_categorical_labels_for_axes( &self, axes_index: usize, ) -> Option<(bool, Vec<String>)>

Source

pub fn overlay_histogram_edges_for_axes( &self, axes_index: usize, ) -> Option<(bool, Vec<f64>)>

Source

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.

Source

pub fn data_bounds(&self) -> Option<(f64, f64, f64, f64)>

Get bounds used for display (manual axis limits override data bounds when provided)

Source

pub fn axes_camera_mut(&mut self, idx: usize) -> Option<&mut Camera>

Get mutable reference to a specific axes camera when using subplots

Source

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)

Source

pub fn axes_bounds(&self, axes_index: usize) -> Option<BoundingBox>

Source

pub fn export_figure_clone(&self) -> Figure

Prefer exporting the original figure if available

Auto Trait Implementations§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> WasmNotSend for T
where T: Send,