summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-07 11:36:25 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-07 11:39:15 -0800
commita0f28aa42271ef014a91c4b8c83d871d7ae0cdf5 (patch)
tree9139dc72ae3f93a004428b9a5085434335400c45
parent982abb5596d6c92004c8ea88320878540f5a8415 (diff)
downloadsubsurface-a0f28aa42271ef014a91c4b8c83d871d7ae0cdf5.tar.gz
Add option to make ceiling visually stand out more in the profile
While having the background "come down" seemed like a good visualization of the ceiling, some divers appear to prefer something more dramatic. This adds an option to the Tec Settings to have the ceiling shown in red instead of the default background color. Suggested-by: Jan Schubert <Jan.Schubert@GMX.li> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--display-gtk.h1
-rw-r--r--gtk-gui.c20
-rw-r--r--profile.c25
3 files changed, 42 insertions, 4 deletions
diff --git a/display-gtk.h b/display-gtk.h
index f88d96633..5dc616bf9 100644
--- a/display-gtk.h
+++ b/display-gtk.h
@@ -32,6 +32,7 @@ typedef struct {
extern visible_cols_t visible_cols;
extern partial_pressure_graphs_t partial_pressure_graphs;
+extern gboolean profile_red_ceiling;
#define GRAPHS_ENABLED (partial_pressure_graphs.po2 || partial_pressure_graphs.pn2 || partial_pressure_graphs.phe)
diff --git a/gtk-gui.c b/gtk-gui.c
index 4e907af5c..c2cad6c5a 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -38,6 +38,7 @@ static GtkWidget *dive_profile;
visible_cols_t visible_cols = {TRUE, FALSE, };
partial_pressure_graphs_t partial_pressure_graphs = { FALSE, FALSE, FALSE, 1.6, 4.0, 10.0};
+gboolean profile_red_ceiling = FALSE;
static const char *default_dive_computer_vendor;
static const char *default_dive_computer_product;
@@ -485,6 +486,7 @@ OPTIONCALLBACK(autogroup_toggle, autogroup)
OPTIONCALLBACK(po2_toggle, partial_pressure_graphs.po2)
OPTIONCALLBACK(pn2_toggle, partial_pressure_graphs.pn2)
OPTIONCALLBACK(phe_toggle, partial_pressure_graphs.phe)
+OPTIONCALLBACK(red_ceiling_toggle, profile_red_ceiling)
OPTIONCALLBACK(force_toggle, force_download)
OPTIONCALLBACK(prefer_dl_toggle, prefer_downloaded)
@@ -680,7 +682,7 @@ 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(otu_toggle), NULL);
- frame = gtk_frame_new(_("Show Partial Pressure Graphs in Profile"));
+ frame = gtk_frame_new(_("Profile Settings"));
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
vbox = gtk_vbox_new(FALSE, 6);
@@ -688,7 +690,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
box = gtk_hbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(vbox), box);
- button = gtk_check_button_new_with_label(_("pO" UTF8_SUBSCRIPT_2));
+ button = gtk_check_button_new_with_label(_("Show pO" UTF8_SUBSCRIPT_2 " graph"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), partial_pressure_graphs.po2);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(po2_toggle), &entry_po2);
@@ -705,7 +707,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
box = gtk_hbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(vbox), box);
- button = gtk_check_button_new_with_label(_("pN" UTF8_SUBSCRIPT_2));
+ button = gtk_check_button_new_with_label(_("Show pN" UTF8_SUBSCRIPT_2 " graph"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), partial_pressure_graphs.pn2);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(pn2_toggle), &entry_pn2);
@@ -722,7 +724,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
box = gtk_hbox_new(FALSE, 6);
gtk_container_add(GTK_CONTAINER(vbox), box);
- button = gtk_check_button_new_with_label(_("pHe"));
+ button = gtk_check_button_new_with_label(_("Show pHe graph"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), partial_pressure_graphs.phe);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(phe_toggle), &entry_phe);
@@ -736,6 +738,14 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
gtk_widget_set_sensitive(entry_phe, partial_pressure_graphs.phe);
gtk_container_add(GTK_CONTAINER(frame), entry_phe);
+ box = gtk_hbox_new(FALSE, 6);
+ gtk_container_add(GTK_CONTAINER(vbox), box);
+
+ button = gtk_check_button_new_with_label(_("Show ceiling in red"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), partial_pressure_graphs.phe);
+ gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
+ g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(red_ceiling_toggle), &entry_phe);
+
gtk_widget_show_all(dialog);
result = gtk_dialog_run(GTK_DIALOG(dialog));
if (result == GTK_RESPONSE_ACCEPT) {
@@ -781,6 +791,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
subsurface_set_conf("po2threshold", PREF_STRING, po2_threshold_text);
subsurface_set_conf("pn2threshold", PREF_STRING, pn2_threshold_text);
subsurface_set_conf("phethreshold", PREF_STRING, phe_threshold_text);
+ subsurface_set_conf("redceiling", PREF_BOOL, BOOL_TO_PTR(profile_red_ceiling));
new_default = strdup(gtk_button_get_label(GTK_BUTTON(xmlfile_button)));
@@ -1141,6 +1152,7 @@ void init_ui(int *argcp, char ***argvp)
conf_value = subsurface_get_conf("phethreshold", PREF_STRING);
if (conf_value)
sscanf(conf_value, "%lf", &partial_pressure_graphs.phe_threshold);
+ profile_red_ceiling = PTR_TO_BOOL(subsurface_get_conf("redceiling", PREF_BOOL));
divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);
autogroup = PTR_TO_BOOL(subsurface_get_conf("autogroup", PREF_BOOL));
default_filename = subsurface_get_conf("default_filename", PREF_STRING);
diff --git a/profile.c b/profile.c
index cea974b21..8940817b8 100644
--- a/profile.c
+++ b/profile.c
@@ -1007,6 +1007,31 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi
cairo_close_path(gc->cr);
cairo_fill(gc->cr);
+ /* if the user wants the deco ceiling more visible, do that here (this
+ * basically draws over the background that we had allowed to shine
+ * through so far) */
+ if (profile_red_ceiling) {
+ pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
+ pattern_add_color_stop_rgba (gc, pat, 0, CEILING_SHALLOW);
+ pattern_add_color_stop_rgba (gc, pat, 1, CEILING_DEEP);
+ cairo_set_source(gc->cr, pat);
+ cairo_pattern_destroy(pat);
+ entry = pi->entry;
+ move_to(gc, 0, 0);
+ for (i = 0; i < pi->nr; i++, entry++) {
+ if (entry->ndl == 0 && entry->stopdepth) {
+ if (entry->ndl == 0 && entry->stopdepth < entry->depth) {
+ line_to(gc, entry->sec, entry->stopdepth);
+ } else {
+ line_to(gc, entry->sec, entry->depth);
+ }
+ } else {
+ line_to(gc, entry->sec, 0);
+ }
+ }
+ cairo_close_path(gc->cr);
+ cairo_fill(gc->cr);
+ }
/* next show where we have been bad and crossed the ceiling */
pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
pattern_add_color_stop_rgba (gc, pat, 0, CEILING_SHALLOW);