diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2013-05-09 15:42:38 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-09 17:50:06 -0700 |
commit | e62eb58ab5004fdeaee56b986d7f9b4c3f23619a (patch) | |
tree | dc5d62106949f93b28aa3a4af22b7ddd60c8eba3 /qt-ui/profilegraphics.cpp | |
parent | d6d1a10195e1d14bafb5987d5f7b8e776a82b4be (diff) | |
download | subsurface-e62eb58ab5004fdeaee56b986d7f9b4c3f23619a.tar.gz |
Plotting cylinder pressure text.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r-- | qt-ui/profilegraphics.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index 158cec286..787182389 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -248,8 +248,8 @@ void ProfileGraphicsView::plot(struct dive *dive) plot_depth_text(); + plot_cylinder_pressure_text(); #if 0 - plot_cylinder_pressure_text(gc, pi); plot_deco_text(gc, pi); #endif /* Bounding box */ @@ -292,6 +292,54 @@ void ProfileGraphicsView::plot(struct dive *dive) #endif } +void ProfileGraphicsView::plot_cylinder_pressure_text() +{ + int i; + int mbar, cyl; + int seen_cyl[MAX_CYLINDERS] = { FALSE, }; + int last_pressure[MAX_CYLINDERS] = { 0, }; + int last_time[MAX_CYLINDERS] = { 0, }; + struct plot_data *entry; + struct plot_info *pi = &gc.pi; + + if (!get_cylinder_pressure_range(&gc)) + return; + + cyl = -1; + for (i = 0; i < pi->nr; i++) { + entry = pi->entry + i; + mbar = GET_PRESSURE(entry); + + if (!mbar) + continue; + if (cyl != entry->cylinderindex) { + cyl = entry->cylinderindex; + if (!seen_cyl[cyl]) { + plot_pressure_value(mbar, entry->sec, LEFT, BOTTOM); + seen_cyl[cyl] = TRUE; + } + } + last_pressure[cyl] = mbar; + last_time[cyl] = entry->sec; + } + + for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { + if (last_time[cyl]) { + plot_pressure_value(last_pressure[cyl], last_time[cyl], CENTER, TOP); + } + } +} + +void ProfileGraphicsView::plot_pressure_value(int mbar, int sec, int xalign, int yalign) +{ + int pressure; + const char *unit; + + pressure = get_pressure_units(mbar, &unit); + static text_render_options_t tro = {PRESSURE_TEXT_SIZE, PRESSURE_TEXT, xalign, yalign}; + plot_text(&tro, sec, mbar, QString("%1 %2").arg(pressure).arg(unit)); +} + void ProfileGraphicsView::plot_depth_text() { int maxtime, maxdepth; |