forked from 1b-agent/opencadstudio-upstream
WIP count feature
This commit is contained in:
1 parent
b8def31145
commit
e29b408bda
26 files changed
+1887
-44
No files matched your search
+37
-1
@@ -1930,6 +1930,15 @@ pub enum ViewportRefreshScope {
|
||||
/// Entity membership in document order, keyed by geometry epoch.
|
||||
type BlockMembers = (u64, HashMap<Handle, Vec<Handle>>);
|
||||
|
||||
/// What count mode colours: see [`Scene::count_display`].
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct CountDisplay {
|
||||
pub counted: HashSet<Handle>,
|
||||
pub errors: HashSet<Handle>,
|
||||
pub color: [f32; 4],
|
||||
pub error_color: [f32; 4],
|
||||
}
|
||||
|
||||
pub struct Scene {
|
||||
pub camera: Rc<RefCell<Camera>>,
|
||||
/// View saved immediately before the latest navigation operation. ZOOM
|
||||
@@ -2018,6 +2027,10 @@ pub struct Scene {
|
||||
/// edited geometry stands out while the surrounding drawing stays visible
|
||||
/// for context. `None` = not editing. (#136)
|
||||
pub refedit_keep: Option<HashSet<Handle>>,
|
||||
/// COUNT mode colours: counted references in COUNTCOLOR, overlapping
|
||||
/// duplicates in COUNTERRORCOLOR, everything else faded. `None` outside
|
||||
/// count mode.
|
||||
pub count_display: Option<CountDisplay>,
|
||||
/// Entity drawn with the selection-highlight colour without being part
|
||||
/// of the real selection — used to preview a row in the cycling list box.
|
||||
pub hover_highlight: Option<Handle>,
|
||||
@@ -2612,6 +2625,7 @@ impl Scene {
|
||||
preview_hidden: HashSet::default(),
|
||||
command_preview_hidden: HashSet::default(),
|
||||
refedit_keep: None,
|
||||
count_display: None,
|
||||
hover_highlight: None,
|
||||
constraint_hover_highlights: HashSet::default(),
|
||||
constraint_hover_refs: Vec::new(),
|
||||
@@ -4084,10 +4098,32 @@ impl Scene {
|
||||
self.bump_geometry_no_blocks();
|
||||
}
|
||||
|
||||
/// Enter / leave the COUNT colouring; a no-op when nothing changed.
|
||||
pub fn set_count_display(&mut self, display: Option<CountDisplay>) {
|
||||
if self.count_display == display {
|
||||
return;
|
||||
}
|
||||
self.count_display = display;
|
||||
self.bump_geometry_no_blocks();
|
||||
}
|
||||
|
||||
/// Fade the colours of wires that belong to entities outside the REFEDIT
|
||||
/// keep set (no-op when not editing). The geometry is untouched, so
|
||||
/// hit-testing still works on faded entities.
|
||||
/// hit-testing still works on faded entities. In count mode the counted
|
||||
/// references and the duplicates take the count colours instead.
|
||||
fn apply_refedit_fade(&self, wires: &mut [WireModel], bg: [f32; 4]) {
|
||||
if let Some(count) = &self.count_display {
|
||||
for w in wires.iter_mut() {
|
||||
let h = Self::handle_from_wire_name(&w.name);
|
||||
w.color = match h {
|
||||
Some(h) if count.errors.contains(&h) => count.error_color,
|
||||
Some(h) if count.counted.contains(&h) => count.color,
|
||||
_ => crate::scene::cache::block_cache::fade_toward_bg(w.color, bg),
|
||||
};
|
||||
// Shared instance geometry keeps its own colour; draw these wires on their own.
|
||||
w.render_instance = None;
|
||||
}
|
||||
}
|
||||
let Some(keep) = &self.refedit_keep else {
|
||||
return;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user