From adcdeb569e451fe622dde3be194b94a50fc81e14 Mon Sep 17 00:00:00 2001 From: "robin.cole@earthdaily.com" Date: Sun, 22 Nov 2026 07:49:40 +0000 Subject: [PATCH 01/11] feat(annotation): add class selection and assignment --- crates/engine/src/cmd/edit.rs | 77 ++++--- crates/engine/src/tests/cancellation.rs | 12 + crates/ui-egui/src/annotation.rs | 196 ++++++++++++++++ crates/ui-egui/src/annotation_classes.rs | 275 +++++++++++++++++++++++ crates/ui-egui/src/boxedit.rs | 19 +- crates/ui-egui/src/circleedit.rs | 19 +- crates/ui-egui/src/lib.rs | 8 +- crates/ui-egui/src/readjob.rs | 77 ++++++- docs/user-guide/editing.md | 21 ++ 9 files changed, 666 insertions(+), 38 deletions(-) create mode 100644 crates/ui-egui/src/annotation_classes.rs diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 2ca4440d8f..551c7d88b6 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -744,8 +744,14 @@ fn typed(raw: Json, ty: FieldType) -> Result { /// Adds an empty field of a type: long, double, text, boolean, date or datetime. Table rows /// are filled on the desktop worker ([`table_ahead`]), with progress and Cancel. +/// Fills a new column on the desktop field-edit worker, with Cancel between rows. +/// The shared row storage's first copy cannot be interrupted. fn add_field(s: &mut Session, p: &Json) -> CmdResult { - if let Some(result) = land_table_edit(s, p, "edit.addField") { + let landed = match target(s, p)? { + Target::Layer(_) => land_layer_schema(s, p, "edit.addField"), + Target::Table(_) => land_table_edit(s, p, "edit.addField"), + }; + if let Some(result) = landed { return result; } let t = write_target(s, p)?; @@ -766,15 +772,10 @@ fn add_field(s: &mut Session, p: &Json) -> CmdResult { if ds.field_index(name).is_some() { return Err(format!("a field named '{name}' already exists")); } - let table = matches!(t, Target::Table(_)); ds.fields.push(Field::new(name, ty)); - if table { - rustgis_data::progress::begin(ds.features.len()); - } + rustgis_data::progress::begin(ds.features.len()); for row in &mut ds.features { - if table { - rustgis_data::progress::step(1).map_err(|e| e.to_string())?; - } + rustgis_data::progress::step(1).map_err(|e| e.to_string())?; // Adding one column to shared rows should not double every row's attribute capacity. row.attrs.reserve_exact(1); row.attrs.push(Value::Null); @@ -795,7 +796,7 @@ fn add_field(s: &mut Session, p: &Json) -> CmdResult { fn convert_field(s: &mut Session, p: &Json) -> CmdResult { // A prepared result has one concrete type: do not consume it while probing another type. let landed = match target(s, p)? { - Target::Layer(_) => land_layer_dates(s, p), + Target::Layer(_) => land_layer_schema(s, p, "edit.convertField"), Target::Table(_) => land_table_edit(s, p, "edit.convertField"), }; if let Some(result) = landed { @@ -1267,7 +1268,7 @@ pub(crate) const TABLE_EDITS: &[(&str, &str, fn(&mut Session, &Json) -> CmdResul ]; /// The registered command and progress label for a table write. Layer invocations keep their -/// existing path; the desktop uses this worker only when parameters name a standalone table. +/// existing path except Add Field and date conversion, which also prepare loaded layer rows. pub fn table_edit_in_background(command: &str) -> Option<(&'static str, &'static str)> { TABLE_EDITS.iter().find(|(id, ..)| *id == command).map(|(id, name, _)| (*id, *name)) } @@ -1346,7 +1347,11 @@ pub(crate) fn script_table( /// shared row storage's first copy and one expression evaluation cannot be interrupted. pub(crate) fn table_ahead(s: &Session, command: &str, p: &Json) -> Result, String> { let Target::Table(i) = target(s, p)? else { - return if command == "edit.convertField" { layer_dates_ahead(s, p).map(Some) } else { Ok(None) }; + return if matches!(command, "edit.convertField" | "edit.addField") { + layer_schema_ahead(s, command, p).map(Some) + } else { + Ok(None) + }; }; let &(_, name, handler) = TABLE_EDITS.iter().find(|(id, ..)| *id == command).ok_or("not a table edit")?; let table = s.project.tables.get(i).ok_or("no such table")?.clone(); @@ -1368,8 +1373,8 @@ pub(crate) fn table_ahead(s: &Session, command: &str, p: &Json) -> Result