v0.6.4 — NIBP touch controls restored

The monitor-side NIBP settings menu again contains **Measure now**,
**Automatic measurement ON/OFF** and the **measurement interval** (1, 3, 5,
10, 20, 30, 60 minutes). These controls are above the horizontal SYS/MAP/DIA
alarm matrix and share its monochrome touchscreen styling. Auto and interval
are saved with Apply; Measure now starts a cuff cycle immediately regardless
of Auto. Both monitor and Admin display the selected settings. Other monitor
menus remain limited to alarm thresholds; NIBP cuff placement, the simulated
failed-reading option and non-NIBP signal settings remain Admin-only.
This commit is contained in:
GABRIEL Sebastian 2026-11-12 20:07:35 +01:00
commit 00dc22b1aa
9 changed files with 702 additions and 56 deletions

View file

@ -279,6 +279,10 @@ impl Simulator {
self.spo2_quality(p))
}
pub fn nibp_measuring(&self) -> bool {
self.nibp.measuring()
}
pub fn start_nibp_now(&mut self, p: &Parameters) {
let quality = self.nibp_start_quality(p);
self.nibp.measure_now(self.time, p, quality);

View file

@ -108,8 +108,8 @@ fn create_monitor(app: &Application, params: SharedParams,
});
window.add_controller(keys);
// One gesture opens alarm-only panels for visible waveform/numeric rows
// and NIBP's bottom-right cell. Mouse and Wayland touch share geometry.
// Mouse and Wayland touch open the visible module's settings panel.
// NIBP alone also includes its explicitly requested measurement controls.
let monitor_menu: MonitorMenuHandle = Rc::new(RefCell::new(None));
let click = gtk::GestureClick::new();
click.connect_released({
@ -117,13 +117,14 @@ fn create_monitor(app: &Application, params: SharedParams,
let window = window.clone();
let canvas = canvas.clone();
let params = params.clone();
let simulator = simulator.clone();
move |_gesture, _press_count, x, y| {
let touched = {
let p = params.borrow();
render::monitor_hit_test(x, y, canvas.width(), canvas.height(), &p)
};
if let Some(channel) = touched {
open_module_menu(&app, &window, params.clone(),
open_module_menu(&app, &window, params.clone(), simulator.clone(),
admin_changed.clone(), monitor_menu.clone(), channel);
}
}
@ -133,11 +134,25 @@ fn create_monitor(app: &Application, params: SharedParams,
window
}
/// Map an Admin NIBP measurement interval to its dropdown selection.
/// The touchscreen alarm menus do not expose scheduling controls.
/// Both Admin and the monitor NIBP menu use the same interval options.
const NIBP_INTERVALS: [i32; 7] = [1, 3, 5, 10, 20, 30, 60];
fn nibp_interval_index(minutes: i32) -> u32 {
const INTERVALS: [i32; 7] = [1, 3, 5, 10, 20, 30, 60];
INTERVALS.iter().position(|&value| value == minutes).unwrap_or(2) as u32
NIBP_INTERVALS.iter().position(|&value| value == minutes).unwrap_or(2) as u32
}
fn nibp_interval_minutes(selected: u32) -> i32 {
NIBP_INTERVALS.get(selected as usize).copied().unwrap_or(5)
}
/// Apply only the explicitly requested monitor-side NIBP measurement settings.
/// Neither cuff settings nor any other module's configuration is changed.
fn apply_nibp_measurement_settings(p: &mut Parameters, selected: u32, auto: bool) -> bool {
let minutes = nibp_interval_minutes(selected);
let changed = p.nibp_interval_minutes != minutes || p.nibp_auto_measurement != auto;
p.nibp_interval_minutes = minutes;
p.nibp_auto_measurement = auto;
changed
}
fn create_admin(app: &Application, params: SharedParams,
@ -437,10 +452,9 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
let nibp_interval_dropdown = add_dropdown_at(&nibp, "Measurement interval",
&["1 min", "3 min", "5 min", "10 min", "20 min", "30 min", "60 min"],
2, params.clone(), |p, selected| {
p.nibp_interval_minutes = match selected {
0 => 1, 1 => 3, 2 => 5, 3 => 10, 4 => 20, 5 => 30, _ => 60,
};
nibp_interval_index(params.borrow().nibp_interval_minutes),
params.clone(), |p, selected| {
p.nibp_interval_minutes = nibp_interval_minutes(selected);
});
let nibp_auto = gtk::CheckButton::with_label("Automatic NIBP measurement");
nibp_auto.set_active(params.borrow().nibp_auto_measurement);
@ -602,6 +616,10 @@ fn install_ecg_menu_style() {
min-height: 48px; min-width: 52px;
}
window.ecg-settings button:hover { background-color: #303437; }
window.ecg-settings dropdown {
color: #e5e9eb; background-color: #171717;
border: 1px solid #6b757d; min-height: 48px;
}
window.ecg-settings button.ecg-apply {
color: #000000; background-color: #e5e9eb; font-weight: bold;
}
@ -866,8 +884,85 @@ fn alarm_limit_matrix(specs: Vec<TouchAlarmSpec>,
frame
}
/// A monitor-side menu may change only alarm limits. All patient and
/// measurement configuration (including NIBP scheduling) stays Admin-only.
/// Add the three explicitly requested NIBP actions to the monitor menu.
/// Alarm limits, interval and Auto are staged until Apply. "Measure now" is
/// an immediate command, independent of Auto and of the staged settings.
fn nibp_touch_measurement_controls(
current: &Parameters,
params: SharedParams,
simulator: Rc<RefCell<Simulator>>,
) -> (gtk::Box, gtk::DropDown, gtk::ToggleButton) {
let section = gtk::Box::new(Orientation::Vertical, 12);
section.add_css_class("alarm-limit-frame");
section.set_hexpand(true);
let heading = gtk::Label::new(Some("NIBP measurement"));
heading.add_css_class("alarm-limit-heading");
heading.set_xalign(0.0);
section.append(&heading);
let row = gtk::Box::new(Orientation::Horizontal, 12);
let label = gtk::Label::new(Some("Measurement interval"));
label.set_hexpand(true);
label.set_xalign(0.0);
let interval = gtk::DropDown::from_strings(&[
"1 min", "3 min", "5 min", "10 min", "20 min", "30 min", "60 min",
]);
interval.set_selected(nibp_interval_index(current.nibp_interval_minutes));
interval.set_size_request(160, 52);
row.append(&label);
row.append(&interval);
section.append(&row);
let action_row = gtk::Box::new(Orientation::Horizontal, 12);
action_row.set_homogeneous(true);
let auto = gtk::ToggleButton::new();
auto.set_active(current.nibp_auto_measurement);
auto.set_label(if auto.is_active() {
"Automatic measurement: ON"
} else {
"Automatic measurement: OFF"
});
auto.connect_toggled(|button| {
button.set_label(if button.is_active() {
"Automatic measurement: ON"
} else {
"Automatic measurement: OFF"
});
});
action_row.append(&auto);
let measure_now = gtk::Button::with_label("Measure now");
measure_now.set_tooltip_text(Some("Start an NIBP cuff measurement immediately"));
action_row.append(&measure_now);
section.append(&action_row);
let feedback = gtk::Label::new(Some(
"Measure now acts immediately. Interval and Auto are saved with Apply."
));
feedback.set_xalign(0.0);
feedback.set_wrap(true);
measure_now.connect_clicked({
let feedback = feedback.clone();
move |_| {
// Drop the immutable Ref before borrowing the simulator mutably.
let measuring = { simulator.borrow().nibp_measuring() };
if measuring {
feedback.set_text("NIBP measurement already in progress.");
} else {
simulator.borrow_mut().start_nibp_now(&params.borrow());
feedback.set_text("NIBP measurement started.");
}
}
});
// Keep the explanatory label visible while the button changes its status.
// It is owned by the section, not by the button callback.
section.append(&feedback);
(section, interval, auto)
}
/// All monitor modules can edit alarm limits. Only NIBP additionally offers
/// the explicitly requested interval, Auto and immediate measurement controls.
fn apply_module_alarm_changes(
p: &mut Parameters,
limits: &[(fn(&mut AlarmSettings, AlarmLimits), AlarmLimits)],
@ -879,12 +974,13 @@ fn apply_module_alarm_changes(
p.alarms != previous
}
/// Open a modal alarm-limit panel with the same black, grey, 0.8 px divider
/// and border design as the ECG panel. Other parameters are Admin-only.
/// Open a modal monitor settings panel in neutral black/grey styling.
/// All modules edit alarm limits; NIBP also retains its explicit controls.
#[allow(clippy::too_many_arguments)]
fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
params: SharedParams, on_change: AdminChanged,
open_menu: MonitorMenuHandle, channel: render::TouchChannel) {
params: SharedParams, simulator: Rc<RefCell<Simulator>>,
on_change: AdminChanged, open_menu: MonitorMenuHandle,
channel: render::TouchChannel) {
if let Some(existing) = open_menu.borrow().as_ref().and_then(|weak| weak.upgrade()) {
existing.present();
return;
@ -906,7 +1002,7 @@ fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
.default_width(800)
.default_height(match channel {
render::TouchChannel::Art => 560,
render::TouchChannel::Nibp => 490,
render::TouchChannel::Nibp => 640,
render::TouchChannel::Ecg => 310,
_ => 420,
})
@ -938,6 +1034,18 @@ fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
inner.append(&heading);
inner.append(&ecg_menu_divider());
// NIBP is the explicit exception to the alarm-only monitor menu policy.
// Put the manual measurement action above the limit matrix for easy access.
let nibp_controls = if channel == render::TouchChannel::Nibp {
let (section, interval, auto) = nibp_touch_measurement_controls(
&current, params.clone(), simulator);
inner.append(&section);
inner.append(&ecg_menu_divider());
Some((interval, auto))
} else {
None
};
// A shared horizontal matrix is used in every monitor-side touch menu.
let specs = module_alarm_specs(channel, &current);
let mut alarm_drafts = Vec::new();
@ -983,7 +1091,12 @@ fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
}
let changed_alarms = {
let mut p = params.borrow_mut();
apply_module_alarm_changes(&mut p, &selected_limits)
let changed = apply_module_alarm_changes(&mut p, &selected_limits);
if let Some((interval, auto)) = &nibp_controls {
apply_nibp_measurement_settings(&mut p,
interval.selected(), auto.is_active());
}
changed
};
if let Some(callback) = on_change.borrow().as_ref() {
callback(changed_alarms);
@ -1064,7 +1177,7 @@ mod module_touch_menu_tests {
}
#[test]
fn touchscreen_applies_only_alarm_limits_and_preserves_other_controls() {
fn monitor_alarm_edits_preserve_other_controls() {
let mut p = Parameters::default();
p.ecg_lead = EcgLead::V1;
p.spo2_quality = Spo2Quality::Poor;
@ -1093,6 +1206,40 @@ mod module_touch_menu_tests {
assert!(p.nibp_cuff_on_art);
}
#[test]
fn nibp_touch_interval_roundtrip_and_startup_off() {
let p = Parameters::default();
assert!(!p.nibp_auto_measurement);
assert_eq!(p.nibp_interval_minutes, 5);
for (index, minutes) in NIBP_INTERVALS.into_iter().enumerate() {
assert_eq!(nibp_interval_index(minutes), index as u32);
assert_eq!(nibp_interval_minutes(index as u32), minutes);
}
assert_eq!(nibp_interval_minutes(99), 5);
}
#[test]
fn nibp_touch_apply_changes_only_interval_and_auto() {
let mut p = Parameters::default();
p.nibp_no_reading = true;
p.nibp_cuff_on_spo2 = true;
p.nibp_cuff_on_art = true;
p.show_nibp = false;
p.alarms.nibp_sys.lower = Some(80);
assert!(apply_nibp_measurement_settings(&mut p, 5, true));
assert_eq!(p.nibp_interval_minutes, 30);
assert!(p.nibp_auto_measurement);
assert!(!apply_nibp_measurement_settings(&mut p, 5, true));
assert!(apply_nibp_measurement_settings(&mut p, 0, false));
assert_eq!(p.nibp_interval_minutes, 1);
assert!(!p.nibp_auto_measurement);
assert!(p.nibp_no_reading);
assert!(p.nibp_cuff_on_spo2);
assert!(p.nibp_cuff_on_art);
assert!(!p.show_nibp);
assert_eq!(p.alarms.nibp_sys.lower, Some(80));
}
}
/// Frame a parameter section with an optional monitor-colored left sidebar.