From 789687659ba23a454c34f6e360f8b7f0b352def8 Mon Sep 17 00:00:00 2001 From: ramox81 <184937705+ramox81@users.noreply.github.com> Date: Mon, 5 Oct 2026 12:54:22 +0300 Subject: [PATCH] Count: Current area counts all of model space; Properties cleared after the pick Co-Authored-By: Claude Opus 5.5 --- src/app/commands/count.rs | 26 +++++++------------------- src/ui/window/count_palette.rs | 2 -- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/app/commands/count.rs b/src/app/commands/count.rs index 94fd8a73e..3dcbcd259 100644 --- a/src/app/commands/count.rs +++ b/src/app/commands/count.rs @@ -278,7 +278,6 @@ impl OpenCADStudio { pub(in crate::app) fn close_count(&mut self, i: usize) { if let Some(mode) = self.tabs[i].count.take() { self.drop_count_boundary(i, mode.boundary); - self.drop_count_boundary(i, mode.remembered.and_then(|(_, b)| b)); } self.tabs[i].scene.set_count_display(None); } @@ -311,13 +310,9 @@ impl OpenCADStudio { let mode = self.tabs[i].count.as_ref(); Some((mode.and_then(|m| m.area.clone()), mode.and_then(|m| m.boundary))) } - // Current area: the count area in use (also one Entire model space - // set aside), else all of model space. - "C" => Some(match self.tabs[i].count.as_ref() { - Some(m) if m.area.is_some() => (m.area.clone(), m.boundary), - Some(m) => m.remembered.clone().map_or((None, None), |(a, b)| (Some(a), b)), - None => (None, None), - }), + // Current area counts all of model space (the view and an area + // in use take no part). + "C" => Some((None, None)), "R" => { let p = points(); let (a, b) = (p.first()?, p.get(1)?); @@ -408,18 +403,11 @@ impl OpenCADStudio { }; // The picked targets do not stay selected. self.tabs[i].scene.deselect_all(); - // Entire model space counts without the area but keeps it for a later - // Current area; a new area replaces it. - let mut remembered = None; - if let Some(old) = self.tabs[i].count.take() { - let old_area = old.area.map(|a| (a, old.boundary)).or(old.remembered); - if area.is_none() { - remembered = old_area; - } else if let Some((_, b)) = old_area.filter(|(_, b)| *b != boundary) { - self.drop_count_boundary(i, b); - } + self.refresh_properties(); + if let Some(old) = self.tabs[i].count.take().filter(|o| o.boundary != boundary) { + self.drop_count_boundary(i, old.boundary); } - let mode = CountMode { area, boundary, target, remembered, ..CountMode::default() }; + let mode = CountMode { area, boundary, target, ..CountMode::default() }; if let Some(name) = mode.target_name() { let n = mode.count(&self.tabs[i].scene.document); self.command_line.push_output(&format!("{name} ...... {n}")); diff --git a/src/ui/window/count_palette.rs b/src/ui/window/count_palette.rs index 8802d0ca5..f444a2266 100644 --- a/src/ui/window/count_palette.rs +++ b/src/ui/window/count_palette.rs @@ -51,8 +51,6 @@ pub struct CountMode { pub cursor: Option, /// The scene geometry epoch the colouring was computed at. pub epoch: u64, - /// The area Entire model space set aside, for a later Current area. - pub remembered: Option<(Vec<[f64; 2]>, Option<(Handle, bool)>)>, /// The result and count at `epoch` (recomputed when the drawing changes). pub cache: Option<(CountResult, usize)>, }