From d029feb2d55f5579f322ec893f95a6aabfcc6560 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sat, 20 Jan 2018 18:21:39 +0100 Subject: Show ICD in gaschange icons Add an exclamation mark in the gas change icons if the change violates our isobaric counter diffusion criterium. Signed-off-by: Robert C. Helling --- icons/Air_changeICD.png | Bin 0 -> 2640 bytes icons/Nx_changeICD.png | Bin 0 -> 2662 bytes icons/Oxy_changeICD.png | Bin 0 -> 2561 bytes icons/Tmx_changeICD.png | Bin 0 -> 2671 bytes icons/gaschangeICD.png | Bin 0 -> 2459 bytes profile-widget/diveeventitem.cpp | 36 +++++++++++++++++++++++++----------- profile-widget/diveeventitem.h | 2 +- subsurface.qrc | 5 +++++ 8 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 icons/Air_changeICD.png create mode 100644 icons/Nx_changeICD.png create mode 100644 icons/Oxy_changeICD.png create mode 100644 icons/Tmx_changeICD.png create mode 100644 icons/gaschangeICD.png diff --git a/icons/Air_changeICD.png b/icons/Air_changeICD.png new file mode 100644 index 000000000..600e296b7 Binary files /dev/null and b/icons/Air_changeICD.png differ diff --git a/icons/Nx_changeICD.png b/icons/Nx_changeICD.png new file mode 100644 index 000000000..b6bb93327 Binary files /dev/null and b/icons/Nx_changeICD.png differ diff --git a/icons/Oxy_changeICD.png b/icons/Oxy_changeICD.png new file mode 100644 index 000000000..8f06272c6 Binary files /dev/null and b/icons/Oxy_changeICD.png differ diff --git a/icons/Tmx_changeICD.png b/icons/Tmx_changeICD.png new file mode 100644 index 000000000..2b17f86a2 Binary files /dev/null and b/icons/Tmx_changeICD.png differ diff --git a/icons/gaschangeICD.png b/icons/gaschangeICD.png new file mode 100644 index 000000000..6174bef58 Binary files /dev/null and b/icons/gaschangeICD.png differ diff --git a/profile-widget/diveeventitem.cpp b/profile-widget/diveeventitem.cpp index 630587375..e904bbefc 100644 --- a/profile-widget/diveeventitem.cpp +++ b/profile-widget/diveeventitem.cpp @@ -56,12 +56,12 @@ void DiveEventItem::setEvent(struct event *ev, struct gasmix *lastgasmix) free(internalEvent); internalEvent = clone_event(ev); - setupPixmap(); + setupPixmap(lastgasmix); setupToolTipString(lastgasmix); recalculatePos(true); } -void DiveEventItem::setupPixmap() +void DiveEventItem::setupPixmap(struct gasmix *lastgasmix) { const IconMetrics& metrics = defaultIconMetrics(); #ifndef SUBSURFACE_MOBILE @@ -86,14 +86,29 @@ void DiveEventItem::setupPixmap() setPixmap(EVENT_PIXMAP(":dive-bookmark-icon")); } else if (event_is_gaschange(internalEvent)) { struct gasmix *mix = get_gasmix_from_event(&displayed_dive, internalEvent); - if (mix->he.permille) - setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-trimix-icon")); - else if (gasmix_is_air(mix)) - setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-air-icon")); - else if (mix->o2.permille == 1000) - setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-oxygen-icon")); - else - setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-ean-icon")); + struct icd_data icd_data; + bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data); + if (mix->he.permille) { + if (icd) + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-trimix-ICD-icon")); + else + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-trimix-icon")); + } else if (gasmix_is_air(mix)) { + if (icd) + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-air-ICD-icon")); + else + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-air-icon")); + } else if (mix->o2.permille == 1000) { + if (icd) + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-oxygen-ICD-icon")); + else + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-oxygen-icon")); + } else { + if (icd) + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-ean-ICD-icon")); + else + setPixmap(EVENT_PIXMAP_BIGGER(":gaschange-ean-icon")); + } #ifdef SAMPLE_FLAGS_SEVERITY_SHIFT } else if ((((internalEvent->flags & SAMPLE_FLAGS_SEVERITY_MASK) >> SAMPLE_FLAGS_SEVERITY_SHIFT) == 1) || // those are useless internals of the dive computer @@ -180,7 +195,6 @@ void DiveEventItem::setupToolTipString(struct gasmix *lastgasmix) name += internalEvent->flags & SAMPLE_FLAGS_BEGIN ? tr(" begin", "Starts with space!") : internalEvent->flags & SAMPLE_FLAGS_END ? tr(" end", "Starts with space!") : ""; } - // qDebug() << name; setToolTip(name); } diff --git a/profile-widget/diveeventitem.h b/profile-widget/diveeventitem.h index 51eead5d0..f56a92898 100644 --- a/profile-widget/diveeventitem.h +++ b/profile-widget/diveeventitem.h @@ -26,7 +26,7 @@ slots: private: void setupToolTipString(struct gasmix *lastgasmix); - void setupPixmap(); + void setupPixmap(struct gasmix *lastgasmix); DiveCartesianAxis *vAxis; DiveCartesianAxis *hAxis; DivePlotDataModel *dataModel; diff --git a/subsurface.qrc b/subsurface.qrc index cad50a400..c5ba1c7a2 100644 --- a/subsurface.qrc +++ b/subsurface.qrc @@ -36,6 +36,11 @@ icons/Nx_change.png icons/Tmx_change.png icons/Oxy_change.png + icons/gaschangeICD.png + icons/Air_changeICD.png + icons/Nx_changeICD.png + icons/Tmx_changeICD.png + icons/Oxy_changeICD.png icons/flag.png icons/scale.png icons/ruler.png -- cgit v1.2.3-70-g09d2