diff --git a/Cargo.lock b/Cargo.lock index 0f58675e1..d77d98502 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4206,7 +4206,7 @@ dependencies = [ [[package]] name = "opencadcodec" version = "0.5.5" -source = "git+https://github.com/ramox81/cadcodec.git?rev=6d9c604#6d9c604dca78ed2f631e0f5b703415ea1f13b0db" +source = "git+https://github.com/ramox81/cadcodec.git?rev=48b86d0#48b86d08c895f07b53753888363d1d9a6b282305" dependencies = [ "ahash 0.8.12", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 361a526a2..51be8093f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ block2 = "0.5" objc2-foundation = { version = "0.2", features = ["NSArray", "NSURL", "NSString", "NSObject", "NSNotification", "NSThread", "NSEnumerator"] } [patch."https://github.com/HakanSeven12/opencadcodec.git"] -opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "6d9c604" } +opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "48b86d0" } [patch.crates-io] iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" } diff --git a/src/app/commands/count.rs b/src/app/commands/count.rs index 754b6db80..101c21c65 100644 --- a/src/app/commands/count.rs +++ b/src/app/commands/count.rs @@ -253,7 +253,7 @@ impl OpenCADStudio { let r = m.result(&self.tabs[i].scene.document); crate::scene::CountDisplay { counted: r.counted.into_iter().collect(), - errors: r.errors.into_iter().collect(), + errors: r.errors.into_iter().chain(r.overlapped).collect(), color: aci_rgba(self.count_palette.color), error_color: aci_rgba(self.count_palette.error_color), } @@ -287,7 +287,8 @@ impl OpenCADStudio { let doc = &self.tabs[i].scene.document; if doc.get_entity(h).is_some() && !boundary_in_use(doc, h) { self.push_undo_snapshot(i, "COUNT"); - self.tabs[i].scene.erase_entities(&[h]); + // The area layer is locked; count mode removes its own polyline. + self.tabs[i].scene.rollback_new_entities(&[h]); self.tabs[i].dirty = true; } } @@ -335,7 +336,7 @@ impl OpenCADStudio { } } - /// A closed polyline on `0-CountArea` (colour 152, not plotted, + /// A closed polyline on `0-CountArea` (locked, colour 152, not plotted, /// Continuous), whatever the current layer. fn draw_count_area(&mut self, i: usize, ring: &[[f64; 2]]) -> Option { self.push_undo_snapshot(i, "COUNT"); @@ -345,6 +346,7 @@ impl OpenCADStudio { layer.handle = doc.allocate_handle(); layer.color = codec::types::Color::from_index(152); layer.is_plottable = false; + layer.flags.locked = true; layer.line_type = "Continuous".into(); let _ = doc.layers.add(layer); } @@ -400,6 +402,8 @@ impl OpenCADStudio { None if targets.is_empty() => None, _ => Some(CountTarget::Group(targets.clone())), }; + // The picked targets do not stay selected. + self.tabs[i].scene.deselect_all(); let old = self.tabs[i].count.take(); if let Some(old) = old.as_ref().filter(|o| o.boundary != boundary) { self.drop_count_boundary(i, old.boundary); diff --git a/src/ui/window/count_palette.rs b/src/ui/window/count_palette.rs index 877ad92c0..1c33dc886 100644 --- a/src/ui/window/count_palette.rs +++ b/src/ui/window/count_palette.rs @@ -58,6 +58,8 @@ pub struct CountMode { pub struct CountResult { pub counted: Vec, pub errors: Vec, + /// The counted references a duplicate overlaps (drawn in the error colour too). + pub overlapped: Vec, } impl CountMode { @@ -83,6 +85,7 @@ impl CountMode { Some(CountTarget::Group(handles)) => CountResult { counted: handles.iter().copied().filter(|h| doc.get_entity(*h).is_some()).collect(), errors: Vec::new(), + overlapped: Vec::new(), }, Some(CountTarget::Block { name, .. }) => { let instances = self.instances(doc); @@ -91,6 +94,7 @@ impl CountMode { CountResult { counted: instances.iter().filter(mine).filter(|i| i.duplicate_of.is_none()).map(|i| i.handle).collect(), errors: instances.iter().filter(mine).filter(|i| i.duplicate_of.is_some()).map(|i| i.handle).collect(), + overlapped: instances.iter().filter(mine).filter_map(|i| i.duplicate_of).collect(), } } }