mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
CCR option: display o2 sensor data
This patch creates the possibility of viewing the individual sensor values when the po2 button on the profile toolbar is activated. This follows exactly the procedure for optionally displaying the setpoint values while viewing po2. A checkbox in the preferences panel determines whether sensor information is shown. By default it is set to OFF. When checked, and the po2 button is activated, sensor1 values are shown in grey, sensor2 in blue and sensor3 in brown. Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
2923329e8e
commit
a700be3207
10 changed files with 82 additions and 10 deletions
1
pref.h
1
pref.h
|
@ -44,6 +44,7 @@ struct preferences {
|
|||
int animation_speed;
|
||||
bool gf_low_at_maxdepth;
|
||||
bool show_ccr_setpoint;
|
||||
bool show_ccr_sensors;
|
||||
short display_invalid_dives;
|
||||
short unit_system;
|
||||
struct units units;
|
||||
|
|
|
@ -28,6 +28,9 @@ void fill_profile_color()
|
|||
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[CCRSENSOR1] = COLOR(TUNDORA1_MED_TRANS, BLACK1_LOW_TRANS, TUNDORA1_MED_TRANS);
|
||||
profile_color[CCRSENSOR2] = COLOR(ROYALBLUE2_LOW_TRANS, BLACK1_LOW_TRANS, ROYALBLUE2_LOW_TRANS);
|
||||
profile_color[CCRSENSOR3] = COLOR(PEANUT, BLACK1_LOW_TRANS, PEANUT);
|
||||
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);
|
||||
|
|
|
@ -38,6 +38,9 @@ typedef enum {
|
|||
PHE,
|
||||
PHE_ALERT,
|
||||
O2SETPOINT,
|
||||
CCRSENSOR1,
|
||||
CCRSENSOR2,
|
||||
CCRSENSOR3,
|
||||
PP_LINES,
|
||||
|
||||
/* Other colors */
|
||||
|
|
|
@ -124,6 +124,7 @@ void PreferencesDialog::setUiFromPrefs()
|
|||
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);
|
||||
ui.show_ccr_sensors->setChecked(prefs.show_ccr_sensors);
|
||||
ui.defaultSetpoint->setValue((double)prefs.defaultsetpoint / 1000.0);
|
||||
ui.psro2rate->setValue(prefs.o2consumption / 1000.0);
|
||||
ui.pscrfactor->setValue(rint(1000.0 / prefs.pscr_ratio));
|
||||
|
@ -279,6 +280,7 @@ void PreferencesDialog::syncSettings()
|
|||
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("show_ccr_sensors", default_prefs.show_ccr_sensors, ui.show_ccr_sensors->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();
|
||||
|
@ -396,6 +398,7 @@ void PreferencesDialog::loadSettings()
|
|||
GET_INT("gfhigh", gfhigh);
|
||||
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);
|
||||
GET_BOOL("show_ccr_setpoint",show_ccr_setpoint);
|
||||
GET_BOOL("show_ccr_sensors",show_ccr_sensors);
|
||||
GET_BOOL("zoomed_plot", zoomed_plot);
|
||||
set_gf(prefs.gflow, prefs.gfhigh, prefs.gf_low_at_maxdepth);
|
||||
GET_BOOL("show_sac", show_sac);
|
||||
|
|
|
@ -788,11 +788,25 @@
|
|||
<string>GFLow at max depth</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="show_ccr_setpoint">
|
||||
<property name="text">
|
||||
<string>CCR: Show setpoints when viewing pO₂</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QCheckBox" name="show_ccr_sensors">
|
||||
<property name="text">
|
||||
<string>CCR: Show individual O₂ sensor values when viewing pO₂</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="text">
|
||||
<string>Default CCR set-point</string>
|
||||
<string>Default CCR set-point for dive planning</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -812,13 +826,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="show_ccr_setpoint">
|
||||
<property name="text">
|
||||
<string>CCR: Show setpoints when viewing pO₂</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="pSCR">
|
||||
<property name="text">
|
||||
|
|
|
@ -52,6 +52,12 @@ QVariant DivePlotDataModel::data(const QModelIndex &index, int role) const
|
|||
return item.pressures.o2;
|
||||
case O2SETPOINT:
|
||||
return item.o2setpoint.mbar / 1000.0;
|
||||
case CCRSENSOR1:
|
||||
return item.o2sensor[0].mbar / 1000.0;
|
||||
case CCRSENSOR2:
|
||||
return item.o2sensor[1].mbar / 1000.0;
|
||||
case CCRSENSOR3:
|
||||
return item.o2sensor[2].mbar / 1000.0;
|
||||
case HEARTBEAT:
|
||||
return item.heartbeat;
|
||||
case AMBPRESSURE:
|
||||
|
@ -129,6 +135,12 @@ QVariant DivePlotDataModel::headerData(int section, Qt::Orientation orientation,
|
|||
return tr("pO₂");
|
||||
case O2SETPOINT:
|
||||
return tr("Setpoint");
|
||||
case CCRSENSOR1:
|
||||
return tr("Sensor1");
|
||||
case CCRSENSOR2:
|
||||
return tr("Sensor2");
|
||||
case CCRSENSOR3:
|
||||
return tr("Sensor3");
|
||||
case AMBPRESSURE:
|
||||
return tr("Ambient pressure");
|
||||
case HEARTBEAT:
|
||||
|
@ -185,9 +197,23 @@ unsigned int DivePlotDataModel::dcShown() const
|
|||
return ret; \
|
||||
}
|
||||
|
||||
#define MAX_SENSOR_GAS_FUNC(GASFUNC) \
|
||||
double DivePlotDataModel::GASFUNC() /* CCR: This function finds the largest measured po2 value */ \
|
||||
{ /* by scanning the readings from the three individual o2 sensors. */ \
|
||||
double ret = -1; /* This is used for scaling the Y-axis for partial pressures */ \
|
||||
for (int s = 0; s < 3; s++) { /* when displaying the graphs for individual o2 sensors */ \
|
||||
for (int i = 0, count = rowCount(); i < count; i++) { /* POTENTIAL PROBLEM: the '3' (no_sensors) is hard-coded here */\
|
||||
if (pInfo.entry[i].o2sensor[s].mbar > ret) \
|
||||
ret = pInfo.entry[i].o2sensor[s].mbar; \
|
||||
} \
|
||||
} \
|
||||
return (ret / 1000.0); /* mbar -> bar conversion */ \
|
||||
}
|
||||
|
||||
MAX_PPGAS_FUNC(he, pheMax);
|
||||
MAX_PPGAS_FUNC(n2, pn2Max);
|
||||
MAX_PPGAS_FUNC(o2, po2Max);
|
||||
MAX_SENSOR_GAS_FUNC(CCRMax);
|
||||
|
||||
void DivePlotDataModel::emitDataChanged()
|
||||
{
|
||||
|
|
|
@ -60,6 +60,9 @@ public:
|
|||
PHE,
|
||||
PO2,
|
||||
O2SETPOINT,
|
||||
CCRSENSOR1,
|
||||
CCRSENSOR2,
|
||||
CCRSENSOR3,
|
||||
HEARTBEAT,
|
||||
AMBPRESSURE,
|
||||
GFLINE,
|
||||
|
@ -78,6 +81,7 @@ public:
|
|||
double pheMax();
|
||||
double pn2Max();
|
||||
double po2Max();
|
||||
double CCRMax();
|
||||
void emitDataChanged();
|
||||
void calculateDecompression();
|
||||
|
||||
|
|
|
@ -84,6 +84,9 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
|
|||
pheGasItem(new PartialPressureGasItem()),
|
||||
po2GasItem(new PartialPressureGasItem()),
|
||||
o2SetpointGasItem(new PartialPressureGasItem()),
|
||||
ccrsensor1GasItem(new PartialPressureGasItem()),
|
||||
ccrsensor2GasItem(new PartialPressureGasItem()),
|
||||
ccrsensor3GasItem(new PartialPressureGasItem()),
|
||||
heartBeatAxis(new DiveCartesianAxis()),
|
||||
heartBeatItem(new DiveHeartrateItem()),
|
||||
percentageAxis(new DiveCartesianAxis()),
|
||||
|
@ -152,6 +155,9 @@ ProfileWidget2::~ProfileWidget2()
|
|||
delete pheGasItem;
|
||||
delete po2GasItem;
|
||||
delete o2SetpointGasItem;
|
||||
delete ccrsensor1GasItem;
|
||||
delete ccrsensor2GasItem;
|
||||
delete ccrsensor3GasItem;
|
||||
delete heartBeatAxis;
|
||||
delete heartBeatItem;
|
||||
delete percentageAxis;
|
||||
|
@ -191,6 +197,9 @@ void ProfileWidget2::addItemsToScene()
|
|||
scene()->addItem(pheGasItem);
|
||||
scene()->addItem(po2GasItem);
|
||||
scene()->addItem(o2SetpointGasItem);
|
||||
scene()->addItem(ccrsensor1GasItem);
|
||||
scene()->addItem(ccrsensor2GasItem);
|
||||
scene()->addItem(ccrsensor3GasItem);
|
||||
scene()->addItem(percentageAxis);
|
||||
scene()->addItem(heartBeatAxis);
|
||||
scene()->addItem(heartBeatItem);
|
||||
|
@ -297,6 +306,9 @@ void ProfileWidget2::setupItemOnScene()
|
|||
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");
|
||||
CREATE_PP_GAS(ccrsensor1GasItem, CCRSENSOR1, CCRSENSOR1, PO2_ALERT, &prefs.pp_graphs.po2_threshold, "ccrsensorgraph");
|
||||
CREATE_PP_GAS(ccrsensor2GasItem, CCRSENSOR2, CCRSENSOR2, PO2_ALERT, &prefs.pp_graphs.po2_threshold, "ccrsensorgraph");
|
||||
CREATE_PP_GAS(ccrsensor3GasItem, CCRSENSOR3, CCRSENSOR3, PO2_ALERT, &prefs.pp_graphs.po2_threshold, "ccrsensorgraph");
|
||||
#undef CREATE_PP_GAS
|
||||
|
||||
temperatureAxis->setTextVisible(false);
|
||||
|
@ -509,7 +521,10 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
|
|||
currentdc = fake_dc(currentdc);
|
||||
}
|
||||
|
||||
o2SetpointGasItem->setVisible(current_dive && (currentdc->divemode == CCR) && prefs.show_ccr_setpoint && prefs.pp_graphs.po2);
|
||||
o2SetpointGasItem->setVisible(prefs.show_ccr_setpoint && (currentdc->divemode == CCR) && prefs.pp_graphs.po2 && current_dive);
|
||||
ccrsensor1GasItem->setVisible(prefs.show_ccr_sensors && (currentdc->divemode == CCR) && prefs.pp_graphs.po2 && current_dive);
|
||||
ccrsensor2GasItem->setVisible(prefs.show_ccr_sensors && (currentdc->divemode == CCR) && prefs.pp_graphs.po2 && current_dive);
|
||||
ccrsensor3GasItem->setVisible(prefs.show_ccr_sensors && (currentdc->divemode == CCR) && prefs.pp_graphs.po2 && (currentdc->no_o2sensors > 2) && current_dive);
|
||||
|
||||
/* 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
|
||||
|
@ -860,6 +875,9 @@ void ProfileWidget2::setEmptyState()
|
|||
pn2GasItem->setVisible(false);
|
||||
po2GasItem->setVisible(false);
|
||||
o2SetpointGasItem->setVisible(false);
|
||||
ccrsensor1GasItem->setVisible(false);
|
||||
ccrsensor2GasItem->setVisible(false);
|
||||
ccrsensor3GasItem->setVisible(false);
|
||||
pheGasItem->setVisible(false);
|
||||
ambPressureItem->setVisible(false);
|
||||
gflineItem->setVisible(false);
|
||||
|
@ -957,8 +975,11 @@ void ProfileWidget2::setProfileState()
|
|||
}
|
||||
pn2GasItem->setVisible(prefs.pp_graphs.pn2);
|
||||
po2GasItem->setVisible(prefs.pp_graphs.po2);
|
||||
o2SetpointGasItem->setVisible(current_dive && prefs.pp_graphs.po2 && (current_dc->divemode == CCR) && (prefs.show_ccr_setpoint));
|
||||
pheGasItem->setVisible(prefs.pp_graphs.phe);
|
||||
o2SetpointGasItem->setVisible(current_dive && prefs.pp_graphs.po2 && (current_dc->divemode == CCR) && (prefs.show_ccr_setpoint));
|
||||
ccrsensor1GasItem->setVisible(prefs.show_ccr_sensors && (current_dc->divemode == CCR) && prefs.pp_graphs.po2 && current_dive);
|
||||
ccrsensor2GasItem->setVisible(prefs.show_ccr_sensors && (current_dc->divemode == CCR) && prefs.pp_graphs.po2 && (current_dc->no_o2sensors > 1) && current_dive);
|
||||
ccrsensor3GasItem->setVisible(prefs.show_ccr_sensors && (current_dc->divemode == CCR) && prefs.pp_graphs.po2 && (current_dc->no_o2sensors > 2) && current_dive);
|
||||
|
||||
timeAxis->setPos(itemPos.time.pos.on);
|
||||
timeAxis->setLine(itemPos.time.expanded);
|
||||
|
|
|
@ -172,6 +172,9 @@ private:
|
|||
PartialPressureGasItem *pheGasItem;
|
||||
PartialPressureGasItem *po2GasItem;
|
||||
PartialPressureGasItem *o2SetpointGasItem;
|
||||
PartialPressureGasItem *ccrsensor1GasItem;
|
||||
PartialPressureGasItem *ccrsensor2GasItem;
|
||||
PartialPressureGasItem *ccrsensor3GasItem;
|
||||
DiveCartesianAxis *heartBeatAxis;
|
||||
DiveHeartrateItem *heartBeatItem;
|
||||
DiveCartesianAxis *percentageAxis;
|
||||
|
|
|
@ -30,6 +30,7 @@ struct preferences default_prefs = {
|
|||
.animation_speed = 500,
|
||||
.gf_low_at_maxdepth = false,
|
||||
.show_ccr_setpoint = false,
|
||||
.show_ccr_sensors = false,
|
||||
.font_size = -1,
|
||||
.display_invalid_dives = false,
|
||||
.show_sac = false,
|
||||
|
|
Loading…
Add table
Reference in a new issue