diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-09-19 08:48:19 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-09-19 21:48:05 -0700 |
commit | 15a99f878970ba90d027f3dda0a779ed0eb3faa9 (patch) | |
tree | cf4c4c80b87ef2b8618179098471e55ea49fe426 /qt-ui | |
parent | 3fc9c1e0053a0ca1d4af7c1e5fb8e118afe0badf (diff) | |
download | subsurface-15a99f878970ba90d027f3dda0a779ed0eb3faa9.tar.gz |
Add tissue saturation plot to tooltip
This adds a graphical representation of tissue loadings at the current moment during the dive
to the tooltip box. The layout is inspired by the Sherwater Petrel.Add tissue saturation plot to tooltip
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/profile/divetooltipitem.cpp | 33 | ||||
-rw-r--r-- | qt-ui/profile/divetooltipitem.h | 2 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 4 |
3 files changed, 32 insertions, 7 deletions
diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index 9ee44e4b6..97f687ab0 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -18,9 +18,9 @@ #include "display.h" #endif -void ToolTipItem::addToolTip(const QString &toolTip, const QIcon &icon) +void ToolTipItem::addToolTip(const QString &toolTip, const QIcon &icon, const QPixmap *pixmap) { - QGraphicsPixmapItem *iconItem = 0; + QGraphicsPixmapItem *iconItem = 0, *pixmapItem = 0; double yValue = title->boundingRect().height() + SPACING; Q_FOREACH (ToolTip t, toolTips) { yValue += t.second->boundingRect().height(); @@ -28,6 +28,11 @@ void ToolTipItem::addToolTip(const QString &toolTip, const QIcon &icon) if (!icon.isNull()) { iconItem = new QGraphicsPixmapItem(icon.pixmap(ICON_SMALL, ICON_SMALL), this); iconItem->setPos(SPACING, yValue); + } else { + if (pixmap && !pixmap->isNull()) { + pixmapItem = new QGraphicsPixmapItem(*pixmap, this); + pixmapItem->setPos(SPACING, yValue); + } } QGraphicsSimpleTextItem *textItem = new QGraphicsSimpleTextItem(toolTip, this); @@ -217,6 +222,10 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis) void ToolTipItem::refresh(const QPointF &pos) { + int i; + struct plot_data *entry; + static QPixmap *tissues = new QPixmap(16,60); + static QPainter *painter = new QPainter(tissues); int time = timeAxis->valueAt(pos); if (time == lastTime) return; @@ -225,8 +234,24 @@ void ToolTipItem::refresh(const QPointF &pos) clear(); struct membuffer mb = { 0 }; - get_plot_details_new(&pInfo, time, &mb); - addToolTip(QString::fromUtf8(mb.buffer, mb.len)); + entry = get_plot_details_new(&pInfo, time, &mb); + tissues->fill(); + painter->setPen(QColor(0, 0, 0, 0)); + painter->setBrush(QColor(LIMENADE1)); + painter->drawRect(0, 10 + (100 - AMB_PERCENTAGE) / 2, 16, AMB_PERCENTAGE / 2); + painter->setBrush(QColor(SPRINGWOOD1)); + painter->drawRect(0, 10, 16, (100 - AMB_PERCENTAGE) / 2); + painter->setBrush(QColor("Red")); + painter->drawRect(0,0,16,10); + painter->setPen(QColor(0, 0, 0, 255)); + painter->drawLine(0, 60 - entry->gfline / 2, 16, 60 - entry->gfline / 2); + painter->drawLine(0, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure / 2, + 16, 60 - AMB_PERCENTAGE * (entry->pressures.n2 + entry->pressures.he) / entry->ambpressure /2); + painter->setPen(QColor(0, 0, 0, 127)); + for (i=0; i<16; i++) { + painter->drawLine(i, 60, i, 60 - entry->percentages[i] / 2); + } + addToolTip(QString::fromUtf8(mb.buffer, mb.len),QIcon(), tissues); free_buffer(&mb); Q_FOREACH (QGraphicsItem *item, scene()->items(pos, Qt::IntersectsItemShape diff --git a/qt-ui/profile/divetooltipitem.h b/qt-ui/profile/divetooltipitem.h index c22287b06..e0e65638a 100644 --- a/qt-ui/profile/divetooltipitem.h +++ b/qt-ui/profile/divetooltipitem.h @@ -40,7 +40,7 @@ public: void collapse(); void expand(); void clear(); - void addToolTip(const QString &toolTip, const QIcon &icon = QIcon()); + void addToolTip(const QString &toolTip, const QIcon &icon = QIcon(), const QPixmap *pixmap = NULL); void refresh(const QPointF &pos); bool isExpanded() const; void persistPos(); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 16339c1de..3838e918b 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -360,9 +360,9 @@ void ProfileWidget2::setupItemSizes() itemPos.heartBeat.expanded.setP2(QPointF(0, 15)); itemPos.percentage.pos.on.setX(3); - itemPos.percentage.pos.on.setY(85); // was 80 + itemPos.percentage.pos.on.setY(85); itemPos.percentage.expanded.setP1(QPointF(0, 0)); - itemPos.percentage.expanded.setP2(QPointF(0, 15)); // was 20 + itemPos.percentage.expanded.setP2(QPointF(0, 15)); itemPos.dcLabel.on.setX(3); itemPos.dcLabel.on.setY(100); |