summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deco.c9
-rw-r--r--display-gtk.h2
-rw-r--r--dive.h1
-rw-r--r--gtk-gui.c67
4 files changed, 76 insertions, 3 deletions
diff --git a/deco.c b/deco.c
index e18779ac8..efcdfd39b 100644
--- a/deco.c
+++ b/deco.c
@@ -10,6 +10,7 @@
* add_segment(pressure, gasmix, seconds) - add <seconds> at the given pressure, breathing gasmix
* deco_allowed_depth(tissues_tolerance, surface_pressure, dive, smooth)
* - ceiling based on lead tissue, surface pressure, 3m increments or smooth
+ * set_gf(gflow, gfhigh) - set Buehlmann gradient factors
*/
#include <math.h>
#include "dive.h"
@@ -244,3 +245,11 @@ unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressur
return depth;
}
+
+void set_gf(double gflow, double gfhigh)
+{
+ if (gflow != -1.0)
+ buehlmann_config.gf_low = gflow;
+ if (gfhigh != -1.0)
+ buehlmann_config.gf_high = gfhigh;
+}
diff --git a/display-gtk.h b/display-gtk.h
index 0523dc0aa..629972434 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -42,6 +42,8 @@ struct preferences {
gboolean profile_red_ceiling;
gboolean profile_calc_ceiling;
gboolean calc_ceiling_3m_incr;
+ double gflow;
+ double gfhigh;
};
extern struct preferences prefs;
diff --git a/dive.h b/dive.h
index 0cee818fe..57ba280e0 100644
--- a/dive.h
+++ b/dive.h
@@ -576,6 +576,7 @@ extern double add_segment(double pressure, struct gasmix *gasmix, int period_in_
extern void clear_deco(double surface_pressure);
extern void dump_tissues(void);
extern unsigned int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, gboolean smooth);
+extern void set_gf(double gflow, double gfhigh);
#ifdef DEBUGFILE
extern char *debugfilename;
extern FILE *debugfile;
diff --git a/gtk-gui.c b/gtk-gui.c
index 79003ac2f..1b1113cad 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -36,7 +36,7 @@ struct preferences prefs = {
SI_UNITS,
{ TRUE, FALSE, },
{ FALSE, FALSE, FALSE, 1.6, 4.0, 13.0},
- FALSE
+ FALSE, FALSE, FALSE, 30.0, 90.0
};
struct dcnicknamelist {
@@ -516,6 +516,24 @@ OPTIONCALLBACK(calc_ceiling_3m_toggle, prefs.calc_ceiling_3m_incr)
OPTIONCALLBACK(force_toggle, force_download)
OPTIONCALLBACK(prefer_dl_toggle, prefer_downloaded)
+static void gflow_edit(GtkWidget *w, gpointer _data)
+{
+ double gflow;
+ const char *buf;
+ buf = gtk_entry_get_text(GTK_ENTRY(w));
+ sscanf(buf, "%lf", &gflow);
+ set_gf(prefs.gflow, -1.0);
+}
+
+static void gfhigh_edit(GtkWidget *w, gpointer _data)
+{
+ double gfhigh;
+ const char *buf;
+ buf = gtk_entry_get_text(GTK_ENTRY(w));
+ sscanf(buf, "%lf", &gfhigh);
+ set_gf(-1.0, prefs.gfhigh);
+}
+
static void event_toggle(GtkWidget *w, gpointer _data)
{
gboolean *plot_ev = _data;
@@ -577,7 +595,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
{
int result;
GtkWidget *dialog, *notebook, *font, *frame, *box, *vbox, *button, *xmlfile_button;
- GtkWidget *entry_po2, *entry_pn2, *entry_phe;
+ GtkWidget *entry_po2, *entry_pn2, *entry_phe, *entry_gflow, *entry_gfhigh;
const char *current_default, *new_default;
char threshold_text[10], utf8_buf[128];
struct preferences oldprefs = prefs;
@@ -775,6 +793,9 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(red_ceiling_toggle), NULL);
+ box = gtk_hbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(vbox), box);
+
button = gtk_check_button_new_with_label(_("Show calculated ceiling"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), prefs.profile_calc_ceiling);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
@@ -785,10 +806,31 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(calc_ceiling_3m_toggle), NULL);
+ box = gtk_hbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(vbox), box);
+
+ frame = gtk_frame_new(_("GFlow"));
+ gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 6);
+ entry_gflow = gtk_entry_new();
+ gtk_entry_set_max_length(GTK_ENTRY(entry_gflow), 4);
+ snprintf(threshold_text, sizeof(threshold_text), "%.0f", prefs.gflow);
+ gtk_entry_set_text(GTK_ENTRY(entry_gflow), threshold_text);
+ gtk_container_add(GTK_CONTAINER(frame), entry_gflow);
+ g_signal_connect(G_OBJECT(entry_gflow), "changed", G_CALLBACK(gflow_edit), NULL);
+
+ frame = gtk_frame_new(_("GFhigh"));
+ gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 6);
+ entry_gfhigh = gtk_entry_new();
+ gtk_entry_set_max_length(GTK_ENTRY(entry_gfhigh), 4);
+ snprintf(threshold_text, sizeof(threshold_text), "%.0f", prefs.gfhigh);
+ gtk_entry_set_text(GTK_ENTRY(entry_gfhigh), threshold_text);
+ gtk_container_add(GTK_CONTAINER(frame), entry_gfhigh);
+ g_signal_connect(G_OBJECT(entry_gflow), "changed", G_CALLBACK(gfhigh_edit), NULL);
+
gtk_widget_show_all(dialog);
result = gtk_dialog_run(GTK_DIALOG(dialog));
if (result == GTK_RESPONSE_ACCEPT) {
- const char *po2_threshold_text, *pn2_threshold_text, *phe_threshold_text;
+ const char *po2_threshold_text, *pn2_threshold_text, *phe_threshold_text, *gflow_text, *gfhigh_text;
/* Make sure to flush any modified old dive data with old units */
update_dive(NULL);
@@ -802,6 +844,11 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
sscanf(pn2_threshold_text, "%lf", &prefs.pp_graphs.pn2_threshold);
phe_threshold_text = gtk_entry_get_text(GTK_ENTRY(entry_phe));
sscanf(phe_threshold_text, "%lf", &prefs.pp_graphs.phe_threshold);
+ gflow_text = gtk_entry_get_text(GTK_ENTRY(entry_gflow));
+ sscanf(gflow_text, "%lf", &prefs.gflow);
+ gfhigh_text = gtk_entry_get_text(GTK_ENTRY(entry_gfhigh));
+ sscanf(gfhigh_text, "%lf", &prefs.gfhigh);
+ set_gf(prefs.gflow, prefs.gfhigh);
update_screen();
@@ -831,6 +878,8 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
subsurface_set_conf("redceiling", PREF_BOOL, BOOL_TO_PTR(prefs.profile_red_ceiling));
subsurface_set_conf("calcceiling", PREF_BOOL, BOOL_TO_PTR(prefs.profile_calc_ceiling));
subsurface_set_conf("calcceiling3m", PREF_BOOL, BOOL_TO_PTR(prefs.calc_ceiling_3m_incr));
+ subsurface_set_conf("gflow", PREF_STRING, gflow_text);
+ subsurface_set_conf("gfhigh", PREF_STRING, gfhigh_text);
new_default = strdup(gtk_button_get_label(GTK_BUTTON(xmlfile_button)));
@@ -1252,6 +1301,18 @@ void init_ui(int *argcp, char ***argvp)
prefs.profile_red_ceiling = PTR_TO_BOOL(subsurface_get_conf("redceiling", PREF_BOOL));
prefs.profile_calc_ceiling = PTR_TO_BOOL(subsurface_get_conf("calcceiling", PREF_BOOL));
prefs.calc_ceiling_3m_incr = PTR_TO_BOOL(subsurface_get_conf("calcceiling3m", PREF_BOOL));
+ conf_value = subsurface_get_conf("gflow", PREF_STRING);
+ if (conf_value) {
+ sscanf(conf_value, "%lf", &prefs.gflow);
+ set_gf(prefs.gflow, -1.0);
+ free((void *)conf_value);
+ }
+ conf_value = subsurface_get_conf("gfhigh", PREF_STRING);
+ if (conf_value) {
+ sscanf(conf_value, "%lf", &prefs.gfhigh);
+ set_gf(-1.0, prefs.gfhigh);
+ free((void *)conf_value);
+ }
divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);
default_filename = subsurface_get_conf("default_filename", PREF_STRING);