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>
This commit is contained in:
Robert C. Helling 2014-09-19 08:48:19 +02:00 committed by Dirk Hohndel
parent 3fc9c1e005
commit 15a99f8789
5 changed files with 35 additions and 9 deletions

View file

@ -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