diff --git a/Cargo.lock b/Cargo.lock index 6b96c417e..40b4fb9d5 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=483c006#483c006df06edeb371af25a39f975007dd91f8ca" +source = "git+https://github.com/ramox81/cadcodec.git?rev=115b753#115b7536c7c00bdd9684a80f2bb7642c11b048e9" dependencies = [ "ahash 0.8.12", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 83e94433a..a1dedd3f3 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 = "483c006" } +opencadcodec = { git = "https://github.com/ramox81/cadcodec.git", rev = "115b753" } [patch.crates-io] iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" } diff --git a/locales/ar-SA/opencadstudio.ftl b/locales/ar-SA/opencadstudio.ftl index 8a6956780..72d8e4db4 100644 --- a/locales/ar-SA/opencadstudio.ftl +++ b/locales/ar-SA/opencadstudio.ftl @@ -5956,3 +5956,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/bg-BG/opencadstudio.ftl b/locales/bg-BG/opencadstudio.ftl index 331b7cba7..c07082a2a 100644 --- a/locales/bg-BG/opencadstudio.ftl +++ b/locales/bg-BG/opencadstudio.ftl @@ -5944,3 +5944,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/cs-CZ/opencadstudio.ftl b/locales/cs-CZ/opencadstudio.ftl index 4fafb4c8d..2d98d426d 100644 --- a/locales/cs-CZ/opencadstudio.ftl +++ b/locales/cs-CZ/opencadstudio.ftl @@ -5941,3 +5941,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/de-DE/opencadstudio.ftl b/locales/de-DE/opencadstudio.ftl index e2a2f8ae4..b37388bca 100644 --- a/locales/de-DE/opencadstudio.ftl +++ b/locales/de-DE/opencadstudio.ftl @@ -5942,3 +5942,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/el-GR/opencadstudio.ftl b/locales/el-GR/opencadstudio.ftl index 95f7054d0..156d8d87c 100644 --- a/locales/el-GR/opencadstudio.ftl +++ b/locales/el-GR/opencadstudio.ftl @@ -5944,3 +5944,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/en-US/opencadstudio.ftl b/locales/en-US/opencadstudio.ftl index 764b2f5c7..92e1f15c0 100644 --- a/locales/en-US/opencadstudio.ftl +++ b/locales/en-US/opencadstudio.ftl @@ -5945,3 +5945,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/es-ES/opencadstudio.ftl b/locales/es-ES/opencadstudio.ftl index 5c228e77d..1ff70cdd5 100644 --- a/locales/es-ES/opencadstudio.ftl +++ b/locales/es-ES/opencadstudio.ftl @@ -5944,3 +5944,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/fi-FI/opencadstudio.ftl b/locales/fi-FI/opencadstudio.ftl index b6b1cc717..b6ad791b8 100644 --- a/locales/fi-FI/opencadstudio.ftl +++ b/locales/fi-FI/opencadstudio.ftl @@ -5941,3 +5941,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/fr-FR/opencadstudio.ftl b/locales/fr-FR/opencadstudio.ftl index faaae44cd..624cfcae7 100644 --- a/locales/fr-FR/opencadstudio.ftl +++ b/locales/fr-FR/opencadstudio.ftl @@ -5943,3 +5943,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/hi-IN/opencadstudio.ftl b/locales/hi-IN/opencadstudio.ftl index a7efb14dc..bcb1e45bf 100644 --- a/locales/hi-IN/opencadstudio.ftl +++ b/locales/hi-IN/opencadstudio.ftl @@ -5932,3 +5932,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/hu-HU/opencadstudio.ftl b/locales/hu-HU/opencadstudio.ftl index fafcb7755..71089bf43 100644 --- a/locales/hu-HU/opencadstudio.ftl +++ b/locales/hu-HU/opencadstudio.ftl @@ -5943,3 +5943,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/it-IT/opencadstudio.ftl b/locales/it-IT/opencadstudio.ftl index 5bb46d938..87e46727e 100644 --- a/locales/it-IT/opencadstudio.ftl +++ b/locales/it-IT/opencadstudio.ftl @@ -5943,3 +5943,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/ja-JP/opencadstudio.ftl b/locales/ja-JP/opencadstudio.ftl index 212923b58..4b26c5689 100644 --- a/locales/ja-JP/opencadstudio.ftl +++ b/locales/ja-JP/opencadstudio.ftl @@ -5932,3 +5932,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/ko-KR/opencadstudio.ftl b/locales/ko-KR/opencadstudio.ftl index 4c0f4307f..f25a45ad6 100644 --- a/locales/ko-KR/opencadstudio.ftl +++ b/locales/ko-KR/opencadstudio.ftl @@ -5943,3 +5943,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/nl-NL/opencadstudio.ftl b/locales/nl-NL/opencadstudio.ftl index 62a0f0efc..c488075de 100644 --- a/locales/nl-NL/opencadstudio.ftl +++ b/locales/nl-NL/opencadstudio.ftl @@ -5942,3 +5942,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/pl-PL/opencadstudio.ftl b/locales/pl-PL/opencadstudio.ftl index 73582eaf9..a6d2dc415 100644 --- a/locales/pl-PL/opencadstudio.ftl +++ b/locales/pl-PL/opencadstudio.ftl @@ -5943,3 +5943,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/pt-BR/opencadstudio.ftl b/locales/pt-BR/opencadstudio.ftl index 3c5d40863..6756aeac9 100644 --- a/locales/pt-BR/opencadstudio.ftl +++ b/locales/pt-BR/opencadstudio.ftl @@ -5944,3 +5944,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/ru-RU/opencadstudio.ftl b/locales/ru-RU/opencadstudio.ftl index 1a532105c..2e370254d 100644 --- a/locales/ru-RU/opencadstudio.ftl +++ b/locales/ru-RU/opencadstudio.ftl @@ -5945,3 +5945,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/tr-TR/opencadstudio.ftl b/locales/tr-TR/opencadstudio.ftl index 10943532b..25d2d556f 100644 --- a/locales/tr-TR/opencadstudio.ftl +++ b/locales/tr-TR/opencadstudio.ftl @@ -5867,3 +5867,10 @@ count-feature = .overlap = Üst üste binen nesne .show-instances = Örnekleri göster .geometries = Geometriler: __ocs_fmt_0__ + .invalid-title = Sayım - Geçersiz Alan + .invalid-message = Sayım sınırındaki değişiklikler geçersiz bir sayım alanıyla sonuçlandı. Ne yapmak istersiniz? + .invalid-undo = Sayım sınırındaki değişiklikleri geri al + .invalid-undo-detail = Son işlem geri alınır, sınır ve sayım alanı eski haline döner. + .invalid-continue = Devam et ve tüm model alanını say + .invalid-continue-detail = Sayım alanı kalkar; sayım tüm model alanında sürer. + .invalid-always = Geçerli seçimimi her zaman uygula diff --git a/locales/zh-CN/opencadstudio.ftl b/locales/zh-CN/opencadstudio.ftl index 3fbd610ca..45e7c5f3c 100644 --- a/locales/zh-CN/opencadstudio.ftl +++ b/locales/zh-CN/opencadstudio.ftl @@ -5927,3 +5927,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/locales/zh-TW/opencadstudio.ftl b/locales/zh-TW/opencadstudio.ftl index fb702b25f..19ede3dfd 100644 --- a/locales/zh-TW/opencadstudio.ftl +++ b/locales/zh-TW/opencadstudio.ftl @@ -5939,3 +5939,10 @@ count-feature = .overlap = Overlapping object .show-instances = Show Count Instances .geometries = Geometries: __ocs_fmt_0__ + .invalid-title = Count - Invalid Area + .invalid-message = The changes to count boundary have resulted to an invalid count area. What do you want to do? + .invalid-undo = Undo the changes to the count boundary + .invalid-undo-detail = The last change is undone; the boundary and the count area come back. + .invalid-continue = Continue and count the entire model space + .invalid-continue-detail = The count area is dropped; counting goes on in all of model space. + .invalid-always = Always perform my current choice diff --git a/src/app/commands/count.rs b/src/app/commands/count.rs index 6fd6d0b92..d10041a43 100644 --- a/src/app/commands/count.rs +++ b/src/app/commands/count.rs @@ -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() } diff --git a/src/app/control/actions.rs b/src/app/control/actions.rs index d40ccbae7..9d6963605 100644 --- a/src/app/control/actions.rs +++ b/src/app/control/actions.rs @@ -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=", "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()), }) } diff --git a/src/app/mod.rs b/src/app/mod.rs index d1b4665cf..9183c3bd5 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -1943,6 +1943,7 @@ pub enum ModalKind { GeometricTolerance, AttDef, AttDefEdit, + CountInvalidArea, Field, DraftingSettings, AutoConstrainSettings, diff --git a/src/app/settings.rs b/src/app/settings.rs index a8d302a39..89e1728ae 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -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, } } } diff --git a/src/app/update/file.rs b/src/app/update/file.rs index 4fd0f783d..42e997535 100644 --- a/src/app/update/file.rs +++ b/src/app/update/file.rs @@ -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(); diff --git a/src/app/update/mod.rs b/src/app/update/mod.rs index 6408592db..6f1ab0b64 100644 --- a/src/app/update/mod.rs +++ b/src/app/update/mod.rs @@ -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(); diff --git a/src/app/view/modal.rs b/src/app/view/modal.rs index d5f81eae6..5f693e757 100644 --- a/src/app/view/modal.rs +++ b/src/app/view/modal.rs @@ -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)) diff --git a/src/locale_catalog.rs b/src/locale_catalog.rs index e1526f410..4d0f65539 100644 --- a/src/locale_catalog.rs +++ b/src/locale_catalog.rs @@ -5546,6 +5546,13 @@ pub(super) fn message_attribute(source: &str) -> Option<(&'static str, &'static "Overlapping object" => Some(("count-feature", "overlap")), "Show Count Instances" => Some(("count-feature", "show-instances")), "Geometries: {}" => Some(("count-feature", "geometries")), + "Count - Invalid Area" => Some(("count-feature", "invalid-title")), + "The changes to count boundary have resulted to an invalid count area. What do you want to do?" => Some(("count-feature", "invalid-message")), + "Undo the changes to the count boundary" => Some(("count-feature", "invalid-undo")), + "The last change is undone; the boundary and the count area come back." => Some(("count-feature", "invalid-undo-detail")), + "Continue and count the entire model space" => Some(("count-feature", "invalid-continue")), + "The count area is dropped; counting goes on in all of model space." => Some(("count-feature", "invalid-continue-detail")), + "Always perform my current choice" => Some(("count-feature", "invalid-always")), _ => None, } } diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 60d442f3f..a63f22b54 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -3468,6 +3468,15 @@ impl Scene { self.associative_hatch_source_cache.borrow_mut().take(); } let mut changes = changes.to_vec(); + // A table's drawing (its *T block) follows the table's cells, sizes + // and styles; it is left alone while it already matches. + for (handle, kind) in &changes { + if !matches!(kind, ChangeKind::Removed) + && matches!(self.document.get_entity(*handle), Some(EntityType::Table(_))) + { + self.document.refresh_table_block(*handle); + } + } // A restyle (layer on/off, colour, text or dimension style) moves no // geometry, so nothing measured from it is re-resolved: an // association that disagrees with its dimension would otherwise diff --git a/src/ui/window/count_palette.rs b/src/ui/window/count_palette.rs index f444a2266..1f31eeb31 100644 --- a/src/ui/window/count_palette.rs +++ b/src/ui/window/count_palette.rs @@ -153,6 +153,11 @@ pub struct CountPalette { pub color: i16, pub error_color: i16, pub service: bool, + /// The Invalid Area dialog's "always" box while it is open. + pub invalid_always: bool, + /// What a lost count boundary does without asking: 0 ask, 1 undo, 2 go + /// on with all of model space (kept with the user settings). + pub invalid_choice: u8, /// The list's references for (document, geometry epoch, area). pub list_cache: std::cell::RefCell>, std::rc::Rc>)>>, } @@ -171,6 +176,8 @@ impl Default for CountPalette { color: 3, error_color: 1, service: true, + invalid_always: false, + invalid_choice: 0, list_cache: Default::default(), } } @@ -217,6 +224,12 @@ pub enum CountMsg { Select, Field, Close, + /// The Invalid Area dialog: undo the boundary change (also its ✕ and + /// Cancel), or go on counting all of model space; `InvalidAlways` is its + /// "always perform my current choice" box. + InvalidUndo, + InvalidContinue, + InvalidAlways(bool), } fn msg(m: CountMsg) -> Message { @@ -609,3 +622,57 @@ pub fn aci_rgba(index: i16) -> [f32; 4] { crate::scene::convert::tess_util::aci_to_rgba(&codec::types::Color::from_index(index)) } + +/// The Invalid Area dialog, shown when the count area's boundary is gone. +pub fn invalid_area_view<'a>(palette: &CountPalette, sizing: crate::ui::modal::ModalSizing) -> Element<'a, Message> { + let action = |title: String, detail: String, m: CountMsg| -> Element<'a, Message> { + button( + row![ + text("→").size(16).style(|theme: &Theme| text::Style { color: Some(theme.palette().primary.base.color) }), + column![text(title).size(13), text(detail).size(11).style(muted_style)].spacing(2), + ] + .spacing(10) + .align_y(iced::Center), + ) + .on_press(msg(m)) + .width(Fill) + .padding([10, 12]) + .style(button_style(false)) + .into() + }; + column![ + row![ + crate::ui::icons::themed_warning(WARNING_ICON, 20.0), + text(crate::t!("The changes to count boundary have resulted to an invalid count area. What do you want to do?")) + .size(14) + .width(Fill), + ] + .spacing(12) + .align_y(iced::Center), + action( + crate::t!("Undo the changes to the count boundary").into_owned(), + crate::t!("The last change is undone; the boundary and the count area come back.").into_owned(), + CountMsg::InvalidUndo, + ), + action( + crate::t!("Continue and count the entire model space").into_owned(), + crate::t!("The count area is dropped; counting goes on in all of model space.").into_owned(), + CountMsg::InvalidContinue, + ), + row![ + checkbox(palette.invalid_always) + .label(crate::t!("Always perform my current choice").into_owned()) + .text_size(12) + .size(14) + .on_toggle(|v| msg(CountMsg::InvalidAlways(v))), + Space::new().width(Fill), + crate::ui::style::form::dialog_button(crate::t!("Cancel"), msg(CountMsg::InvalidUndo), false), + ] + .spacing(8) + .align_y(iced::Center), + ] + .spacing(10) + .padding([12, 14]) + .width(sizing.width) + .into() +}