Subject: [PATCH] Display CCR setpoint values on the po2 graph (V2)
This is version 2 of this patch. When a CCR dive is viewed and the toolbar button for PO2 is activated, both the PO2 (green line) and the O2 setpoint (red line) are shown. This allows evaluation of the PO2 in the CCR loop with respect to the pre-configured O2 setpoint. The setpoint graph can be disabled from the Preferences/Graphs tab by checking the appropriate checkbox. By default the box is checked. Most of Dirk's comments on the first version of this patch are addressed here. Signed-off-by: willem ferguson <[email protected]> The problem of crazy uninitialised setpoint values for Poseidon dive logs is corrected by Miika in a separate patch. The graphics code needs careful check by someone familiar with Qt, please!
>From 4063ff14819b6d61c859319fbb4f01426e7b7a1a Mon Sep 17 00:00:00 2001 From: willem ferguson <[email protected]> Date: Mon, 5 Jan 2015 07:57:14 +0200 Subject: [PATCH] Display CCR setpoint values on the po2 graph (V2) This is version 2 of this patch. When a CCR dive is viewed and the toolbar button for PO2 is activated, both the PO2 (green line) and the O2 setpoint (red line) are shown. This allows evaluation of the PO2 in the CCR loop with respect to the pre-configured O2 setpoint. The setpoint graph can be disabled from the Preferences/Graphs tab by checking the appropriate checkbox. By default the box is checked. Most of Dirk's comments on the first version of this patch are addressed here. Signed-off-by: willem ferguson <[email protected]> --- pref.h | 1 + profile.c | 3 +-- profile.h | 1 + qt-ui/graphicsview-common.cpp | 1 + qt-ui/graphicsview-common.h | 1 + qt-ui/preferences.cpp | 3 +++ qt-ui/preferences.ui | 7 +++++++ qt-ui/profile/diveplotdatamodel.cpp | 4 ++++ qt-ui/profile/diveplotdatamodel.h | 1 + qt-ui/profile/profilewidget2.cpp | 11 +++++++++++ qt-ui/profile/profilewidget2.h | 1 + subsurface.pro | 2 +- subsurfacestartup.c | 1 + 13 files changed, 34 insertions(+), 3 deletions(-) diff --git a/pref.h b/pref.h index f43c320..49e1afa 100644 --- a/pref.h +++ b/pref.h @@ -43,6 +43,7 @@ struct preferences { short gfhigh; int animation_speed; bool gf_low_at_maxdepth; + bool show_ccr_setpoint; short display_invalid_dives; short unit_system; struct units units; diff --git a/profile.c b/profile.c index 74d4936..54ee84e 100644 --- a/profile.c +++ b/profile.c @@ -17,7 +17,6 @@ #include "libdivecomputer/version.h" #include "membuffer.h" - //#define DEBUG_GAS 1 int selected_dive = -1; /* careful: 0 is a valid value */ @@ -608,7 +607,7 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer * entry->in_deco = sample->in_deco; entry->cns = sample->cns; if (dc->dctype == CCR) { - entry->o2pressure.mbar = sample->setpoint.mbar; // for rebreathers + entry->o2pressure.mbar = entry->o2setpoint.mbar = sample->setpoint.mbar; // for rebreathers entry->o2sensor[0].mbar = sample->o2sensor[0].mbar; // for up to three rebreather O2 sensors entry->o2sensor[1].mbar = sample->o2sensor[1].mbar; entry->o2sensor[2].mbar = sample->o2sensor[2].mbar; diff --git a/profile.h b/profile.h index 5c30ca4..0ae9a8f 100644 --- a/profile.h +++ b/profile.h @@ -43,6 +43,7 @@ struct plot_data { struct gas_pressures pressures; pressure_t o2pressure; // for rebreathers, this is consensus measured po2, or setpoint otherwise. 0 for OC. pressure_t o2sensor[3]; //for rebreathers with up to 3 PO2 sensors + pressure_t o2setpoint; double mod, ead, end, eadd; velocity_t velocity; int speed; diff --git a/qt-ui/graphicsview-common.cpp b/qt-ui/graphicsview-common.cpp index 4beab9d..4402a23 100644 --- a/qt-ui/graphicsview-common.cpp +++ b/qt-ui/graphicsview-common.cpp @@ -27,6 +27,7 @@ void fill_profile_color() profile_color[PN2_ALERT] = COLOR(RED1, BLACK1_LOW_TRANS, RED1); profile_color[PHE] = COLOR(PEANUT, BLACK1_LOW_TRANS, PEANUT); profile_color[PHE_ALERT] = COLOR(RED1, BLACK1_LOW_TRANS, RED1); + profile_color[O2SETPOINT] = COLOR(RED1, BLACK1_LOW_TRANS, RED1); profile_color[PP_LINES] = COLOR(BLACK1_HIGH_TRANS, BLACK1_LOW_TRANS, BLACK1_HIGH_TRANS); profile_color[TEXT_BACKGROUND] = COLOR(CONCRETE1_LOWER_TRANS, WHITE1, CONCRETE1_LOWER_TRANS); diff --git a/qt-ui/graphicsview-common.h b/qt-ui/graphicsview-common.h index c223c30..294109d 100644 --- a/qt-ui/graphicsview-common.h +++ b/qt-ui/graphicsview-common.h @@ -37,6 +37,7 @@ typedef enum { PN2_ALERT, PHE, PHE_ALERT, + O2SETPOINT, PP_LINES, /* Other colors */ diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 871faea..2f87147 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -100,6 +100,7 @@ void PreferencesDialog::setUiFromPrefs() ui.gflow->setValue(prefs.gflow); ui.gfhigh->setValue(prefs.gfhigh); ui.gf_low_at_maxdepth->setChecked(prefs.gf_low_at_maxdepth); + ui.show_ccr_setpoint->setChecked(prefs.show_ccr_setpoint); // units if (prefs.unit_system == METRIC) @@ -251,6 +252,7 @@ void PreferencesDialog::syncSettings() SAVE_OR_REMOVE("gflow", default_prefs.gflow, ui.gflow->value()); SAVE_OR_REMOVE("gfhigh", default_prefs.gfhigh, ui.gfhigh->value()); SAVE_OR_REMOVE("gf_low_at_maxdepth", default_prefs.gf_low_at_maxdepth, ui.gf_low_at_maxdepth->isChecked()); + SAVE_OR_REMOVE("show_ccr_setpoint", default_prefs.show_ccr_setpoint, ui.show_ccr_setpoint->isChecked()); SAVE_OR_REMOVE("display_unused_tanks", default_prefs.display_unused_tanks, ui.display_unused_tanks->isChecked()); SAVE_OR_REMOVE("show_average_depth", default_prefs.show_average_depth, ui.show_average_depth->isChecked()); s.endGroup(); @@ -364,6 +366,7 @@ void PreferencesDialog::loadSettings() GET_INT("gflow", gflow); GET_INT("gfhigh", gfhigh); GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth); + GET_BOOL("show_ccr_setpoint",show_ccr_setpoint); GET_BOOL("zoomed_plot", zoomed_plot); set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth); GET_BOOL("show_sac", show_sac); diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui index 5e0778a..cf1b91f 100644 --- a/qt-ui/preferences.ui +++ b/qt-ui/preferences.ui @@ -789,6 +789,13 @@ </property> </widget> </item> + <item row="3" column="0" colspan="2"> + <widget class="QCheckBox" name="show_ccr_setpoint"> + <property name="text"> + <string>CCR: Show setpoints when viewing pOâ</string> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/qt-ui/profile/diveplotdatamodel.cpp b/qt-ui/profile/diveplotdatamodel.cpp index 51aea1b..f8550c2 100644 --- a/qt-ui/profile/diveplotdatamodel.cpp +++ b/qt-ui/profile/diveplotdatamodel.cpp @@ -52,6 +52,8 @@ QVariant DivePlotDataModel::data(const QModelIndex &index, int role) const return item.pressures.he; case PO2: return item.pressures.o2; + case O2SETPOINT: + return item.o2setpoint.mbar / 1000.0; case HEARTBEAT: return item.heartbeat; case AMBPRESSURE: @@ -125,6 +127,8 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation, return tr("pHe"); case PO2: return tr("pOâ"); + case O2SETPOINT: + return tr("Setpoint"); case AMBPRESSURE: return tr("Ambient pressure"); } diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h index 416ae69..e178972 100644 --- a/qt-ui/profile/diveplotdatamodel.h +++ b/qt-ui/profile/diveplotdatamodel.h @@ -59,6 +59,7 @@ public: PN2, PHE, PO2, + O2SETPOINT, HEARTBEAT, AMBPRESSURE, GFLINE, diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index d631e3c..5bb8b38 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -93,6 +93,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), pn2GasItem(new PartialPressureGasItem()), pheGasItem(new PartialPressureGasItem()), po2GasItem(new PartialPressureGasItem()), + o2SetpointGasItem(new PartialPressureGasItem()), heartBeatAxis(new DiveCartesianAxis()), heartBeatItem(new DiveHeartrateItem()), percentageAxis(new DiveCartesianAxis()), @@ -161,6 +162,7 @@ ProfileWidget2::~ProfileWidget2() delete pn2GasItem; delete pheGasItem; delete po2GasItem; + delete o2SetpointGasItem; delete heartBeatAxis; delete heartBeatItem; delete percentageAxis; @@ -199,6 +201,7 @@ void ProfileWidget2::addItemsToScene() scene()->addItem(pn2GasItem); scene()->addItem(pheGasItem); scene()->addItem(po2GasItem); + scene()->addItem(o2SetpointGasItem); scene()->addItem(percentageAxis); scene()->addItem(heartBeatAxis); scene()->addItem(heartBeatItem); @@ -307,6 +310,7 @@ void ProfileWidget2::setupItemOnScene() CREATE_PP_GAS(pn2GasItem, PN2, PN2, PN2_ALERT, &prefs.pp_graphs.pn2_threshold, "pn2graph"); CREATE_PP_GAS(pheGasItem, PHE, PHE, PHE_ALERT, &prefs.pp_graphs.phe_threshold, "phegraph"); CREATE_PP_GAS(po2GasItem, PO2, PO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold, "po2graph"); + CREATE_PP_GAS(o2SetpointGasItem, O2SETPOINT, PO2_ALERT, PO2_ALERT, &prefs.pp_graphs.po2_threshold, "po2graph"); #undef CREATE_PP_GAS temperatureAxis->setTextVisible(false); @@ -521,6 +525,11 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) currentdc = fake_dc(currentdc); } + if ((current_dc->dctype == CCR) && (prefs.show_ccr_setpoint)) + o2SetpointGasItem->setVisible(true); + else + o2SetpointGasItem->setVisible(false); + /* This struct holds all the data that's about to be plotted. * I'm not sure this is the best approach ( but since we are * interpolating some points of the Dive, maybe it is... ) @@ -879,6 +888,7 @@ void ProfileWidget2::setEmptyState() tankItem->setVisible(false); pn2GasItem->setVisible(false); po2GasItem->setVisible(false); + o2SetpointGasItem->setVisible(false); pheGasItem->setVisible(false); ambPressureItem->setVisible(false); gflineItem->setVisible(false); @@ -977,6 +987,7 @@ void ProfileWidget2::setProfileState() } pn2GasItem->setVisible(prefs.pp_graphs.pn2); po2GasItem->setVisible(prefs.pp_graphs.po2); + o2SetpointGasItem->setVisible(true); pheGasItem->setVisible(prefs.pp_graphs.phe); timeAxis->setPos(itemPos.time.pos.on); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 5a612d9..3dfc503 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -169,6 +169,7 @@ private: PartialPressureGasItem *pn2GasItem; PartialPressureGasItem *pheGasItem; PartialPressureGasItem *po2GasItem; + PartialPressureGasItem *o2SetpointGasItem; DiveCartesianAxis *heartBeatAxis; DiveHeartrateItem *heartBeatItem; DiveCartesianAxis *percentageAxis; diff --git a/subsurface.pro b/subsurface.pro index ec8b0fd..aefe354 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -105,7 +105,7 @@ HEADERS = \ qt-ui/statistics/yearstatistics.h \ qt-ui/diveshareexportdialog.h \ qt-ui/filtermodels.h \ - qt-ui/socialnetworks.h + qt-ui/socialnetworks.h android: HEADERS -= \ qt-ui/usermanual.h \ diff --git a/subsurfacestartup.c b/subsurfacestartup.c index 48e2581..6603246 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -29,6 +29,7 @@ struct preferences default_prefs = { .gfhigh = 75, .animation_speed = 500, .gf_low_at_maxdepth = false, + .show_ccr_setpoint = true, .font_size = -1, .display_invalid_dives = false, .show_sac = false, -- 1.9.1
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
