Skip to main content

Scene

Struct Scene 

Source
pub struct Scene { /* private fields */ }
Expand description

entities, layers, styles and the camera of one scene: on a Renderer’s device, or without one (Scene::new_cpu; draw_cpu draws it through lib/gfx)

Implementations§

Source§

impl Scene

Source

pub fn set_highlight(&mut self, id: EntityId, bits: u8) -> Result<()>

an entity on a layer is highlighted (HL_SELECTED, HL_HOVER, both, or 0: not); an insert as a whole. Only the mask’s changed words go up with the next prepare

Source

pub fn set_highlights(&mut self, ids: &[EntityId], bits: u8) -> Result<()>

many at once (the same bits for each)

Source

pub fn highlight(&self, id: EntityId) -> u8

an entity’s highlight bits (0 for a dead id)

Source

pub fn clear_highlights(&mut self, bits: u8)

these bits off on every entity (HL_HOVER: no hover left; HL_SELECTED | HL_HOVER: nothing highlighted)

Source

pub fn highlighted(&self) -> Vec<EntityId>

the entities highlighted now

Source

pub fn highlight_info(&self) -> HighlightInfo

what the last prepare sent of the highlights

Source§

impl Scene

Source

pub fn overlay(&mut self) -> &mut Overlay

the overlay: what is drawn over the scene with the next frames (clear it and fill it again for each frame)

Source

pub fn overlay_info(&self) -> OverlayInfo

what the last prepare made of the overlay

Source§

impl Scene

Source

pub fn build_index(&mut self)

builds the spatial index now (else the first pick, select or snap does)

Source

pub fn index_info(&self) -> IndexInfo

what the index holds

Source

pub fn index_check(&mut self) -> Result<u32, &'static str>

(tests) the trees’ invariants hold

Source§

impl Scene

Source

pub fn pick(&mut self, at: [f64; 2], tolerance: f64) -> Vec<Hit>

what is drawn within tolerance pixels of a point of the drawing (f64), topmost first (the painter’s order: an app cycles through overlapping ones); inside an insert the hit names the insert and the way down to the entity

Source

pub fn pick_filtered( &mut self, at: [f64; 2], tolerance: f64, filter: &dyn Fn(LayerId) -> bool, ) -> Vec<Hit>

pick with a filter of layers (false: skipped; hidden layers are skipped anyway): a layer lock of an app

Source

pub fn pick_brute(&mut self, at: [f64; 2], tolerance: f64) -> Vec<Hit>

(tests) pick without the index: every entity, every entity of every block

Source§

impl Scene

Source

pub fn select(&mut self, region: Region<'_>, mode: SelectMode) -> Vec<EntityId>

the entities on layers a region selects (an insert as a whole): Window what lies wholly inside, Crossing what lies inside or touches it (AutoCAD’s); by the centre lines (widths do not count, as in AutoCAD), a fill by its rings (a crossing region inside a fill touches it), a text by its quad. In no particular order

Source

pub fn select_filtered( &mut self, region: Region<'_>, mode: SelectMode, filter: &dyn Fn(LayerId) -> bool, ) -> Vec<EntityId>

select with a filter of layers (false: skipped)

Source

pub fn select_brute( &mut self, region: Region<'_>, mode: SelectMode, ) -> Vec<EntityId>

(tests) select without the index

Source§

impl Scene

Source

pub fn snap(&mut self, at: [f64; 2], opt: &SnapOptions) -> Option<Snap>

the object snap at a point of the drawing (f64): of the kinds asked for within the aperture, the one nearest the pointer (equally near: endpoint, intersection, midpoint, centre, quadrant, insertion, perpendicular, tangent), nearest only where nothing else is

Source

pub fn snaps(&mut self, at: [f64; 2], opt: &SnapOptions) -> Vec<Snap>

every snap candidate in that order (an app cycles through them)

Source

pub fn snaps_filtered( &mut self, at: [f64; 2], opt: &SnapOptions, filter: &dyn Fn(LayerId) -> bool, ) -> Vec<Snap>

snaps with a filter of layers (false: skipped)

Source

pub fn snaps_brute(&mut self, at: [f64; 2], opt: &SnapOptions) -> Vec<Snap>

(tests) snaps without the index

Source§

impl Scene

Source

pub fn grip_points(&self, id: EntityId) -> Vec<[f64; 2]>

AutoCAD’s grips of an entity on a layer (drawing units): a line’s ends and middle, a polyline’s vertices and its segments’ middles, an arc’s centre, ends and middle, a circle’s centre and quadrants, an ellipse’s centre and its axes’ ends (an open one’s ends too), a Bézier chain’s and a spline’s control points, a fill’s corners, a text’s alignment point, an insert’s insertion point (each copy of an array). Empty for a dead id or a block’s entity

Source§

impl Scene

Source

pub fn draw_cpu( &mut self, dc: &mut Dc, sf: &mut Surface, r: [i32; 4], ) -> CpuInfo

the scene drawn on the CPU through lib/gfx (G6e1, decision 29): the camera’s view of a target of r’s size into the rectangle r (x, y, w, h, relative to dc’s origin) of sf, clipped to dc’s clip, blended over what is there (the app clears it first, as a frame’s load does); the painter’s order, the visible layers, the look, the highlights and the overlay of a frame on the GPU (docs/RENDER2D.md “Der CPU-Weg”). With and without a device. dc keeps its colour, clip and origin

Source

pub fn set_cpu_single(&mut self, single: bool)

draw_cpu on one thread (false: row bands on lib/gfx’s parallel loop where one is set, gfx::set_parallel: lib/ui sets its worker pool there; the same bytes either way)

Source

pub fn cpu_info(&self) -> CpuInfo

what the last draw_cpu did

Source§

impl Scene

Source

pub fn new(r: &Renderer) -> Result<Scene>

a scene on a renderer’s device (Scene::new_cpu, then attach)

Source

pub fn new_cpu() -> Scene

a scene without a device (G6e1): everything but a frame on the GPU works on it (entities, layers, styles, blocks, text, picking, selection, snaps, highlights, the overlay), and draw_cpu draws it through lib/gfx. attach puts it on a renderer’s device (all of it goes up with the next prepare), detach takes it off again (a lost device: the drawing stays)

Source

pub fn attach(&mut self, r: &Renderer) -> Result<()>

the scene on a renderer’s device (G6e1): its buffers made there, everything it holds goes up with the next prepare. Attached to another renderer before, it leaves that one first; to the same one, nothing happens. An error leaves it without a device

Source

pub fn detach(&mut self)

the scene off its device (G6e1; a lost device, another renderer next): what it made there goes, what it holds stays; draw_cpu draws it, attach puts it on a device again

Source

pub fn attached(&self) -> bool

the scene is on a renderer’s device (Scene::new, attach); else only draw_cpu draws it

Source

pub fn add_style(&mut self, s: &Style) -> Result<StyleId>

a style for entities; the next frame shows it

Source

pub fn set_style(&mut self, id: StyleId, s: &Style) -> Result<()>

a style changed: every entity of it shows the change with the next frame (nothing else goes up)

Source

pub fn style(&self, id: StyleId) -> Option<Style>

Source

pub fn add_layer(&mut self, l: &Layer) -> Result<LayerId>

a new layer, empty, on top of those of its order

Source

pub fn set_layer(&mut self, id: LayerId, l: &Layer) -> Result<()>

shown or hidden, its place in the draw order, its transparency (nothing of its entities goes up: the layer table)

Source

pub fn layer(&self, id: LayerId) -> Result<Layer>

Source

pub fn remove_layer(&mut self, id: LayerId) -> Result<()>

the layer goes, with every entity on it

Source

pub fn drawn_layers(&self) -> Vec<LayerId>

the visible layers in the order the last prepare drew them (the lists’ order: lists_buffer)

Source

pub fn add_font(&mut self, data: &[u8], face: u32) -> Result<FontId>

a font from TrueType or OpenType bytes (face: a collection’s font, else 0), lib/text’s parser

Source

pub fn fonts(&mut self) -> &mut Fonts

the scene’s fonts: their metrics and glyph outlines, and what lays text out with them (text::layout_text, layout_mtext: the CPU path of G6e draws the same layout)

Source

pub fn add_text_style(&mut self, s: &TextStyle) -> Result<TextStyleId>

a text style (DXF’s STYLE) for texts

Source

pub fn set_text_style(&mut self, id: TextStyleId, s: &TextStyle) -> Result<()>

a text style changes: every text of it is laid out again (its records go up, a block’s once for all its inserts)

Source

pub fn text_style(&self, id: TextStyleId) -> Option<TextStyle>

Source

pub fn text_layout(&self, id: EntityId) -> Option<&Layout>

a text’s layout (G6d picks with its extent: TextLayout::quad, bounds; G6e draws it): None for any other entity

Source

pub fn text_info(&self) -> TextInfo

what the scene’s text holds (TextInfo)

Source

pub fn atlas_hash(&self) -> u64

(tests) FNV-1a of the atlas’s pages: the same bytes on every target for the same texts

Source

pub fn insert( &mut self, layer: LayerId, style: StyleId, s: &Shape<'_>, ) -> Result<EntityId>

a new entity at the end of its layer (drawn over everything there); an insert of a block (Shape::Insert) sits there with its block’s entities

Source

pub fn update(&mut self, id: EntityId, s: &Shape<'_>) -> Result<()>

new geometry; the entity keeps its place in the draw order (in its layer or its block). An insert on a layer that stays an insert of the same block with as many copies only moves: its instances’ transforms go up, nothing else

Source

pub fn set_entity_style(&mut self, id: EntityId, style: StyleId) -> Result<()>

another style: its records go up again (a block’s entity: its block’s, once for all its inserts; an insert: what its block’s entities take by block)

Source

pub fn remove(&mut self, id: EntityId) -> Result<()>

the entity goes; its records become free places (and its id dead); a block’s entity leaves its block (its records go up once for all its inserts)

Source

pub fn len(&self) -> u32

entities alive (a block’s entities and inserts each once)

Source

pub fn is_empty(&self) -> bool

Source

pub fn locate(&self, id: EntityId) -> Option<(u32, u32)>

(tests, tools) an entity’s records as the last prepare laid them out: its first record’s place in the pool and the records of its geometry (a polyline of n points: n - 1, closed n; a point: 1; an insert on a layer: its one record of zeros); None for a block’s entity (its records lie in its block’s variants)

Source

pub fn add_block(&mut self, b: &Block) -> Result<BlockId>

a new block, empty: entities go into it with insert_in, Shape::Insert places it

Source

pub fn block(&self, id: BlockId) -> Result<Block>

Source

pub fn set_block(&mut self, id: BlockId, b: &Block) -> Result<()>

a block’s base point changed: every insert shows it (its records go up once)

Source

pub fn remove_block(&mut self, id: BlockId) -> Result<()>

the block goes with its entities; refused while an insert places it

Source

pub fn insert_in( &mut self, block: BlockId, style: StyleId, s: &Shape<'_>, ) -> Result<EntityId>

a new entity at the end of a block (its units: the block’s base lands on an insert’s point); a Shape::Insert of another block nests it (no cycles, at most BLOCK_DEPTH levels). Every insert of the block shows it with the next frame, the block’s records going up once

Source

pub fn instance_info(&self) -> InstanceInfo

what the blocks hold and what the last prepare sent of them

Source

pub fn set_camera(&mut self, c: &Camera) -> Result<()>

Source

pub fn camera(&self) -> &Camera

Source

pub fn set_culling(&mut self, on: bool)

false: every live record of a visible layer is drawn (a test’s comparison, a debugging aid)

Source

pub fn set_stats(&mut self, on: bool)

FrameStats of each frame: the records found visible (a small copy per frame), the GPU’s times

Source

pub fn upload_info(&self) -> UploadInfo

what the last prepare sent

Source

pub fn lists_buffer(&self) -> &Buffer

(tests, tools) after a frame’s visibility: per visible layer in draw order (drawn_layers) its first place in the visible list and its count (16 bytes each); the visible list (record places in the pool); the indirect draws. These and pool_buffer panic on a scene without a device (Scene::attached)

Source

pub fn visible_buffer(&self) -> &Buffer

Source

pub fn draws_buffer(&self) -> &Buffer

Source

pub fn pool_buffer(&self) -> &Buffer

(tests, tools) the pool of records (common.wgsl Record, 64 bytes each)

Source

pub fn wait_slot(&mut self) -> Result<()>

wait for the frame that last used this frame’s slot, so its data can be written; prepare does it too. The browser cannot wait, and needs not: its writes go in queue order

Source

pub fn take_stats(&mut self) -> Vec<FrameStats>

the finished frames’ stats since the last call

Source

pub fn collect_stats(&mut self)

after Device::wait_idle: the stats of what was still in flight

Source

pub fn reflattened(&self) -> u32

curves and fills the last prepare flattened again (their zoom band changed, or the view left their window)

Source

pub fn prepare(&mut self, r: &mut Renderer, size: (u32, u32)) -> Result<()>

the frame’s data for Renderer::record: waits for this slot’s last frame, sends what changed. size: the target’s in pixels

Source

pub fn submitted(&mut self, id: SubmitId)

the frame went to the GPU: Queue::submit’s or Swapchain::present’s answer

Auto Trait Implementations§

§

impl !RefUnwindSafe for Scene

§

impl !UnwindSafe for Scene

§

impl Forget for Scene

§

impl Freeze for Scene
where *const ArcInner<Shared> is !null: Freeze, PhantomData<ArcInner<Shared>>: Freeze, *const ArcInner<Tag> is !null: Freeze, PhantomData<ArcInner<Tag>>: Freeze, *const u8 is !null: Freeze, PhantomData<Style>: Freeze, PhantomData<u32>: Freeze, *const ArcInner<BufInner> is !null: Freeze, PhantomData<ArcInner<BufInner>>: Freeze, PhantomData<(u32, FlatState, [f64; 4], u32)>: Freeze, PhantomData<LayerSlot>: Freeze, PhantomData<Ent>: Freeze, PhantomData<(u32, u32, u32, u32)>: Freeze, *const ArcInner<BgInner> is !null: Freeze, PhantomData<ArcInner<BgInner>>: Freeze, PhantomData<FrameSlot>: Freeze, *const ArcInner<TsInner> is !null: Freeze, PhantomData<ArcInner<TsInner>>: Freeze, PhantomData<[u32; 4]>: Freeze, PhantomData<u8>: Freeze, PhantomData<(u64, u64, u64)>: Freeze, PhantomData<TexCopy>: Freeze, PhantomData<(u64, u32, u64)>: Freeze, PhantomData<FrameStats>: Freeze, PhantomData<BlockSlot>: Freeze, PhantomData<Inst>: Freeze, PhantomData<(u32, u32)>: Freeze, PhantomData<(u32, u32, Style)>: Freeze, PhantomData<FontData>: Freeze, PhantomData<TextStyle>: Freeze, PhantomData<Page>: Freeze, PhantomData<GlyphRow>: Freeze, *const LeafNode<(u32, u32), u32> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<((u32, u32), u32)>>: Freeze, PhantomData<(u32, u32, u32, u32, u32)>: Freeze, PhantomData<TextRef>: Freeze, *const ArcInner<TexInner> is !null: Freeze, PhantomData<ArcInner<TexInner>>: Freeze, *const ArcInner<ViewInner> is !null: Freeze, PhantomData<ArcInner<ViewInner>>: Freeze, *const Index is !null: Freeze, PhantomData<Index>: Freeze, PhantomData<bool>: Freeze, PhantomData<Item>: Freeze, PhantomData<[f32; 4]>: Freeze, PhantomData<i32>: Freeze, PhantomData<Rl>: Freeze, PhantomData<f32>: Freeze,

§

impl Move for Scene

§

impl Send for Scene
where Arc<Shared>: Send, Arc<Tag>: Send, RawVecInner: Send, Arc<BufInner>: Send, BoxRaw<CurveG>: Send, BoxRaw<FillG>: Send, BoxRaw<TextG>: Send, Arc<BgInner>: Send, Arc<TsInner>: Send, BoxRaw<TtFont>: Send, Arc<SharedFontRepr>: Send, Arc<VariedInstance>: Send, NodeRef<Owned, u32, GlyphShape, LeafOrInternal>: Send, BoxRaw<(u32, GlyphShape)>: Send, NodeRef<Owned, (u32, u32), u32, LeafOrInternal>: Send, BoxRaw<((u32, u32), u32)>: Send, Arc<TexInner>: Send, Arc<ViewInner>: Send, BoxRaw<Index>: Send,

§

impl Sync for Scene
where Arc<Shared>: Sync, Arc<Tag>: Sync, RawVecInner: Sync, Arc<BufInner>: Sync, BoxRaw<CurveG>: Sync, BoxRaw<FillG>: Sync, BoxRaw<TextG>: Sync, Arc<BgInner>: Sync, Arc<TsInner>: Sync, BoxRaw<TtFont>: Sync, Arc<SharedFontRepr>: Sync, Arc<VariedInstance>: Sync, NodeRef<Owned, u32, GlyphShape, LeafOrInternal>: Sync, BoxRaw<(u32, GlyphShape)>: Sync, NodeRef<Owned, (u32, u32), u32, LeafOrInternal>: Sync, BoxRaw<((u32, u32), u32)>: Sync, Arc<TexInner>: Sync, Arc<ViewInner>: Sync, BoxRaw<Index>: Sync,

§

impl Unpin for Scene
where Arc<Shared>: Unpin, Arc<Tag>: Unpin, *const u8 is !null: Unpin, Arc<BufInner>: Unpin, Box<CurveG>: Unpin, Box<FillG>: Unpin, Box<TextG>: Unpin, Arc<BgInner>: Unpin, Arc<TsInner>: Unpin, Box<TtFont>: Unpin, Arc<SharedFontRepr>: Unpin, Arc<VariedInstance>: Unpin, *const LeafNode<u32, GlyphShape> is !null: Unpin, Box<(u32, GlyphShape)>: Unpin, *const LeafNode<(u32, u32), u32> is !null: Unpin, Box<((u32, u32), u32)>: Unpin, Arc<TexInner>: Unpin, Arc<ViewInner>: Unpin, Box<Index>: Unpin,

§

impl UnsafeUnpin for Scene
where *const ArcInner<Shared> is !null: UnsafeUnpin, PhantomData<ArcInner<Shared>>: UnsafeUnpin, *const ArcInner<Tag> is !null: UnsafeUnpin, PhantomData<ArcInner<Tag>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Style>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, *const ArcInner<BufInner> is !null: UnsafeUnpin, PhantomData<ArcInner<BufInner>>: UnsafeUnpin, PhantomData<(u32, FlatState, [f64; 4], u32)>: UnsafeUnpin, PhantomData<LayerSlot>: UnsafeUnpin, PhantomData<Ent>: UnsafeUnpin, PhantomData<(u32, u32, u32, u32)>: UnsafeUnpin, *const ArcInner<BgInner> is !null: UnsafeUnpin, PhantomData<ArcInner<BgInner>>: UnsafeUnpin, PhantomData<FrameSlot>: UnsafeUnpin, *const ArcInner<TsInner> is !null: UnsafeUnpin, PhantomData<ArcInner<TsInner>>: UnsafeUnpin, PhantomData<[u32; 4]>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<(u64, u64, u64)>: UnsafeUnpin, PhantomData<TexCopy>: UnsafeUnpin, PhantomData<(u64, u32, u64)>: UnsafeUnpin, PhantomData<FrameStats>: UnsafeUnpin, PhantomData<BlockSlot>: UnsafeUnpin, PhantomData<Inst>: UnsafeUnpin, PhantomData<(u32, u32)>: UnsafeUnpin, PhantomData<(u32, u32, Style)>: UnsafeUnpin, PhantomData<FontData>: UnsafeUnpin, PhantomData<TextStyle>: UnsafeUnpin, PhantomData<Page>: UnsafeUnpin, PhantomData<GlyphRow>: UnsafeUnpin, *const LeafNode<(u32, u32), u32> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<((u32, u32), u32)>>: UnsafeUnpin, PhantomData<(u32, u32, u32, u32, u32)>: UnsafeUnpin, PhantomData<TextRef>: UnsafeUnpin, *const ArcInner<TexInner> is !null: UnsafeUnpin, PhantomData<ArcInner<TexInner>>: UnsafeUnpin, *const ArcInner<ViewInner> is !null: UnsafeUnpin, PhantomData<ArcInner<ViewInner>>: UnsafeUnpin, *const Index is !null: UnsafeUnpin, PhantomData<Index>: UnsafeUnpin, PhantomData<bool>: UnsafeUnpin, PhantomData<Item>: UnsafeUnpin, PhantomData<[f32; 4]>: UnsafeUnpin, PhantomData<i32>: UnsafeUnpin, PhantomData<Rl>: UnsafeUnpin, PhantomData<f32>: UnsafeUnpin,

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> 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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.