Skip to main content

GeomContext

Struct GeomContext 

Source
pub struct GeomContext<'a> {
    pub panel_rect: Rect,
    pub dpi: f64,
    pub shapes: &'a ShapeRegistry,
    pub scales: &'a dyn ScaleResolver,
    pub projection: &'a Projection,
    pub theme: &'a Theme,
}
Expand description

Per-draw context passed to Geom::draw. Carries the panel rect (in pixels, output of the composition solver), the dpi, the shape registry, and the channel→scale resolver.

Picking is driven entirely by each geom’s "pick_id" channel: the resolved value is the 24-bit id reported by pick_at. Unset channel → PickId::Skip for the whole geom (no participation in the hitmap); resolved value 0PickId::Block (occlude without reporting); otherwise → PickId::Id(value). The context does not allocate or track ids — the user owns the namespace.

Fields§

§panel_rect: Rect§dpi: f64§shapes: &'a ShapeRegistry§scales: &'a dyn ScaleResolver§projection: &'a Projection

Coordinate projection. Geoms route their final fraction→pixel conversion through Projection::project_to_panel_px so non-Cartesian variants (polar, future ternary) drop in without touching geom code. Defaults to Projection::Cartesian for callers that construct a context via Self::new.

§theme: &'a Theme

Effective theme — geoms read defaults (point size, linewidth, fill / stroke style) from theme.geom.* when a channel binding doesn’t supply the value. Defaults to a Theme::default() reference for callers that construct a context via Self::new.

Implementations§

Source§

impl<'a> GeomContext<'a>

Source

pub fn new( panel_rect: Rect, dpi: f64, shapes: &'a ShapeRegistry, scales: &'a dyn ScaleResolver, ) -> Self

Construct a per-draw context with the default Cartesian projection and default theme. Use Self::with_projection or Self::with_theme to override.

Source

pub fn with_projection( panel_rect: Rect, dpi: f64, shapes: &'a ShapeRegistry, scales: &'a dyn ScaleResolver, projection: &'a Projection, ) -> Self

Construct a per-draw context with an explicit projection. Used by the orchestrator (Plot::draw_panel_into) so the plot’s configured projection threads to every geom.

Source

pub fn with_theme(self, theme: &'a Theme) -> Self

Builder-style override of the context’s theme reference. Returns the context with theme swapped in. Used by the orchestrator to thread the resolved per-plot theme through to every geom’s draw call.

Source

pub fn scale_for(&self, channel: &str) -> Option<&Scale>

Resolve a channel name to a scale, if one is bound.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for GeomContext<'a>

§

impl<'a> !Send for GeomContext<'a>

§

impl<'a> !Sync for GeomContext<'a>

§

impl<'a> !UnwindSafe for GeomContext<'a>

§

impl<'a> Freeze for GeomContext<'a>

§

impl<'a> Unpin for GeomContext<'a>

§

impl<'a> UnsafeUnpin for GeomContext<'a>

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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

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

Convert &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)

Convert &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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

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

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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

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

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
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