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 0 → PickId::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 ProjectionCoordinate 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 ThemeEffective 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>
impl<'a> GeomContext<'a>
Sourcepub fn new(
panel_rect: Rect,
dpi: f64,
shapes: &'a ShapeRegistry,
scales: &'a dyn ScaleResolver,
) -> Self
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.
Sourcepub fn with_projection(
panel_rect: Rect,
dpi: f64,
shapes: &'a ShapeRegistry,
scales: &'a dyn ScaleResolver,
projection: &'a Projection,
) -> Self
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.
Sourcepub fn with_theme(self, theme: &'a Theme) -> Self
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.
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> 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.