aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2014-01-21 14:14:52 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-01-21 11:35:04 -0800
commitb1df7aeb4e06cfc512d19b2f7e7f5b455dea0c22 (patch)
tree97d6930934db5a094117006628a06af6613e279a
parent9d33640bea9332ca5afb3df71f7a12da9c29e080 (diff)
downloadsubsurface-b1df7aeb4e06cfc512d19b2f7e7f5b455dea0c22.tar.gz
Plot gas value function ported to the new canvas.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/diveprofileitem.cpp20
-rw-r--r--qt-ui/profile/diveprofileitem.h1
2 files changed, 17 insertions, 4 deletions
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, QFlags<Qt::Alig
{
const char *unit;
int pressure = get_pressure_units(mbar, &unit);
- //static text_render_options_t tro = {PRESSURE_TEXT_SIZE, PRESSURE_TEXT, xalign, yalign};
DiveTextItem *text = new DiveTextItem(this);
text->setPos(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<Qt::Alig
texts.push_back(text);
}
+void DiveGasPressureItem::plot_gas_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> 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<Qt::AlignmentFlag> align);
+ void plot_gas_value(int mbar, int sec, QFlags<Qt::AlignmentFlag> align, int o2, int he);
QVector<QPolygonF> polygons;
};