Hi,

finally, here are the two patches I prepared in recent holiday days in southern 
France without wifi access. I will send them as soon as my laptop sees the 
internet again.

From 25ca4a02c7b17e2ba6fa849db81da8b1e67baca1 Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Sun, 28 Aug 2016 00:09:22 +0200
Subject: [PATCH 1/2] Introduce heat map
To: [email protected]

This replaces the tissue percentage graph that probably nobody ever
understood with a heat map like the one used in the discussion
of bubble model deco. The information shown is the same but the
saturation is now in the color while the dissue determines the y
position.

Signed-off-by: Robert C. Helling <[email protected]>
---
 profile-widget/diveprofileitem.cpp | 36 +++++++++++++++++++++++-------------
 profile-widget/diveprofileitem.h   |  1 +
 profile-widget/profilewidget2.cpp  |  3 ---
 3 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/profile-widget/diveprofileitem.cpp 
b/profile-widget/diveprofileitem.cpp
index 6eb678b..ce811f9 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -359,13 +359,7 @@ void DiveHeartrateItem::paint(QPainter *painter, const 
QStyleOptionGraphicsItem
 
 DivePercentageItem::DivePercentageItem(int i)
 {
-       QPen pen;
-       QColor color;
-       color.setHsl(100 + 10 * i, 200, 100);
-       pen.setBrush(QBrush(color));
-       pen.setCosmetic(true);
-       pen.setWidth(1);
-       setPen(pen);
+       tissueIndex = i;
        settingsChanged();
 }
 
@@ -380,11 +374,8 @@ void DivePercentageItem::modelDataChanged(const 
QModelIndex &topLeft, const QMod
        // Ignore empty values. a heartrate of 0 would be a bad sign.
        QPolygonF poly;
        for (int i = 0, modelDataCount = dataModel->rowCount(); i < 
modelDataCount; i++) {
-               int hr = dataModel->index(i, vDataColumn).data().toInt();
-               if (!hr)
-                       continue;
                sec = dataModel->index(i, hDataColumn).data().toInt();
-               QPointF point(hAxis->posAtValue(sec), vAxis->posAtValue(hr));
+               QPointF point(hAxis->posAtValue(sec), vAxis->posAtValue(64 - 4 
* tissueIndex));
                poly.append(point);
        }
        setPolygon(poly);
@@ -401,8 +392,27 @@ void DivePercentageItem::paint(QPainter *painter, const 
QStyleOptionGraphicsItem
        if (polygon().isEmpty())
                return;
        painter->save();
-       painter->setPen(pen());
-       painter->drawPolyline(polygon());
+       QColor color;
+       QPen mypen;
+       mypen.setCosmetic(true);
+       mypen.setWidth(5);
+       QPolygonF poly = polygon();
+       for (int i = 0, modelDataCount = dataModel->rowCount(); i < 
modelDataCount; i++) {
+               if (i < poly.count()) {
+                       double value = dataModel->index(i, 
vDataColumn).data().toDouble();
+                       if (value < 50.0) {
+                               value *= 255.0 / 50.0;
+                               color.setRgb(rint(value), 255 - rint(value),0);
+                       } else {
+                               value = (value - 50.0) * 255.0 / 50.0;
+                               color.setRgb(255 - rint(value), 0 , 
rint(value));
+                       }
+
+                       mypen.setBrush(QBrush(color));
+                       painter->setPen(mypen);
+                       painter->drawPoint(poly[i]);
+               }
+       }
        painter->restore();
        connect(SettingsObjectWrapper::instance()->techDetails, 
&TechnicalDetailsSettings::percentageGraphChanged, this, 
&DivePercentageItem::setVisible);
 }
diff --git a/profile-widget/diveprofileitem.h b/profile-widget/diveprofileitem.h
index 0c3f9a6..05c7eb7 100644
--- a/profile-widget/diveprofileitem.h
+++ b/profile-widget/diveprofileitem.h
@@ -132,6 +132,7 @@ public:
 
 private:
        QString visibilityKey;
+       int tissueIndex;
 };
 
 class DiveAmbPressureItem : public AbstractProfilePolygonItem {
diff --git a/profile-widget/profilewidget2.cpp 
b/profile-widget/profilewidget2.cpp
index aae8fdd..58cebf6 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1159,9 +1159,6 @@ void ProfileWidget2::setProfileState()
                Q_FOREACH (DivePercentageItem *percentage, allPercentages) {
                        percentage->setVisible(true);
                }
-
-               ambPressureItem->setVisible(true);
-               gflineItem->setVisible(true);
        }
 
        rulerItem->setVisible(prefs.rulergraph);
-- 
2.7.4 (Apple Git-66)

From 6688426a08151c121cee18e6f37eecf17079503c Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Tue, 30 Aug 2016 11:33:16 +0200
Subject: [PATCH 2/2] Cosmetic changes to Buehlmann code
To: [email protected]

Change runtime table string from ZHL-16B to ZHL-16C to reflect he fact
that we use 5min as half-time for the festest compartment rahter than
4min.

Further more trade pow(2.0, ...) for exp().

Signed-off-by: Robert C. Helling <[email protected]>
---
 core/deco.c    | 7 +++++--
 core/planner.c | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/core/deco.c b/core/deco.c
index af3e061..b86376c 100644
--- a/core/deco.c
+++ b/core/deco.c
@@ -91,6 +91,7 @@ const double buehlmann_N2_t_halflife[] = { 5.0, 8.0, 12.5, 
18.5,
                                           109.0, 146.0, 187.0, 239.0,
                                           305.0, 390.0, 498.0, 635.0 };
 
+// 1 - exp(-1 / (halflife * 60) * ln(2))
 const double buehlmann_N2_factor_expositon_one_second[] = {
        2.30782347297664E-003, 1.44301447809736E-003, 9.23769302935806E-004, 
6.24261986779007E-004,
        4.27777107246730E-004, 3.01585140931371E-004, 2.12729727268379E-004, 
1.50020603047807E-004,
@@ -329,7 +330,8 @@ double n2_factor(int period_in_seconds, int ci)
 
        if (period_in_seconds != cache[ci].last_period) {
                cache[ci].last_period = period_in_seconds;
-               cache[ci].last_factor = 1 - pow(2.0, -period_in_seconds / 
(buehlmann_N2_t_halflife[ci] * 60));
+               // ln(2)/60 = 1.155245301e-02
+               cache[ci].last_factor = 1 - exp(-period_in_seconds * 
1.155245301e-02 / buehlmann_N2_t_halflife[ci]);
        }
 
        return cache[ci].last_factor;
@@ -344,7 +346,8 @@ double he_factor(int period_in_seconds, int ci)
 
        if (period_in_seconds != cache[ci].last_period) {
                cache[ci].last_period = period_in_seconds;
-               cache[ci].last_factor = 1 - pow(2.0, -period_in_seconds / 
(buehlmann_He_t_halflife[ci] * 60));
+               // ln(2)/60 = 1.155245301e-02
+               cache[ci].last_factor = 1 - exp(-period_in_seconds * 
1.155245301e-02 / buehlmann_He_t_halflife[ci]);
        }
 
        return cache[ci].last_factor;
diff --git a/core/planner.c b/core/planner.c
index 8a2e1d6..49a27e5 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -560,7 +560,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, 
struct dive *dive, bool
 
        len = show_disclaimer ? snprintf(buffer, sz_buffer, 
"<div><b>%s<b></div><br>", disclaimer) : 0;
        if (prefs.deco_mode == BUEHLMANN){
-               snprintf(temp, sz_temp, translate("gettextFromC", "based on 
Bühlmann ZHL-16B with GFlow = %d and GFhigh = %d"),
+               snprintf(temp, sz_temp, translate("gettextFromC", "based on 
Bühlmann ZHL-16C with GFlow = %d and GFhigh = %d"),
                        diveplan->gflow, diveplan->gfhigh);
        } else if (prefs.deco_mode == VPMB){
                if (prefs.conservatism_level == 0)
-- 
2.7.4 (Apple Git-66)


The first changes the saturation plot (that I bet none of our users understood) 
and displays the same information in terms of a heat map (i.e. before tissue 
number was color while saturation was y-value, now the two are exchanged. This 
is like in the video that Anton shared a while ago on IRC.

The second patch just changes a string according to a recent comment on the 
forum.

Best
Robert

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to