From b1df7aeb4e06cfc512d19b2f7e7f5b455dea0c22 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Tue, 21 Jan 2014 14:14:52 -0200 Subject: Plot gas value function ported to the new canvas. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/diveprofileitem.cpp | 20 ++++++++++++++++---- qt-ui/profile/diveprofileitem.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'qt-ui/profile') diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 031acf816..7c339eba9 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -263,9 +263,9 @@ void DiveGasPressureItem::modelDataChanged() cyl = entry->cylinderindex; if (!seen_cyl[cyl]) { plot_pressure_value(mbar, entry->sec, Qt::AlignLeft | Qt::AlignBottom); -// plot_gas_value(mbar, entry->sec, LEFT, TOP, -// get_o2(&dive->cylinder[cyl].gasmix), -// get_he(&dive->cylinder[cyl].gasmix)); + plot_gas_value(mbar, entry->sec, Qt::AlignLeft | Qt::AlignTop, + get_o2(&dive->cylinder[cyl].gasmix), + get_he(&dive->cylinder[cyl].gasmix)); seen_cyl[cyl] = true; } } @@ -284,7 +284,6 @@ void DiveGasPressureItem::plot_pressure_value(int mbar, int sec, QFlagssetPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar)); text->setText(QString("%1 %2").arg(pressure).arg(unit)); @@ -293,6 +292,19 @@ void DiveGasPressureItem::plot_pressure_value(int mbar, int sec, QFlags flags, int o2, int he) +{ + QString gas = (is_air(o2, he)) ? tr("air") : + (he == 0) ? QString(tr("EAN%1")).arg((o2 + 5) / 10) : + QString("%1/%2").arg((o2 + 5) / 10).arg((he + 5) / 10); + DiveTextItem *text = new DiveTextItem(this); + text->setPos(hAxis->posAtValue(sec), vAxis->posAtValue(mbar)); + text->setText(gas); + text->setAlignment(flags); + text->setBrush(getColor(PRESSURE_TEXT)); + texts.push_back(text); +} + void DiveGasPressureItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { QPen pen; diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h index bd1170f39..1aa1af9ad 100644 --- a/qt-ui/profile/diveprofileitem.h +++ b/qt-ui/profile/diveprofileitem.h @@ -76,6 +76,7 @@ public: virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0); private: void plot_pressure_value(int mbar, int sec, QFlags align); + void plot_gas_value(int mbar, int sec, QFlags align, int o2, int he); QVector polygons; }; -- cgit v1.2.3-70-g09d2