SimPaM/patches/patient-monitor-simulation-v0.5.8-to-v0.5.9.patch

420 lines
18 KiB
Diff
Raw Permalink Normal View History

--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "patient-monitor-simulation"
-version = "0.5.8"
+version = "0.5.9"
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.5.8
+# Patient Monitor Simulation (PaMSim) — v0.5.9
Ein mit Rust und GTK4 entwickelter Patient*innenmonitor-Simulator mit zwei Fenstern für die Lehre unter Fedora Linux.
@@ -26,10 +26,10 @@
Beim Ausblenden anderer Parameter werden die verbleibenden Kurvenzeilen wie
bisher dynamisch verteilt.
-## EKG-Bedienung direkt am Monitor (v0.5.8)
+## EKG-Bedienung direkt am Monitor (v0.5.9)
Durch Berühren oder Anklicken der **EKG-Zeile** öffnet sich ein eigenes
-Einstellfenster mit **grüner Schrift auf schwarzem Hintergrund**. Die gesamte
+Einstellfenster mit **hellgrauer Schrift auf schwarzem Hintergrund**. Die gesamte
EKG-Zeile ist aktiv, sowohl die Kurve links (75 %) als auch das numerische
Herzfrequenzfeld rechts (25 %). Die Bedienung ist auch im Vollbildmodus möglich.
Bei ausgeblendetem EKG ist die Interaktionsfläche deaktiviert.
@@ -42,11 +42,17 @@
eine klinisch validierte 12-Kanal-EKG-Ableitung. Frequenz, QRS-Zeitpunkte
und mechanische Pulskopplung bleiben unverändert.
- **HR alarm limits:** unabhängig einstellbare untere (↓) und obere (↑)
- Herzfrequenzgrenze in /min. Ein leeres Eingabefeld (**OFF**) deaktiviert
- die jeweilige Grenze. Zulässig sind 0–240; die untere Grenze darf die obere
- nicht überschreiten.
+ Herzfrequenzgrenze in /min. Große Tasten **− / +** ändern den jeweiligen
+ Grenzwert in **5er-Schritten** zwischen 0 und 240. Mit **OFF** lässt sich
+ jede Grenze einzeln deaktivieren; **ON** aktiviert den vorherigen Wert
+ erneut (bei anfänglich nicht gesetzten Werten 60 bzw. 100 /min).
+ Die untere Grenze darf die obere nicht überschreiten.
- **Apply** übernimmt beide Alarmgrenzen und die Ableitung gemeinsam;
**Cancel** oder **Esc** verwirft die noch nicht übernommenen Eingaben.
+
+Die Bedienelemente sind ohne Tastatur verwendbar. Schmale hellgraue
+Begrenzungslinien und Trennlinien orientieren sich an der Gestaltung des
+Monitors; die EKG-spezifische grüne Textfarbe wird hier nicht verwendet.
Die Einstellungen werden mit der Admin-Oberfläche synchronisiert. Eine am
Monitor geänderte Alarmgrenze schaltet die Alarmvoreinstellung auf **Custom**.
@@ -542,3 +548,13 @@
werden geprüft und mit dem Admin-Fenster synchronisiert. Die geänderte
Kurvenpolarität ist eine schematische Darstellung ohne diagnostischen
Anspruch; die zugrunde liegende Rhythmus- und Pulssimulation bleibt gleich.
+
+### v0.5.9 – Berührungsoptimiertes EKG-Einstellfenster
+
+Hellgraue Bedienelemente auf schwarzem Hintergrund, eine dezente umlaufende
+Rahmenlinie und 0,8 Pixel breite Trennlinien im Stil des Hauptmonitors.
+Die unteren und oberen HF-Alarmgrenzen werden am Monitor ohne Tastatur über
+große **−/+**-Tasten in 5er-Schritten und über **ON/OFF** eingestellt.
+Die Ableitung wird weiterhin über das Auswahlmenü gewählt. Änderungen
+werden erst mit **Apply** übernommen; **Cancel** verwirft sie.
+Keine Änderungen an den simulierten Vitalparametern.
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Patient Monitor Simulation (PaMSim) — v0.5.8
+# Patient Monitor Simulation (PaMSim) — v0.5.9
A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedora Linux.
@@ -23,10 +23,10 @@
bottom measurement row and other three groups remain present. Disabling one
of the four waveform channels still reflows the remaining rows above it.
-## ECG touchscreen settings (v0.5.8)
+## ECG touchscreen settings (v0.5.9)
Tap or click **anywhere in the ECG row**, on either the **trace (left 75%)** or
-**heart-rate readout (right 25%)**, to open a modal green-on-black ECG settings
+**heart-rate readout (right 25%)**, to open a modal **black-and-light-grey ECG settings**
window above the monitor. The same interaction works when the monitor is in
fullscreen mode. Touch/click input outside the ECG row opens no menu. Hiding
the ECG channel also disables its touch target.
@@ -38,12 +38,19 @@
an *illustrative lead-dependent gain/polarity transformation*. This is **not**
a diagnostic 12-lead ECG derivation; cardiac timing, HR and mechanical
capture do not change when the lead changes.
-- **HR alarm limits:** optional **↓ Lower** and **↑ Upper**, in bpm. Leave
- either box empty (OFF) to disable that alarm boundary. A limit must be in
- the range 0–240 and the lower limit must not exceed the upper limit.
+- **HR alarm limits:** optional **↓ Lower** and **↑ Upper**, in bpm.
+ Each limit has large **− / +** touch buttons that adjust the value in
+ **5 bpm steps** (range 0–240), plus an **OFF** button to disable it.
+ When disabled, an **ON** button restores its previous value (or 60 bpm
+ for an unset lower limit and 100 bpm for an unset upper limit).
+ The lower limit must not exceed the upper limit.
- **Apply** commits lead and limits together; **Cancel** or **Esc** discards
unsaved changes. Both Admin and monitor displays reflect committed changes.
Changing limits in the monitor marks the Admin alarm preset as **Custom**.
+
+The menu uses light-grey text instead of the ECG waveform color and
+subtle separators matching the main monitor divider thickness. No keyboard
+is required for the ECG menu; the Admin window retains numeric text inputs.
The Admin ECG section also includes an ECG-lead selector, synchronized with
changes made from the monitor. No settings menu is yet provided for other
@@ -561,3 +568,12 @@
(I, II, III, aVR, aVL, aVF, V1–V6), with input validation and Admin sync.
Lead changes are schematic display projections only; arrhythmia and pulse
simulation remain unchanged.
+
+### v0.5.9 — Touch-optimized ECG settings
+
+Restyled the ECG settings window with light-grey text/controls, a neutral
+0.8-pixel outer border and thin 0.8-pixel Cairo separators matching the
+monitor. Replaced the on-monitor HR limit text entries with large 5-bpm
+**−/+** buttons and independent **ON/OFF** controls; the ECG lead remains a
+touch-selectable dropdown. Pending changes still require Apply, and Cancel
+leaves the shared parameters unchanged. No signal generation was altered.
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -539,29 +539,144 @@
window
}
-/// Dark ECG control panel matching the green-on-black bedside monitor.
-/// Installed only once, with a CSS class scoped to this popup.
+/// Neutral black-and-light-grey ECG control panel. Match the monitor's
+/// MUTED divider color, with 0.8-pixel outer borders and 0.8-pixel Cairo
+/// dividers (the same thickness as the main monitor header divider).
fn install_ecg_menu_style() {
if let Some(display) = gdk::Display::default() {
let provider = gtk::CssProvider::new();
provider.load_from_data(
"window.ecg-settings { background-color: #000000; }
- window.ecg-settings box { background-color: #000000; }
- window.ecg-settings label { color: #42ff63; }
- window.ecg-settings label.menu-error { color: #ff4d50; }
- window.ecg-settings entry { color: #42ff63; background-color: #101b13;
- border: 1px solid #377547; min-height: 42px; }
- window.ecg-settings dropdown { color: #42ff63; background-color: #101b13;
- min-height: 44px; }
- window.ecg-settings button { min-height: 44px; }
- window.ecg-settings button.ecg-apply { color: #000000;
- background-image: none; background-color: #42ff63; font-weight: bold; }
- window.ecg-settings button.ecg-close { color: #42ff63;
- background-image: none; background-color: #152219; }"
+ window.ecg-settings box.ecg-panel {
+ background-color: #000000; border: 0.8px solid #6b757d;
+ }
+ window.ecg-settings label { color: #e5e9eb; }
+ window.ecg-settings label.menu-error { color: #ff8080; }
+ window.ecg-settings label.ecg-limit-value {
+ color: #e5e9eb; font-weight: bold; font-size: 19px;
+ }
+ window.ecg-settings dropdown {
+ color: #e5e9eb; background-color: #141414;
+ border: 1px solid #6b757d; min-height: 48px;
+ }
+ window.ecg-settings dropdown button {
+ color: #e5e9eb; background-color: #141414;
+ }
+ window.ecg-settings button {
+ color: #e5e9eb; background-image: none;
+ background-color: #171717; border: 1px solid #6b757d;
+ min-height: 48px; min-width: 52px;
+ }
+ window.ecg-settings button:hover { background-color: #303437; }
+ window.ecg-settings button.ecg-apply {
+ color: #000000; background-color: #e5e9eb; font-weight: bold;
+ }
+ window.ecg-settings button.ecg-close { background-color: #171717; }"
);
gtk::style_context_add_provider_for_display(
&display, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION);
}
+}
+
+/// Cairo divider with the same line thickness and color as the bedside
+/// monitor's header separator (render.rs: MUTED, 0.8 logical pixels).
+fn ecg_menu_divider() -> gtk::DrawingArea {
+ let separator = gtk::DrawingArea::new();
+ separator.set_hexpand(true);
+ separator.set_content_height(2);
+ separator.set_draw_func(|_area, cr, width, height| {
+ cr.set_source_rgb(0.42, 0.46, 0.49);
+ cr.set_line_width(0.8);
+ let y = f64::from(height) / 2.0;
+ cr.move_to(0.0, y);
+ cr.line_to(f64::from(width), y);
+ let _ = cr.stroke();
+ });
+ separator
+}
+
+const TOUCH_HR_STEP: i32 = 5;
+const MAX_HR_ALARM: i32 = 240;
+
+/// When a limit is OFF, either +/- first restores its previous value (or
+/// a sensible initial value). Subsequent presses adjust it by 5 bpm.
+fn stepped_hr_limit(current: Option<i32>, last_enabled: i32, direction: i32) -> i32 {
+ current.map_or(last_enabled, |value| {
+ (value + TOUCH_HR_STEP * direction).clamp(0, MAX_HR_ALARM)
+ })
+}
+
+fn show_touch_hr_limit(value: Option<i32>, number: &gtk::Label,
+ toggle: &gtk::Button) {
+ number.set_text(&value.map_or("OFF".to_owned(), |v| v.to_string()));
+ toggle.set_label(if value.is_some() { "OFF" } else { "ON" });
+}
+
+/// Large, keyboard-free +/- and ON/OFF controls. Returning a Cell permits
+/// Apply to read the draft value without changing the shared configuration.
+fn ecg_touch_limit(parent: &gtk::Box, caption: &str,
+ initial: Option<i32>, default: i32) -> Rc<Cell<Option<i32>>> {
+ let state = Rc::new(Cell::new(initial));
+ let previous = Rc::new(Cell::new(initial.unwrap_or(default)));
+ let row = gtk::Box::new(Orientation::Horizontal, 10);
+
+ let heading = gtk::Label::new(Some(caption));
+ heading.set_xalign(0.0);
+ heading.set_width_chars(10);
+ row.append(&heading);
+
+ let minus = gtk::Button::with_label("−");
+ minus.set_tooltip_text(Some("Decrease alarm limit by 5 bpm"));
+ minus.set_size_request(54, 50);
+ row.append(&minus);
+
+ let display = gtk::Label::new(None);
+ display.add_css_class("ecg-limit-value");
+ display.set_width_chars(5);
+ display.set_xalign(0.5);
+ row.append(&display);
+
+ let plus = gtk::Button::with_label("+");
+ plus.set_tooltip_text(Some("Increase alarm limit by 5 bpm"));
+ plus.set_size_request(54, 50);
+ row.append(&plus);
+
+ let enable_toggle = gtk::Button::new();
+ enable_toggle.set_tooltip_text(Some("Enable or disable this alarm limit"));
+ enable_toggle.set_size_request(78, 50);
+ row.append(&enable_toggle);
+ show_touch_hr_limit(initial, &display, &enable_toggle);
+
+ for (button, direction) in [(minus, -1), (plus, 1)] {
+ let state = state.clone();
+ let previous = previous.clone();
+ let display = display.clone();
+ let enable_toggle = enable_toggle.clone();
+ button.connect_clicked(move |_| {
+ let next = stepped_hr_limit(state.get(), previous.get(), direction);
+ state.set(Some(next));
+ previous.set(next);
+ show_touch_hr_limit(Some(next), &display, &enable_toggle);
+ });
+ }
+ enable_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);
+ }
+ });
+ parent.append(&row);
+ state
}
/// Displayed only for touches in the ECG row. The monitor window can remain
@@ -583,23 +698,32 @@
.transient_for(monitor)
.modal(true)
.resizable(false)
- .default_width(450)
- .default_height(340)
+ .default_width(550)
+ .default_height(410)
.build();
dialog.add_css_class("ecg-settings");
dialog.set_decorated(false);
*open_menu.borrow_mut() = Some(dialog.downgrade());
- let content = gtk::Box::new(Orientation::Vertical, 15);
- content.set_margin_top(22);
- content.set_margin_bottom(22);
- content.set_margin_start(22);
- content.set_margin_end(22);
+ let content = gtk::Box::new(Orientation::Vertical, 12);
+ content.add_css_class("ecg-panel");
+ content.set_margin_top(1);
+ content.set_margin_bottom(1);
+ content.set_margin_start(1);
+ content.set_margin_end(1);
+ // Inner padding keeps controls away from the thin panel border.
+ let inner = gtk::Box::new(Orientation::Vertical, 12);
+ inner.set_margin_top(20);
+ inner.set_margin_bottom(20);
+ inner.set_margin_start(20);
+ inner.set_margin_end(20);
+ content.append(&inner);
+
let title = gtk::Label::new(Some("ECG / SETTINGS"));
title.set_xalign(0.0);
title.add_css_class("title-2");
- content.append(&title);
- content.append(&gtk::Separator::new(Orientation::Horizontal));
+ inner.append(&title);
+ inner.append(&ecg_menu_divider());
let lead_row = gtk::Box::new(Orientation::Horizontal, 12);
let lead_label = gtk::Label::new(Some("ECG lead"));
@@ -610,34 +734,27 @@
lead_selector.set_hexpand(true);
lead_row.append(&lead_label);
lead_row.append(&lead_selector);
- content.append(&lead_row);
+ inner.append(&lead_row);
+ inner.append(&ecg_menu_divider());
let limits_header = gtk::Label::new(Some("HR alarm limits · bpm"));
limits_header.set_xalign(0.0);
- content.append(&limits_header);
- let limits_row = gtk::Box::new(Orientation::Horizontal, 10);
- let lower = alarm_entry(limits.lower, "OFF");
- let upper = alarm_entry(limits.upper, "OFF");
- lower.set_hexpand(true);
- upper.set_hexpand(true);
- limits_row.append(&gtk::Label::new(Some("↓ Lower")));
- limits_row.append(&lower);
- limits_row.append(&gtk::Label::new(Some("↑ Upper")));
- limits_row.append(&upper);
- content.append(&limits_row);
-
+ inner.append(&limits_header);
+ let lower = ecg_touch_limit(&inner, "↓ Lower", limits.lower, 60);
+ let upper = ecg_touch_limit(&inner, "↑ Upper", limits.upper, 100);
let hint = gtk::Label::new(Some(
- "Leave either limit empty to disable that alarm boundary."
+ "+/− adjusts by 5 bpm. OFF disables the limit; ON restores it."
));
hint.set_wrap(true);
hint.set_xalign(0.0);
- content.append(&hint);
+ inner.append(&hint);
+ inner.append(&ecg_menu_divider());
let error = gtk::Label::new(None);
error.add_css_class("menu-error");
error.set_xalign(0.0);
error.set_wrap(true);
- content.append(&error);
+ inner.append(&error);
let buttons = gtk::Box::new(Orientation::Horizontal, 12);
buttons.set_halign(gtk::Align::End);
@@ -652,13 +769,7 @@
apply.connect_clicked({
let weak = dialog.downgrade();
move |_| {
- let (Ok(lo), Ok(hi)) = (
- parse_alarm_bound(&lower, 240), parse_alarm_bound(&upper, 240)
- ) else {
- error.set_text("Alarm limits must be 0–240 bpm, or blank (OFF).");
- return;
- };
- let new_limits = AlarmLimits { lower: lo, upper: hi };
+ let new_limits = AlarmLimits { lower: lower.get(), upper: upper.get() };
if !new_limits.valid() {
error.set_text("The lower limit must not exceed the upper limit.");
return;
@@ -679,7 +790,7 @@
});
buttons.append(&cancel);
buttons.append(&apply);
- content.append(&buttons);
+ inner.append(&buttons);
dialog.set_child(Some(&content));
let escape = gtk::EventControllerKey::new();
@@ -694,6 +805,25 @@
});
dialog.add_controller(escape);
dialog.present();
+}
+
+#[cfg(test)]
+mod ecg_touch_menu_tests {
+ use super::*;
+
+ #[test]
+ fn touch_step_uses_five_bpm_and_respects_bounds() {
+ assert_eq!(stepped_hr_limit(Some(60), 60, 1), 65);
+ assert_eq!(stepped_hr_limit(Some(60), 60, -1), 55);
+ assert_eq!(stepped_hr_limit(Some(240), 240, 1), 240);
+ assert_eq!(stepped_hr_limit(Some(0), 0, -1), 0);
+ }
+
+ #[test]
+ fn disabled_alarm_reenables_at_last_saved_value() {
+ assert_eq!(stepped_hr_limit(None, 60, 1), 60);
+ assert_eq!(stepped_hr_limit(None, 100, -1), 100);
+ }
}
/// Frame a parameter section with an optional monitor-colored left sidebar.