v0.3.2
This commit is contained in:
parent
788c68a1d8
commit
35a380b808
8 changed files with 954 additions and 46 deletions
|
|
@ -8,7 +8,7 @@ use gtk::glib;
|
|||
use gtk::prelude::*;
|
||||
use gtk::{Application, ApplicationWindow, Orientation};
|
||||
|
||||
use crate::model::{ArterialShape, CapnoShape, EcgRhythm, Parameters, PulseConduction};
|
||||
use crate::model::{ArterialShape, CapnoShape, EcgRhythm, Parameters, PulseConduction, Spo2Quality};
|
||||
use crate::render;
|
||||
use crate::simulation::Simulator;
|
||||
|
||||
|
|
@ -41,12 +41,12 @@ fn create_monitor(app: &Application, params: SharedParams,
|
|||
let params = params.clone();
|
||||
let simulator = simulator.clone();
|
||||
move |_area, cr, width, height| {
|
||||
let config = *params.borrow();
|
||||
let config = params.borrow();
|
||||
render::draw(cr, width, height, &config, &simulator.borrow());
|
||||
}
|
||||
});
|
||||
|
||||
// Synchronize simulation time with frame updates; synthesize at 100 Hz.
|
||||
// Synchronize simulation time with frame updates; synthesize at 250 Hz.
|
||||
let previous = Rc::new(Cell::new(Instant::now()));
|
||||
canvas.add_tick_callback({
|
||||
let params = params.clone();
|
||||
|
|
@ -54,7 +54,7 @@ fn create_monitor(app: &Application, params: SharedParams,
|
|||
let now = Instant::now();
|
||||
let elapsed = now.saturating_duration_since(previous.get()).as_secs_f64();
|
||||
previous.set(now);
|
||||
let config = *params.borrow();
|
||||
let config = params.borrow();
|
||||
simulator.borrow_mut().advance(elapsed, &config);
|
||||
area.queue_draw();
|
||||
glib::ControlFlow::Continue
|
||||
|
|
@ -105,6 +105,24 @@ fn create_admin(app: &Application, params: SharedParams,
|
|||
scroller.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic);
|
||||
let controls = gtk::Box::new(Orientation::Vertical, 12);
|
||||
|
||||
let patient = group(&controls, "Patient");
|
||||
let patient_row = gtk::Box::new(Orientation::Horizontal, 8);
|
||||
let patient_label = gtk::Label::new(Some("Patient name"));
|
||||
patient_label.set_xalign(0.0);
|
||||
patient_label.set_width_chars(17);
|
||||
let name_entry = gtk::Entry::new();
|
||||
name_entry.set_hexpand(true);
|
||||
name_entry.set_max_length(80);
|
||||
name_entry.set_placeholder_text(Some("Name displayed on monitor"));
|
||||
name_entry.set_text(¶ms.borrow().patient_name);
|
||||
name_entry.connect_changed({
|
||||
let params = params.clone();
|
||||
move |entry| params.borrow_mut().patient_name = entry.text().to_string()
|
||||
});
|
||||
patient_row.append(&patient_label);
|
||||
patient_row.append(&name_entry);
|
||||
patient.append(&patient_row);
|
||||
|
||||
let ecg = group(&controls, "ECG");
|
||||
add_visibility(&ecg, params.borrow().show_ecg, params.clone(), |p, show| p.show_ecg = show);
|
||||
add_dropdown(&ecg, "ECG rhythm", &[
|
||||
|
|
@ -126,6 +144,26 @@ fn create_admin(app: &Application, params: SharedParams,
|
|||
add_visibility(&spo2, params.borrow().show_spo2, params.clone(), |p, show| p.show_spo2 = show);
|
||||
add_numeric(&spo2, "SpO₂", "%", 0, 100, params.borrow().spo2,
|
||||
params.clone(), |p, v| p.spo2 = v);
|
||||
let sensor = gtk::CheckButton::with_label("Sensor not attached");
|
||||
sensor.set_active(!params.borrow().spo2_sensor_attached);
|
||||
sensor.connect_toggled({
|
||||
let params = params.clone();
|
||||
move |button| params.borrow_mut().spo2_sensor_attached = !button.is_active()
|
||||
});
|
||||
spo2.append(&sensor);
|
||||
add_dropdown_at(&spo2, "Signal quality", &[
|
||||
"0 — None (no reading)",
|
||||
"1 — Poor (*)",
|
||||
"2 — Adequate (**)",
|
||||
"3 — Good (***)",
|
||||
], params.borrow().spo2_quality as u32, params.clone(), |p, selected| {
|
||||
p.spo2_quality = match selected {
|
||||
1 => Spo2Quality::Poor,
|
||||
2 => Spo2Quality::Adequate,
|
||||
3 => Spo2Quality::Good,
|
||||
_ => Spo2Quality::None,
|
||||
};
|
||||
});
|
||||
add_dropdown(&spo2, "Mechanical capture", &[
|
||||
"1:1 (every QRS)",
|
||||
"2:1 (one pulse in two)",
|
||||
|
|
@ -242,12 +280,19 @@ where F: Fn(&mut Parameters, bool) + 'static {
|
|||
|
||||
fn add_dropdown<F>(parent: >k::Box, label: &str, items: &[&str],
|
||||
params: SharedParams, setter: F)
|
||||
where F: Fn(&mut Parameters, u32) + 'static {
|
||||
add_dropdown_at(parent, label, items, 0, params, setter);
|
||||
}
|
||||
|
||||
fn add_dropdown_at<F>(parent: >k::Box, label: &str, items: &[&str],
|
||||
initial: u32, params: SharedParams, setter: F)
|
||||
where F: Fn(&mut Parameters, u32) + 'static {
|
||||
let row = gtk::Box::new(Orientation::Horizontal, 8);
|
||||
let caption = gtk::Label::new(Some(label));
|
||||
caption.set_xalign(0.0);
|
||||
caption.set_width_chars(17);
|
||||
let combo = gtk::DropDown::from_strings(items);
|
||||
combo.set_selected(initial);
|
||||
combo.set_hexpand(true);
|
||||
combo.connect_selected_notify(move |combo| {
|
||||
setter(&mut params.borrow_mut(), combo.selected());
|
||||
|
|
|
|||
Loading…
Reference in a new issue