From fd46167ae02db9976c45f76d71b752ee5fa3ed31 Mon Sep 17 00:00:00 2001 From: Rick Walsh Date: Tue, 18 Oct 2016 08:05:32 +1100 Subject: Heatmap: Color undersaturated values relative to inert gas pressure Color "undersaturated" values relative to inert gas pressure of gas being breathed, rather than relative to inert gas pressure of air. Also change slightly the point at which bright green (hue = 120 deg) from 10% of M value to 0% of M value (=ambient pressure). Other than the slight shift in lower bound of the green-red scale, this does not affect the colors of the tissues with inert gas pressure greater than ambient pressure, which are relative to the Buhlmann M value. Signed-off-by: Rick Walsh Signed-off-by: Dirk Hohndel --- profile-widget/diveprofileitem.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'profile-widget/diveprofileitem.cpp') diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index 896174185..2b7e4e396 100644 --- a/profile-widget/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -385,19 +385,18 @@ void DivePercentageItem::modelDataChanged(const QModelIndex &topLeft, const QMod texts.last()->setAlignment(Qt::AlignLeft | Qt::AlignBottom); } -QColor DivePercentageItem::ColorScale(double value) +QColor DivePercentageItem::ColorScale(double value, int inert) { QColor color; - double scaledValue = value / (AMB_PERCENTAGE * N2_IN_AIR) * 1000.0; - + double scaledValue = value / (AMB_PERCENTAGE * inert) * 1000.0; if (scaledValue < 0.8) // grade from cyan to blue to purple color.setHsvF(0.5 + 0.25 * scaledValue / 0.8, 1.0, 1.0); else if (scaledValue < 1.0) // grade from magenta to black color.setHsvF(0.75, 1.0, (1.0 - scaledValue) / 0.2); - else if (value < 55) // grade from black to green - color.setHsvF(0.333, 1.0, (value - AMB_PERCENTAGE * N2_IN_AIR / 1000.0) / (55.0 - AMB_PERCENTAGE * N2_IN_AIR / 1000.0)); + else if (value < AMB_PERCENTAGE) // grade from black to green + color.setHsvF(0.333, 1.0, (value - AMB_PERCENTAGE * inert / 1000.0) / (AMB_PERCENTAGE - AMB_PERCENTAGE * inert / 1000.0)); else if (value < 100) // grade from green to yellow to red - color.setHsvF(0.333 * (100.0 - value) / 45.0, 1.0, 1.0); + color.setHsvF(0.333 * (100.0 - value) / (100.0 - AMB_PERCENTAGE), 1.0, 1.0); else if (value < 120) // M value exceeded - grade from red to white color.setHsvF(0.0, 1 - (value - 100.0) / 20.0, 1.0); else // white @@ -421,7 +420,9 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem for (int i = 1, modelDataCount = dataModel->rowCount(); i < modelDataCount; i++) { if (i < poly.count()) { double value = dataModel->index(i, vDataColumn).data().toDouble(); - mypen.setBrush(QBrush(ColorScale(value))); + int cyl = dataModel->index(i, DivePlotDataModel::CYLINDERINDEX).data().toInt(); + int inert = 1000 - get_o2(&displayed_dive.cylinder[cyl].gasmix); + mypen.setBrush(QBrush(ColorScale(value, inert))); painter->setPen(mypen); painter->drawLine(poly[i - 1], poly[i]); } -- cgit v1.2.3-70-g09d2