ui: draw the marked elements in the error colour

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-15 23:32:47 -04:00
1 parent 75b8c7e26e
commit e9801e4528
1 file changed
+22
+22
View File
@@ -1086,6 +1086,11 @@ impl ModelApp {
Some(p) => results::scene(p, style, show, &t),
None => scene::build(&self.display.1, style, show, &t),
};
// The elements Mark Bad Elements marked, in the error colour over the element faces.
if self.plot.1.is_none() && show.mesh && style != scene::Style::Wireframe {
let marked = fieldcraft_engine::view::marked(&self.session);
fieldcraft_engine::view::mark(&mut s, &self.display.1, &marked, theme::rgb(t.error));
}
let mut datums = Aabb3::EMPTY;
if show.geometry && self.plot.1.is_none() {
datums = scene::datums(&mut s, &self.session, &self.display.1.bounds, self.selected_datum().as_deref(), &t);
@@ -2432,6 +2437,23 @@ mod tests {
assert!(!status.error && !status.text.contains('{'));
}
/// Mark Bad Elements draws the marked elements' faces in the error colour, and only while
/// they are marked.
#[test]
fn marked_elements_draw_in_the_error_colour() {
let mut app = ModelApp::new(Session::default());
app.run_script(&fieldcraft_engine::sample::script()).unwrap();
let error = theme::rgb(theme::Tokens::get(app.ui.dark).error);
let red = |app: &mut ModelApp| app.scene().1.tris.iter().filter(|t| t.color == error).count();
assert_eq!(red(&mut app), 0);
let some = app.session.model.elements().keys().take(3).copied().collect::<Vec<_>>();
app.run("mesh.quality.mark", json!({"elements": some, "limits": {"scaled_jacobian": 1.5}})).unwrap();
let marked = red(&mut app);
assert!(marked > 0 && marked < app.scene().1.tris.len(), "{marked}");
app.run("mesh.quality.mark", json!({})).unwrap();
assert_eq!(red(&mut app), 0);
}
#[test]
fn starting_a_command_opens_its_form_and_running_it_closes_the_form() {
let mut app = ModelApp::new(Session::default());