--- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "patient-monitor-simulation" -version = "0.6.1" +version = "0.6.2" edition = "2021" license = "MIT" description = "Synthetic patient-monitor simulation for teaching (not for clinical use)" --- a/README.de.md +++ b/README.de.md @@ -1,4 +1,4 @@ -# Patient Monitor Simulation (PaMSim) — v0.6.1 +# Patient Monitor Simulation (PaMSim) — v0.6.2 Ein mit Rust und GTK4 entwickelter Patient*innenmonitor-Simulator mit zwei Fenstern für die Lehre unter Fedora Linux. @@ -72,6 +72,17 @@ eine bereits laufende Messung nicht abgebrochen. **Measure now** funktioniert auch bei ausgeschalteter Automatik. Dann bleibt die Intervallanzeige leer und der Monitor zeigt `AUTO OFF`. + +### Anordnung der ART-Alarmgrenzen (v0.6.2) + +Das Touchmenü für die invasive arterielle Druckmessung ordnet **SYS, MAP und +DIA** in drei Spalten an. Die obere Bedienzeile enthält die **oberen (↑)** +Alarmgrenzen, die zweite die **unteren (↓)** Alarmgrenzen. **PPV** folgt unter +SYS mit eigenen oberen und unteren Grenzwerten. Die bisherigen großen +**+ / Wert / − / EIN-AUS**-Schaltflächen und ihre Bedienlogik bleiben erhalten. +Die Gestaltung verwendet weiterhin Schwarz, Hellgrau und schmale Rahmenlinien. +Alle anderen Parametermenüs bleiben unverändert. Alarmverarbeitung und +Voreinstellungen sind von dieser Layoutänderung nicht betroffen. ## Thoraxkompressionen (v0.5.4) --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Patient Monitor Simulation (PaMSim) — v0.6.1 +# Patient Monitor Simulation (PaMSim) — v0.6.2 A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedora Linux. @@ -66,6 +66,17 @@ cycle already in progress. Manual measurement remains possible while Auto is off. The interval bar is empty and the monitor displays `AUTO OFF` whenever automatic measurements are disabled. + +### ART alarm-limit arrangement (v0.6.2) + +The ART touchscreen alarm panel groups **SYS, MAP and DIA** in three +side-by-side columns. The first control row adjusts their **upper (↑)** limits; +the second adjusts their **lower (↓)** limits. **PPV** appears below SYS, with +its own upper and lower controls. Each bound retains the existing large +**+ / value / − / ON-OFF** buttons, including previous-value restoration. +The groups share the monitor's neutral black/grey palette and thin borders. +All other module menus retain their previous arrangement. This is a layout +change only; thresholds, presets and alarm evaluation are unchanged. ## Chest compressions (v0.5.4) --- a/src/ui.rs +++ b/src/ui.rs @@ -608,7 +608,16 @@ window.ecg-settings button.ecg-apply { color: #000000; background-color: #e5e9eb; font-weight: bold; } - window.ecg-settings button.ecg-close { background-color: #171717; }" + window.ecg-settings button.ecg-close { background-color: #171717; } + window.ecg-settings box.art-limit-frame { + border: 0.8px solid #6b757d; padding: 12px; + } + window.ecg-settings label.art-limit-heading { + font-weight: bold; font-size: 17px; + } + window.ecg-settings label.art-limit-arrow { + font-size: 21px; + }" ); gtk::style_context_add_provider_for_display( &display, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION); @@ -969,6 +978,127 @@ state } +/// ART-only keyboard-free limit editor: the existing button appearance and +/// callback semantics are retained, but its widgets are stacked vertically +/// for the SYS/MAP/DIA columns and the PPV controls below them. +#[allow(clippy::too_many_arguments)] +fn art_touch_limit(grid: >k::Grid, column: i32, row: i32, + initial: Option, fallback: i32, + step: i32, maximum: i32) -> Rc>> { + let state = Rc::new(Cell::new(initial)); + let previous = Rc::new(Cell::new(initial.unwrap_or(fallback))); + let controls = gtk::Box::new(Orientation::Vertical, 7); + controls.set_halign(gtk::Align::Center); + controls.set_hexpand(true); + + let plus = gtk::Button::with_label("+"); + plus.set_size_request(54, 50); + plus.set_halign(gtk::Align::Center); + controls.append(&plus); + + let display = gtk::Label::new(None); + display.add_css_class("ecg-limit-value"); + display.set_width_chars(5); + display.set_xalign(0.5); + controls.append(&display); + + let minus = gtk::Button::with_label("−"); + minus.set_size_request(54, 50); + minus.set_halign(gtk::Align::Center); + controls.append(&minus); + + let toggle = gtk::Button::new(); + toggle.set_size_request(78, 50); + toggle.set_halign(gtk::Align::Center); + show_touch_hr_limit(initial, &display, &toggle); + controls.append(&toggle); + + for (button, direction) in [(plus, 1), (minus, -1)] { + let state = state.clone(); + let previous = previous.clone(); + let display = display.clone(); + let toggle = toggle.clone(); + button.connect_clicked(move |_| { + let new_value = state.get().map_or(previous.get(), |current| { + (current + direction * step).clamp(0, maximum) + }); + state.set(Some(new_value)); + previous.set(new_value); + show_touch_hr_limit(Some(new_value), &display, &toggle); + }); + } + toggle.connect_clicked({ + let state = state.clone(); + let previous = previous.clone(); + let display = display.clone(); + move |button| { + let new_value = match state.get() { + Some(value) => { previous.set(value); None } + None => Some(previous.get()), + }; + state.set(new_value); + show_touch_hr_limit(new_value, &display, button); + } + }); + grid.attach(&controls, column, row, 1, 1); + state +} + +/// Map the four ART parameters to the three-column alarm grid. Row 1 is +/// upper thresholds, row 2 lower; PPV occupies column SYS in rows 4 and 5. +fn art_alarm_position(index: usize) -> (i32, i32, i32, i32, &'static str) { + match index { + 0 => (1, 0, 1, 2, "SYS"), + 1 => (2, 0, 1, 2, "MAP"), + 2 => (3, 0, 1, 2, "DIA"), + 3 => (1, 3, 4, 5, "PPV"), + _ => unreachable!("ART has exactly four alarm parameters"), + } +} + +/// The ART alarm menu groups SYS/MAP/DIA into columns with upper limits in +/// the first row and lower limits in the second; PPV occupies the first +/// parameter column beneath them. It reuses the same alarm draft/Apply path. +fn art_alarm_grid(specs: Vec, drafts: &mut Vec) -> gtk::Box { + let frame = gtk::Box::new(Orientation::Vertical, 16); + frame.add_css_class("art-limit-frame"); + frame.set_hexpand(true); + + let heading = gtk::Label::new(Some("Alarm Limits")); + heading.add_css_class("art-limit-heading"); + heading.set_xalign(0.0); + frame.append(&heading); + + let grid = gtk::Grid::new(); + grid.set_hexpand(true); + grid.set_column_spacing(12); + grid.set_row_spacing(23); + + for (row, arrow) in [(1, "↑"), (2, "↓"), (4, "↑"), (5, "↓")] { + let label = gtk::Label::new(Some(arrow)); + label.add_css_class("art-limit-arrow"); + label.set_width_chars(2); + grid.attach(&label, 0, row, 1, 1); + } + for (i, spec) in specs.into_iter().enumerate() { + let (column, title_row, upper_row, lower_row, title) = art_alarm_position(i); + let label = gtk::Label::new(Some(title)); + label.add_css_class("art-limit-heading"); + label.set_hexpand(true); + grid.attach(&label, column, title_row, 1, 1); + + let upper = art_touch_limit(&grid, column, upper_row, spec.limits.upper, + spec.restore_upper, spec.step, spec.maximum); + let lower = art_touch_limit(&grid, column, lower_row, spec.limits.lower, + spec.restore_lower, spec.step, spec.maximum); + drafts.push(TouchAlarmDraft { + name: spec.name, lower, upper, apply: spec.apply, + }); + } + frame.append(&grid); + frame +} + /// A monitor-side menu may change only alarm limits. All patient and /// measurement configuration (including NIBP scheduling) stays Admin-only. fn apply_module_alarm_changes( @@ -1006,8 +1136,8 @@ .transient_for(monitor) .modal(true) .resizable(true) - .default_width(560) - .default_height(if channel == render::TouchChannel::Art { 720 } else { 610 }) + .default_width(if channel == render::TouchChannel::Art { 720 } else { 560 }) + .default_height(if channel == render::TouchChannel::Art { 790 } else { 610 }) .build(); dialog.add_css_class("ecg-settings"); dialog.set_decorated(false); @@ -1039,25 +1169,42 @@ // Every numeric alarm has two optional bounds, editable without a keyboard. let specs = module_alarm_specs(channel, ¤t); let mut alarm_drafts = Vec::new(); - for spec in specs { - let label = gtk::Label::new(Some(&format!("{} alarm limits · {}", spec.name, spec.unit))); - label.set_xalign(0.0); - inner.append(&label); - let lower = module_touch_limit(&inner, "↓ Lower", spec.limits.lower, - spec.restore_lower, spec.step, spec.maximum); - let upper = module_touch_limit(&inner, "↑ Upper", spec.limits.upper, - spec.restore_upper, spec.step, spec.maximum); - alarm_drafts.push(TouchAlarmDraft { - name: spec.name, lower, upper, apply: spec.apply, - }); - inner.append(&ecg_menu_divider()); + if channel == render::TouchChannel::Art { + // The ART panel uses the requested column/row arrangement. Other + // channels retain their current one-parameter-at-a-time layout. + inner.append(&art_alarm_grid(specs, &mut alarm_drafts)); + } else { + for spec in specs { + let label = gtk::Label::new(Some(&format!("{} alarm limits · {}", spec.name, spec.unit))); + label.set_xalign(0.0); + inner.append(&label); + let lower = module_touch_limit(&inner, "↓ Lower", spec.limits.lower, + spec.restore_lower, spec.step, spec.maximum); + let upper = module_touch_limit(&inner, "↑ Upper", spec.limits.upper, + spec.restore_upper, spec.step, spec.maximum); + alarm_drafts.push(TouchAlarmDraft { + name: spec.name, lower, upper, apply: spec.apply, + }); + inner.append(&ecg_menu_divider()); + } } let error = gtk::Label::new(None); error.set_xalign(0.0); error.add_css_class("menu-error"); error.set_wrap(true); - inner.append(&error); + // The ART layout is taller; keep validation and buttons visible while + // the alarm-limit controls scroll on smaller monitor touchscreens. + let footer = gtk::Box::new(Orientation::Vertical, 8); + if channel == render::TouchChannel::Art { + footer.set_margin_start(20); + footer.set_margin_end(20); + footer.set_margin_top(8); + footer.set_margin_bottom(12); + footer.append(&error); + } else { + inner.append(&error); + } let buttons = gtk::Box::new(Orientation::Horizontal, 12); buttons.set_halign(gtk::Align::End); let cancel = gtk::Button::with_label("Cancel"); @@ -1097,7 +1244,12 @@ }); buttons.append(&cancel); buttons.append(&apply); - inner.append(&buttons); + if channel == render::TouchChannel::Art { + footer.append(&buttons); + content.append(&footer); + } else { + inner.append(&buttons); + } dialog.set_child(Some(&content)); let escape = gtk::EventControllerKey::new(); @@ -1131,6 +1283,31 @@ assert_eq!(specs.len(), expected); assert!(specs.iter().all(|spec| spec.maximum > 0 && spec.step > 0)); } + } + + #[test] + fn art_menu_columns_follow_sys_map_dia_and_ppv_order() { + assert_eq!(art_alarm_position(0), (1, 0, 1, 2, "SYS")); + assert_eq!(art_alarm_position(1), (2, 0, 1, 2, "MAP")); + assert_eq!(art_alarm_position(2), (3, 0, 1, 2, "DIA")); + assert_eq!(art_alarm_position(3), (1, 3, 4, 5, "PPV")); + let specs = module_alarm_specs(render::TouchChannel::Art, &Parameters::default()); + assert_eq!(specs.iter().map(|spec| spec.name).collect::>(), + ["ART systolic", "ART MAP", "ART diastolic", "PPV"]); + let mut alarms = AlarmSettings::default(); + let limits = [ + AlarmLimits { lower: Some(80), upper: Some(180) }, + AlarmLimits { lower: Some(60), upper: Some(100) }, + AlarmLimits { lower: None, upper: None }, + AlarmLimits { lower: None, upper: Some(10) }, + ]; + for (spec, value) in specs.into_iter().zip(limits.iter().copied()) { + (spec.apply)(&mut alarms, value); + } + assert_eq!(alarms.art_sys, limits[0]); + assert_eq!(alarms.art_map, limits[1]); + assert_eq!(alarms.art_dia, limits[2]); + assert_eq!(alarms.ppv, limits[3]); } #[test]