Count: Invalid Area dialog, table block kept with the table

- When the count area's boundary is gone the approved Invalid Area dialog
  asks: undo the change (also its X and Cancel) or count all of model space;
  "always" keeps the choice in the settings. An edited boundary moves the area.
- A table's *T block is brought up to date whenever the table changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-05 15:40:02 +03:00
1 parent 4dba66bbac
commit 7ad6e5b094
33 files changed
+318 -5

No files matched your search

+66 -2
View File
@@ -268,8 +268,63 @@ impl OpenCADStudio {
/// After the drawing changes, count mode colours its references again.
pub(in crate::app) fn refresh_count_if_stale(&mut self) {
let i = self.active_tab;
if self.tabs[i].count.as_ref().is_some_and(|m| m.epoch != self.tabs[i].scene.geometry_epoch) {
self.apply_count_display(i);
let Some(mode) = self.tabs[i].count.as_ref().filter(|m| m.epoch != self.tabs[i].scene.geometry_epoch) else {
return;
};
if let Some((h, _)) = mode.boundary {
match self.tabs[i].scene.document.get_entity(h) {
// The boundary is gone (erased, undone): ask, or do what was
// chosen for good.
None => {
if self.active_modal == Some(crate::app::ModalKind::CountInvalidArea) {
return;
}
match self.count_palette.invalid_choice {
1 => self.count_invalid_undo(i),
2 => self.count_invalid_continue(i),
_ => {
self.count_palette.invalid_always = false;
self.active_modal = Some(crate::app::ModalKind::CountInvalidArea);
}
}
return;
}
// An edited boundary moves the area with it.
Some(EntityType::LwPolyline(pl)) => {
let ring: Vec<[f64; 2]> = pl.vertices.iter().map(|v| [v.location.x, v.location.y]).collect();
if let Some(mode) = self.tabs[i].count.as_mut() {
mode.area = Some(ring);
}
}
Some(_) => {}
}
}
self.apply_count_display(i);
}
/// Invalid Area › Undo (also ✕ and Cancel): the change that took the
/// boundary away is undone.
fn count_invalid_undo(&mut self, i: usize) {
self.undo_active_tab();
self.apply_count_display(i);
}
/// Invalid Area › Continue: the area goes, the count covers all of model space.
fn count_invalid_continue(&mut self, i: usize) {
if let Some(mode) = self.tabs[i].count.as_mut() {
mode.area = None;
mode.boundary = None;
}
self.apply_count_display(i);
}
fn close_invalid_area(&mut self, choice: u8) {
if self.active_modal == Some(crate::app::ModalKind::CountInvalidArea) {
self.close_active_modal();
}
if self.count_palette.invalid_always {
self.count_palette.invalid_choice = choice;
self.persist_settings_if_changed();
}
}
@@ -755,6 +810,15 @@ impl OpenCADStudio {
return self.start_count_command(i, Box::new(command), "COUNT");
}
CountMsg::Field => return self.dispatch_command("COUNTFIELD"),
CountMsg::InvalidAlways(v) => self.count_palette.invalid_always = v,
CountMsg::InvalidUndo => {
self.close_invalid_area(1);
self.count_invalid_undo(i);
}
CountMsg::InvalidContinue => {
self.close_invalid_area(2);
self.count_invalid_continue(i);
}
}
Task::none()
}
+5 -1
View File
@@ -933,7 +933,7 @@ impl OpenCADStudio {
// layer|scale|mirror>:NAME", "create_table", "check=NAME:1",
// "all=1", "table_cancel", "table_insert", "back", "match=<0|1|2>:1",
// "details", "errors", "error=<n>", "area", "prev", "next", "select",
// "field", "close".
// "field", "close", "invalid_undo", "invalid_continue", "invalid_always=1".
"count_palette" => {
use crate::ui::window::count_palette::{CountMsg as M, RowAction};
let value = string(req, "value")?;
@@ -993,6 +993,10 @@ impl OpenCADStudio {
"select" => M::Select,
"field" => M::Field,
"close" => M::Close,
// The Invalid Area dialog.
"invalid_undo" => M::InvalidUndo,
"invalid_continue" => M::InvalidContinue,
"invalid_always" => M::InvalidAlways(arg == "1"),
_ => return Err(bad()),
})
}
+1
View File
@@ -1943,6 +1943,7 @@ pub enum ModalKind {
GeometricTolerance,
AttDef,
AttDefEdit,
CountInvalidArea,
Field,
DraftingSettings,
AutoConstrainSettings,
+4
View File
@@ -622,6 +622,9 @@ pub struct UserSettings {
/// COUNTSERVICE (default on).
#[serde(default = "default_true")]
pub count_service: bool,
/// Count - Invalid Area: 0 ask, 1 undo, 2 count all of model space.
#[serde(default)]
pub count_invalid_area: u8,
}
/// A block the Blocks palette lists from outside the current drawing (a
@@ -873,6 +876,7 @@ impl Default for UserSettings {
count_color: 3,
count_error_color: 1,
count_service: true,
count_invalid_area: 0,
}
}
}
+2
View File
@@ -748,6 +748,7 @@ impl OpenCADStudio {
count_color: self.count_palette.color,
count_error_color: self.count_palette.error_color,
count_service: self.count_palette.service,
count_invalid_area: self.count_palette.invalid_choice,
}
}
@@ -882,6 +883,7 @@ impl OpenCADStudio {
self.count_palette.color = s.count_color;
self.count_palette.error_color = s.count_error_color;
self.count_palette.service = s.count_service;
self.count_palette.invalid_choice = s.count_invalid_area.min(2);
self.block_palette.recent = s.block_recent.clone();
self.block_palette.favorites = s.block_favorites.clone();
self.block_palette.libraries = s.block_libraries.clone();
+4
View File
@@ -8524,6 +8524,10 @@ impl OpenCADStudio {
}
Message::CloseModal => {
// The Invalid Area dialog's ✕ undoes the boundary change, as its Cancel does.
if self.active_modal == Some(super::ModalKind::CountInvalidArea) {
return self.update(Message::Count(crate::ui::window::count_palette::CountMsg::InvalidUndo));
}
if self.active_modal == Some(super::ModalKind::Field) {
self.close_field_dialog();
return Task::none();
+4
View File
@@ -40,6 +40,7 @@ impl OpenCADStudio {
Some(K::GeometricTolerance) => crate::t!("Geometric Tolerance").into_owned(),
Some(K::AttDef) => crate::t!("Attribute Definition").into_owned(),
Some(K::AttDefEdit) => crate::t!("Edit Attribute Definition").into_owned(),
Some(K::CountInvalidArea) => crate::t!("Count - Invalid Area").into_owned(),
Some(K::Field) => crate::t!("Field").into_owned(),
Some(K::DraftingSettings) => crate::t!("Drafting Settings").into_owned(),
Some(K::AutoConstrainSettings) => crate::t!("Constraint Settings").into_owned(),
@@ -584,6 +585,9 @@ impl OpenCADStudio {
let state = self.field_dialog.as_ref()?;
sized_flow(ex, 760, 660, |flow| crate::ui::window::field_dialog::view(state, flow))
}
super::super::ModalKind::CountInvalidArea => {
sized_flow(ex, 520, 260, |flow| crate::ui::window::count_palette::invalid_area_view(&self.count_palette, flow))
}
super::super::ModalKind::AttDefEdit => {
let state = self.attdef_edit.as_ref()?;
sized_flow(ex, 460, 220, |flow| crate::ui::window::attdef_dialog::view_edit(state, flow))