Count: overlapping pair in the error colour, targets deselected, locked area layer

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-05 10:12:00 +03:00
1 parent 88d8a33572
commit d830e40bfa
4 files changed
+13 -5

No files matched your search

Generated
+1 -1
View File
@@ -4206,7 +4206,7 @@ dependencies = [
[[package]] [[package]]
name = "opencadcodec" name = "opencadcodec"
version = "0.5.5" 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 = [ dependencies = [
"ahash 0.8.12", "ahash 0.8.12",
"anyhow", "anyhow",
+1 -1
View File
@@ -91,7 +91,7 @@ block2 = "0.5"
objc2-foundation = { version = "0.2", features = ["NSArray", "NSURL", "NSString", "NSObject", "NSNotification", "NSThread", "NSEnumerator"] } objc2-foundation = { version = "0.2", features = ["NSArray", "NSURL", "NSString", "NSObject", "NSNotification", "NSThread", "NSEnumerator"] }
[patch."https://github.com/HakanSeven12/opencadcodec.git"] [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] [patch.crates-io]
iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" } iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" }
+7 -3
View File
@@ -253,7 +253,7 @@ impl OpenCADStudio {
let r = m.result(&self.tabs[i].scene.document); let r = m.result(&self.tabs[i].scene.document);
crate::scene::CountDisplay { crate::scene::CountDisplay {
counted: r.counted.into_iter().collect(), 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), color: aci_rgba(self.count_palette.color),
error_color: aci_rgba(self.count_palette.error_color), error_color: aci_rgba(self.count_palette.error_color),
} }
@@ -287,7 +287,8 @@ impl OpenCADStudio {
let doc = &self.tabs[i].scene.document; let doc = &self.tabs[i].scene.document;
if doc.get_entity(h).is_some() && !boundary_in_use(doc, h) { if doc.get_entity(h).is_some() && !boundary_in_use(doc, h) {
self.push_undo_snapshot(i, "COUNT"); 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; 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. /// Continuous), whatever the current layer.
fn draw_count_area(&mut self, i: usize, ring: &[[f64; 2]]) -> Option<Handle> { fn draw_count_area(&mut self, i: usize, ring: &[[f64; 2]]) -> Option<Handle> {
self.push_undo_snapshot(i, "COUNT"); self.push_undo_snapshot(i, "COUNT");
@@ -345,6 +346,7 @@ impl OpenCADStudio {
layer.handle = doc.allocate_handle(); layer.handle = doc.allocate_handle();
layer.color = codec::types::Color::from_index(152); layer.color = codec::types::Color::from_index(152);
layer.is_plottable = false; layer.is_plottable = false;
layer.flags.locked = true;
layer.line_type = "Continuous".into(); layer.line_type = "Continuous".into();
let _ = doc.layers.add(layer); let _ = doc.layers.add(layer);
} }
@@ -400,6 +402,8 @@ impl OpenCADStudio {
None if targets.is_empty() => None, None if targets.is_empty() => None,
_ => Some(CountTarget::Group(targets.clone())), _ => 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(); let old = self.tabs[i].count.take();
if let Some(old) = old.as_ref().filter(|o| o.boundary != boundary) { if let Some(old) = old.as_ref().filter(|o| o.boundary != boundary) {
self.drop_count_boundary(i, old.boundary); self.drop_count_boundary(i, old.boundary);
+4
View File
@@ -58,6 +58,8 @@ pub struct CountMode {
pub struct CountResult { pub struct CountResult {
pub counted: Vec<Handle>, pub counted: Vec<Handle>,
pub errors: Vec<Handle>, pub errors: Vec<Handle>,
/// The counted references a duplicate overlaps (drawn in the error colour too).
pub overlapped: Vec<Handle>,
} }
impl CountMode { impl CountMode {
@@ -83,6 +85,7 @@ impl CountMode {
Some(CountTarget::Group(handles)) => CountResult { Some(CountTarget::Group(handles)) => CountResult {
counted: handles.iter().copied().filter(|h| doc.get_entity(*h).is_some()).collect(), counted: handles.iter().copied().filter(|h| doc.get_entity(*h).is_some()).collect(),
errors: Vec::new(), errors: Vec::new(),
overlapped: Vec::new(),
}, },
Some(CountTarget::Block { name, .. }) => { Some(CountTarget::Block { name, .. }) => {
let instances = self.instances(doc); let instances = self.instances(doc);
@@ -91,6 +94,7 @@ impl CountMode {
CountResult { CountResult {
counted: instances.iter().filter(mine).filter(|i| i.duplicate_of.is_none()).map(|i| i.handle).collect(), 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(), 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(),
} }
} }
} }