diff options
author | Robert C. Helling <helling@atdotde.de> | 2016-08-28 00:09:22 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-09-17 13:39:54 -0700 |
commit | 893bea700c982daacb0af2feec4b2ac98c96424f (patch) | |
tree | db4e73ae6e7ff121b960b7436e6dbc83a39b7015 /profile-widget | |
parent | 6f43c16ea9cc2c0323c5ac78059cf3a118c9a528 (diff) | |
download | subsurface-893bea700c982daacb0af2feec4b2ac98c96424f.tar.gz |
Introduce heat map
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 tissue determines the y
position.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/diveprofileitem.cpp | 36 | ||||
-rw-r--r-- | profile-widget/diveprofileitem.h | 1 | ||||
-rw-r--r-- | 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 6eb678b3b..ce811f930 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 0c3f9a610..05c7eb7d6 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 aae8fdd3b..58cebf633 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); |