diff --git a/deco.c b/deco.c
index c5d2bffc7..c7ad61660 100644
--- a/deco.c
+++ b/deco.c
@@ -83,6 +83,9 @@ int ci_pointing_to_guiding_tissue;
double gf_low_pressure_this_dive;
#define TISSUE_ARRAY_SZ sizeof(tissue_n2_sat)
+double tolerated_by_tissue[16];
+
+
static double tissue_tolerance_calc(const struct dive *dive)
{
int ci = -1;
@@ -117,6 +120,8 @@ static double tissue_tolerance_calc(const struct dive *dive)
(1.0 - buehlmann_inertgas_b)*(gf_low * gf_low_pressure_this_dive - gf_high * surface) +
buehlmann_inertgas_b * (gf_low_pressure_this_dive - surface));
+ tolerated_by_tissue[ci] = tolerated;
+
if (tolerated > ret_tolerance_limit_ambient_pressure)
{
ci_pointing_to_guiding_tissue = ci;
diff --git a/deco.h b/deco.h
new file mode 100644
index 000000000..f9ed7d4d7
--- /dev/null
+++ b/deco.h
@@ -0,0 +1,12 @@
+#ifndef DECO_H
+#define DECO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ extern double tolerated_by_tissue[];
+
+ extern double buehlmann_N2_t_halflife[];
+
+#endif
diff --git a/pref.h b/pref.h
index 7bf71b44c..376cc4a71 100644
--- a/pref.h
+++ b/pref.h
@@ -39,6 +39,7 @@ struct preferences {
short profile_red_ceiling;
short profile_calc_ceiling;
short calc_ceiling_3m_incr;
+ short calc_all_tissues;
short gflow;
short gfhigh;
int map_provider;
diff --git a/profile.c b/profile.c
index e6ba6ad8d..c502cf669 100644
--- a/profile.c
+++ b/profile.c
@@ -12,6 +12,7 @@
#include "divelist.h"
#include "profile.h"
+#include "deco.h"
#include "libdivecomputer/parser.h"
#include "libdivecomputer/version.h"
@@ -971,7 +972,7 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d
double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, TRUE)) / 1000.0;
for (i = 1; i < pi->nr; i++) {
- int fo2, fhe, j, t0, t1;
+ int fo2, fhe, j, k, t0, t1;
double tissue_tolerance;
struct plot_data *entry = pi->entry + i;
int cylinderindex = entry->cylinderindex;
@@ -1038,6 +1039,8 @@ static void calculate_deco_information(struct dive *dive, struct divecomputer *d
entry->ceiling = (entry - 1)->ceiling;
else
entry->ceiling = deco_allowed_depth(tissue_tolerance, surface_pressure, dive, !prefs.calc_ceiling_3m_incr);
+ for (k=0; k<16; k++)
+ entry->ceilings[k] = deco_allowed_depth(tolerated_by_tissue[k], surface_pressure, dive, 1);
}
#if DECO_CALC_DEBUG & 1
@@ -1137,6 +1140,16 @@ static void plot_string(struct plot_data *entry, char *buf, int bufsize,
depthvalue = get_depth_units(entry->ceiling, NULL, &depth_unit);
memcpy(buf2, buf, bufsize);
snprintf(buf, bufsize, _("%s\nCalculated ceiling %.0f %s"), buf2, depthvalue, depth_unit);
+ if (prefs.calc_all_tissues){
+ int k;
+ for (k=0; k<16; k++){
+ if (entry->ceilings[k]){
+ depthvalue = get_depth_units(entry->ceilings[k], NULL, &depth_unit);
+ memcpy(buf2, buf, bufsize);
+ snprintf(buf, bufsize, _("%s\nTissue %.0fmin: %.0f %s"), buf2, buehlmann_N2_t_halflife[k], depthvalue, depth_unit);
+ }
+ }
+ }
}
if (entry->stopdepth) {
depthvalue = get_depth_units(entry->stopdepth, NULL, &depth_unit);
diff --git a/profile.h b/profile.h
index 5190c54f8..7af95d565 100644
--- a/profile.h
+++ b/profile.h
@@ -23,6 +23,7 @@ struct plot_data {
/* Depth info */
int depth;
int ceiling;
+ int ceilings[16];
int ndl;
int stoptime;
int stopdepth;
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 14958b50f..79e3f2c7d 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -403,6 +403,7 @@ void MainWindow::readSettings()
GET_BOOL(v, "dcceiling", prefs.profile_dc_ceiling);
GET_BOOL(v, "calcceiling", prefs.profile_calc_ceiling);
GET_BOOL(v, "calcceiling3m", prefs.calc_ceiling_3m_incr);
+ GET_BOOL(v, "calcalltissues", prefs.calc_all_tissues);
v = settings.value(QString("gflow"));
if (v.isValid())
prefs.gflow = v.toInt();
@@ -479,6 +480,7 @@ void MainWindow::writeSettings()
SAVE_VALUE("redceiling", profile_red_ceiling);
SAVE_VALUE("calcceiling", profile_calc_ceiling);
SAVE_VALUE("calcceiling3m", calc_ceiling_3m_incr);
+ SAVE_VALUE("calcalltissues", calc_all_tissues);
SAVE_VALUE("dcceiling", profile_dc_ceiling);
SAVE_VALUE("gflow", gflow);
SAVE_VALUE("gfhigh", gfhigh);
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index 453f20c34..68dcbf2a0 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -41,6 +41,8 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Qt::WindowFlags f) : QDial
ui->calculated_ceiling->setChecked(B(calcceiling, profile_calc_ceiling));
ui->increment_3m->setEnabled(ui->calculated_ceiling->isChecked());
ui->increment_3m->setChecked(B(calcceiling3m, calc_ceiling_3m_incr));
+ ui->all_tissues->setEnabled(ui->all_tissues->isChecked());
+ ui->all_tissues->setChecked(B(calcalltissues, calc_all_tissues));
ui->gflow->setValue((int)(I(gflow, gflow)));
ui->gfhigh->setValue((int)(I(gfhigh, gfhigh)));
@@ -112,6 +114,7 @@ void PreferencesDialog::syncSettings()
SB("redceiling", ui->red_ceiling);
SB("calcceiling", ui->calculated_ceiling);
SB("calcceiling3m", ui->increment_3m);
+ SB("calcalltissues", ui->all_tissues);
s.setValue("gflow", ui->gflow->value());
s.setValue("gfhigh", ui->gfhigh->value());
s.endGroup();
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 348e62ecd..1617c453b 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -6,8 +6,8 @@
0
0
- 444
- 386
+ 604
+ 490
@@ -116,7 +116,7 @@
- 1
+ 2
@@ -624,8 +624,8 @@
-
-
+
+
-
-
@@ -648,6 +648,16 @@
+ -
+
+
+ false
+
+
+ show all tissues
+
+
+
-
@@ -890,26 +900,10 @@
-
- dc_ceiling
- clicked(bool)
- red_ceiling
- setEnabled(bool)
-
-
- 288
- 364
-
-
- 555
- 371
-
-
-
calculated_ceiling
clicked(bool)
- increment_3m
+ all_tissues
setEnabled(bool)
@@ -922,12 +916,28 @@
+
+ calculated_ceiling
+ clicked(bool)
+ increment_3m
+ setEnabled(bool)
+
+
+ 198
+ 286
+
+
+ 503
+ 286
+
+
+
-
+
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 663aefe25..d635e1956 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -1072,6 +1072,32 @@ void ProfileGraphicsView::plot_depth_profile()
neatFill->setBrush(pat);
scene()->addItem(neatFill);
}
+
+ /* plot the calculated ceiling for all tissues */
+ if (prefs.calc_all_tissues){
+ int k;
+ for (k=0; k<16; k++){
+ if (prefs.profile_calc_ceiling) {
+ pat.setColorAt(0, profile_color[CALC_CEILING_SHALLOW].first());
+ pat.setColorAt(1, QColor(100, 100, 100, 50));
+
+ entry = gc.pi.entry;
+ p.clear();
+ p.append(QPointF(SCALEGC(0, 0)));
+ for (i = 0; i < gc.pi.nr; i++, entry++) {
+ if ((entry->ceilings)[k])
+ p.append(QPointF(SCALEGC(entry->sec, (entry->ceilings)[k])));
+ else
+ p.append(QPointF(SCALEGC(entry->sec, 0)));
+ }
+ p.append(QPointF(SCALEGC((entry-1)->sec, 0)));
+ neatFill = new QGraphicsPolygonItem();
+ neatFill->setPolygon(p);
+ neatFill->setBrush(pat);
+ scene()->addItem(neatFill);
+ }
+ }
+ }
/* next show where we have been bad and crossed the dc's ceiling */
if (prefs.profile_dc_ceiling) {
pat.setColorAt(0, profile_color[CEILING_SHALLOW].first());