Add configurable visualization of calculated ceiling

This is on top of the deco information reported by the dive computer (in a
different color - currently ugly green). The user needs to enable this via
the Tec page of the preferences.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2013-01-02 22:45:21 -08:00
parent 3c31d0401d
commit aab67e2a5b
4 changed files with 33 additions and 2 deletions

View file

@ -7,9 +7,11 @@
// Greens
#define CAMARONE1 { 0.0, 0.4, 0.0, 1 }
#define FUNGREEN1 { 0.0, 0.4, 0.2, 1 }
#define FUNGREEN1_HIGH_TRANS { 0.0, 0.4, 0.2, 0.25 }
#define KILLARNEY1 { 0.2, 0.4, 0.2, 1 }
#define APPLE1 { 0.2, 0.6, 0.2, 1 }
#define APPLE1_MED_TRANS { 0.2, 0.6, 0.2, 0.5 }
#define APPLE1_HIGH_TRANS { 0.2, 0.6, 0.2, 0.25 }
#define LIMENADE1 { 0.4, 0.8, 0.0, 1 }
#define ATLANTIS1 { 0.4, 0.8, 0.2, 1 }
#define ATLANTIS2 { 0.6, 0.8, 0.2, 1 }

View file

@ -40,6 +40,7 @@ struct preferences {
visible_cols_t visible_cols;
partial_pressure_graphs_t pp_graphs;
gboolean profile_red_ceiling;
gboolean profile_calc_ceiling;
};
extern struct preferences prefs;

View file

@ -511,6 +511,7 @@ OPTIONCALLBACK(po2_toggle, prefs.pp_graphs.po2)
OPTIONCALLBACK(pn2_toggle, prefs.pp_graphs.pn2)
OPTIONCALLBACK(phe_toggle, prefs.pp_graphs.phe)
OPTIONCALLBACK(red_ceiling_toggle, prefs.profile_red_ceiling)
OPTIONCALLBACK(calc_ceiling_toggle, prefs.profile_calc_ceiling)
OPTIONCALLBACK(force_toggle, force_download)
OPTIONCALLBACK(prefer_dl_toggle, prefer_downloaded)
@ -768,11 +769,16 @@ 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(_("Show ceiling in red"));
button = gtk_check_button_new_with_label(_("Show dc reported ceiling in red"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), prefs.profile_red_ceiling);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(red_ceiling_toggle), NULL);
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);
g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(calc_ceiling_toggle), NULL);
gtk_widget_show_all(dialog);
result = gtk_dialog_run(GTK_DIALOG(dialog));
if (result == GTK_RESPONSE_ACCEPT) {
@ -817,6 +823,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
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(prefs.profile_red_ceiling));
subsurface_set_conf("calcceiling", PREF_BOOL, BOOL_TO_PTR(prefs.profile_calc_ceiling));
new_default = strdup(gtk_button_get_label(GTK_BUTTON(xmlfile_button)));
@ -1236,6 +1243,7 @@ void init_ui(int *argcp, char ***argvp)
free((void *)conf_value);
}
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));
divelist_font = subsurface_get_conf("divelist_font", PREF_STRING);
default_filename = subsurface_get_conf("default_filename", PREF_STRING);

View file

@ -78,7 +78,7 @@ typedef enum {
TEXT_BACKGROUND, ALERT_BG, ALERT_FG, EVENTS, SAMPLE_DEEP, SAMPLE_SHALLOW,
SMOOTHED, MINUTE, TIME_GRID, TIME_TEXT, DEPTH_GRID, MEAN_DEPTH, DEPTH_TOP,
DEPTH_BOTTOM, TEMP_TEXT, TEMP_PLOT, SAC_DEFAULT, BOUNDING_BOX, PRESSURE_TEXT, BACKGROUND,
CEILING_SHALLOW, CEILING_DEEP
CEILING_SHALLOW, CEILING_DEEP, CALC_CEILING_SHALLOW, CALC_CEILING_DEEP
} color_indice_t;
typedef struct {
@ -136,6 +136,8 @@ static const color_t profile_color[] = {
[BACKGROUND] = {{SPRINGWOOD1, BLACK1_LOW_TRANS}},
[CEILING_SHALLOW] = {{REDORANGE1_HIGH_TRANS, REDORANGE1_HIGH_TRANS}},
[CEILING_DEEP] = {{RED1_MED_TRANS, RED1_MED_TRANS}},
[CALC_CEILING_SHALLOW] = {{FUNGREEN1_HIGH_TRANS, FUNGREEN1_HIGH_TRANS}},
[CALC_CEILING_DEEP] = {{APPLE1_HIGH_TRANS, APPLE1_HIGH_TRANS}},
};
@ -807,6 +809,24 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi
cairo_close_path(gc->cr);
cairo_fill(gc->cr);
}
/* finally, plot the calculated ceiling over all this */
if (prefs.profile_calc_ceiling) {
pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
pattern_add_color_stop_rgba (gc, pat, 0, CALC_CEILING_SHALLOW);
pattern_add_color_stop_rgba (gc, pat, 1, CALC_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->ceiling)
line_to(gc, entry->sec, entry->ceiling);
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);