aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2016-09-13 13:52:04 +1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-09-17 13:42:08 -0700
commitddc7f3dc98c8ed2226fc57b8876f2d4d43a14294 (patch)
treeb144495c64f834aa0de3f0b0355ca70a366394cf
parentcd99bbe727e31222a0cfb127f0b5acc7464b9800 (diff)
downloadsubsurface-ddc7f3dc98c8ed2226fc57b8876f2d4d43a14294.tar.gz
Adjust heat map colour scale
Make the heat map use a colour scale similar to that by Kevin Watt, as used in Simon Mitchell's presentation, Decompression Controversies https://www.youtube.com/watch?v=UY61E49lyos&t=2090&authuser=0 Undersaturated: cyan -> blue ->purple -> black Supersaturated up to M value: black -> yellow -> red Exceeding M value: red -> white Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--profile-widget/diveprofileitem.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index ce811f930..1543b3617 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -400,13 +400,18 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
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));
- }
+ if (value < 0.8 * AMB_PERCENTAGE * N2_IN_AIR / 1000.0) // grade from cyan to blue to purple
+ color.setHsvF(0.5 + 0.25 * value / (0.8 * AMB_PERCENTAGE * N2_IN_AIR / 1000.0), 1.0, 1.0);
+ else if (value < AMB_PERCENTAGE * N2_IN_AIR / 1000.0) // grade from magenta to black
+ color.setHsvF(0.75, 1.0, (AMB_PERCENTAGE * N2_IN_AIR / 1000.0 - value) / (0.2 * AMB_PERCENTAGE * N2_IN_AIR / 1000.0));
+ 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 < 100) // grade from green to yellow to red
+ color.setHsvF(0.333 * (100.0 - value) / 45.0, 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
+ color.setHsvF(0.0, 0.0, 1.0);
mypen.setBrush(QBrush(color));
painter->setPen(mypen);