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

@ -1053,7 +1053,7 @@ static void plot_string(struct plot_info *pi, struct plot_data *entry, struct me
strip_mb(b);
}
void get_plot_details_new(struct plot_info *pi, int time, struct membuffer *mb)
struct plot_data *get_plot_details_new(struct plot_info *pi, int time, struct membuffer *mb)
{
struct plot_data *entry = NULL;
int i;
@ -1065,6 +1065,7 @@ void get_plot_details_new(struct plot_info *pi, int time, struct membuffer *mb)
}
if (entry)
plot_string(pi, entry, mb, pi->has_ndl);
return (entry);
}
/* Compare two plot_data entries and writes the results into a string */

View file

@ -71,7 +71,7 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *
struct plot_info *analyze_plot_info(struct plot_info *pi);
void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi);
void calculate_deco_information(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool print_mode);
void get_plot_details_new(struct plot_info *pi, int time, struct membuffer *);
struct plot_data *get_plot_details_new(struct plot_info *pi, int time, struct membuffer *);
/*
* When showing dive profiles, we scale things to the

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

View file

@ -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();

View file

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