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/profile/divetooltipitem.cpp | |
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/profile/divetooltipitem.cpp')
-rw-r--r-- | qt-ui/profile/divetooltipitem.cpp | 33 |
1 files changed, 29 insertions, 4 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 |