swls_core/systems/shapes/
visible.rs1use std::sync::Arc;
12
13use bevy_ecs::prelude::*;
14
15use crate::{prelude::*, systems::shapes::ShaclShapes};
16
17pub fn shapes_apply(shapes: &Label, global: bool, doc: &Label, links: &DocumentLinks) -> bool {
19 global || shapes.0 == doc.0 || links.iter().any(|link| link.0 == shapes.0)
20}
21
22pub type ShapeDocs<'w, 's> = Query<
24 'w,
25 's,
26 (
27 &'static Label,
28 &'static Triples,
29 Option<&'static Global>,
30 Option<&'static Prefixes>,
31 ),
32 With<ShaclShapes>,
33>;
34
35pub fn visible_shapes<'a>(
37 shapes: &'a ShapeDocs,
38 doc: &Label,
39 links: &DocumentLinks,
40) -> (Vec<Arc<Vec<MyQuad<'static>>>>, Vec<&'a Prefixes>) {
41 let mut triples = Vec::new();
42 let mut prefixes = Vec::new();
43 for (label, t, global, p) in shapes.iter() {
44 if shapes_apply(label, global.is_some(), doc, links) {
45 triples.push(t.0.clone());
46 prefixes.extend(p);
47 }
48 }
49 (triples, prefixes)
50}