summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Willem Ferguson <willemferguson@zoology.up.ac.za>2015-01-05 09:20:26 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-05 09:18:06 -0800
commit0de3bc84523778ad74a305a5f9e85645c90e02cf (patch)
treefcef310e491b9bb8de14c88ca756c21eaaccf25c
parent27bfbee4e8c3644dedea61f67338dcb2b83ffbed (diff)
downloadsubsurface-0de3bc84523778ad74a305a5f9e85645c90e02cf.tar.gz
Display CCR setpoint values on the po2 graph
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. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--pref.h1
-rw-r--r--profile.c3
-rw-r--r--profile.h1
-rw-r--r--qt-ui/graphicsview-common.cpp1
-rw-r--r--qt-ui/graphicsview-common.h1
-rw-r--r--qt-ui/preferences.cpp3
-rw-r--r--qt-ui/preferences.ui7
-rw-r--r--qt-ui/profile/diveplotdatamodel.cpp4
-rw-r--r--qt-ui/profile/diveplotdatamodel.h1
-rw-r--r--qt-ui/profile/profilewidget2.cpp11
-rw-r--r--qt-ui/profile/profilewidget2.h1
-rw-r--r--subsurfacestartup.c1
12 files changed, 33 insertions, 2 deletions
diff --git a/pref.h b/pref.h
index f43c32084..49e1afaab 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 e2913b3c0..a09268bf1 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 */
@@ -609,7 +608,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 5c30ca4de..0ae9a8f84 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 4beab9d3a..4402a23bf 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 c223c30c7..294109d34 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 871faeace..2f87147b1 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 bdc41d1cf..b716efa73 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 c73d7918e..e60dd9ddb 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:
@@ -127,6 +129,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");
case HEARTBEAT:
diff --git a/qt-ui/profile/diveplotdatamodel.h b/qt-ui/profile/diveplotdatamodel.h
index 91e6a8b30..6fdb5fcdd 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 f9aa49eff..f986a2c30 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()),
@@ -162,6 +163,7 @@ ProfileWidget2::~ProfileWidget2()
delete pn2GasItem;
delete pheGasItem;
delete po2GasItem;
+ delete o2SetpointGasItem;
delete heartBeatAxis;
delete heartBeatItem;
delete percentageAxis;
@@ -201,6 +203,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);
@@ -313,6 +316,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);
@@ -527,6 +531,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... )
@@ -883,6 +892,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);
@@ -981,6 +991,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 2de60ccbd..ffeecb3ee 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -174,6 +174,7 @@ private:
PartialPressureGasItem *pn2GasItem;
PartialPressureGasItem *pheGasItem;
PartialPressureGasItem *po2GasItem;
+ PartialPressureGasItem *o2SetpointGasItem;
DiveCartesianAxis *heartBeatAxis;
DiveHeartrateItem *heartBeatItem;
DiveCartesianAxis *percentageAxis;
diff --git a/subsurfacestartup.c b/subsurfacestartup.c
index 95578918c..1e3a2c1b4 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 = false,
.font_size = -1,
.display_invalid_dives = false,
.show_sac = false,