From 25ca4a02c7b17e2ba6fa849db81da8b1e67baca1 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sun, 28 Aug 2016 00:09:22 +0200 Subject: [PATCH 1/2] Introduce heat map To: subsurface@subsurface-divelog.org 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 --- 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)