From 1b606ae2260395471890616f8b9dcb16e997fa3d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 1 Nov 2012 10:04:12 -0700 Subject: First stab at plotting a pO2 graph So far this is done unconditionally. This already starts some of the infrastructure for other gases, but so far only O2 is handled. We also need a pressure scale on the right to make this useful - or we need to do peek / trough pressure prints like we do for temperature and depth. Finally, I think I want to move the plot further down, maybe make the whole plot area taller if we are plotting partial gas pressures as well. Signed-off-by: Dirk Hohndel --- display-gtk.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'display-gtk.h') diff --git a/display-gtk.h b/display-gtk.h index f4961b301..879a02b4c 100644 --- a/display-gtk.h +++ b/display-gtk.h @@ -21,6 +21,12 @@ typedef struct { gboolean otu; } visible_cols_t; +typedef struct { + gboolean po2; + gboolean pn2; + gboolean phe; +} enabled_graphs_t; + typedef enum { PREF_BOOL, PREF_STRING -- cgit v1.2.3-70-g09d2 From bdc6b6ba243678e00c3e7f639358ee803ef5d85b Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 1 Nov 2012 11:11:05 -0700 Subject: Change preferences into a notebook and add second page for tec settings Not sure this is the best naming scheme (General Settings / Tec Settings) but it's a start. The idea is to have the settings that a recreational diver might care about on the first page, and all the other stuff on the second one. Let's see how this works out long term. For now I moved OTU over and added toggles for the different partial pressure graphs (only the pO2 one is implemented so far). Signed-off-by: Dirk Hohndel --- display-gtk.h | 1 + gtk-gui.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- profile.c | 5 ++-- 3 files changed, 69 insertions(+), 13 deletions(-) (limited to 'display-gtk.h') diff --git a/display-gtk.h b/display-gtk.h index 879a02b4c..ea4786b67 100644 --- a/display-gtk.h +++ b/display-gtk.h @@ -60,6 +60,7 @@ extern void quit(GtkWidget *w, gpointer data); extern int is_default_dive_computer_device(const char *name); extern visible_cols_t visible_cols; +extern enabled_graphs_t enabled_graphs; extern const char *divelist_font; extern void set_divelist_font(const char *); diff --git a/gtk-gui.c b/gtk-gui.c index fb992f644..e5b35f468 100644 --- a/gtk-gui.c +++ b/gtk-gui.c @@ -36,7 +36,8 @@ struct units output_units; static GtkWidget *dive_profile; -visible_cols_t visible_cols = {TRUE, FALSE}; +visible_cols_t visible_cols = {TRUE, FALSE, }; +enabled_graphs_t enabled_graphs = { FALSE, }; static const char *default_dive_computer_vendor; static const char *default_dive_computer_product; @@ -503,6 +504,9 @@ OPTIONCALLBACK(totalweight_toggle, visible_cols.totalweight) OPTIONCALLBACK(suit_toggle, visible_cols.suit) OPTIONCALLBACK(cylinder_toggle, visible_cols.cylinder) OPTIONCALLBACK(autogroup_toggle, autogroup) +OPTIONCALLBACK(po2_toggle, enabled_graphs.po2) +OPTIONCALLBACK(pn2_toggle, enabled_graphs.pn2) +OPTIONCALLBACK(phe_toggle, enabled_graphs.phe) static void event_toggle(GtkWidget *w, gpointer _data) { @@ -564,7 +568,7 @@ static void pick_default_file(GtkWidget *w, GtkButton *button) static void preferences_dialog(GtkWidget *w, gpointer data) { int result; - GtkWidget *dialog, *font, *frame, *box, *vbox, *button; + GtkWidget *dialog, *notebook, *font, *frame, *box, *vbox, *button; const char *current_default, *new_default; menu_units = output_units; @@ -576,8 +580,15 @@ static void preferences_dialog(GtkWidget *w, gpointer data) GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); + /* create the notebook for the preferences and attach it to dialog */ + notebook = gtk_notebook_new(); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), notebook, FALSE, FALSE, 5); + + /* vbox that holds the first notebook page */ + vbox = gtk_vbox_new(FALSE, 6); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, + gtk_label_new(_("General Settings"))); frame = gtk_frame_new(_("Units")); - vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); box = gtk_vbox_new(FALSE, 6); @@ -609,7 +620,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data) NULL); frame = gtk_frame_new(_("Show Columns")); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); box = gtk_hbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(frame), box); @@ -634,11 +645,6 @@ 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(sac_toggle), NULL); - button = gtk_check_button_new_with_label(_("OTU")); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.otu); - gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); - g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(otu_toggle), NULL); - button = gtk_check_button_new_with_label(_("Weight")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.totalweight); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); @@ -650,13 +656,13 @@ static void preferences_dialog(GtkWidget *w, gpointer data) g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(suit_toggle), NULL); frame = gtk_frame_new(_("Divelist Font")); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); font = gtk_font_button_new_with_font(divelist_font); gtk_container_add(GTK_CONTAINER(frame),font); frame = gtk_frame_new(_("Misc. Options")); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); box = gtk_hbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(frame), box); @@ -675,6 +681,43 @@ static void preferences_dialog(GtkWidget *w, gpointer data) g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(pick_default_file), button); gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); + /* vbox that holds the second notebook page */ + vbox = gtk_vbox_new(FALSE, 6); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox, + gtk_label_new(_("Tec Settings"))); + + frame = gtk_frame_new(_("Show Columns")); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); + + box = gtk_hbox_new(FALSE, 6); + gtk_container_add(GTK_CONTAINER(frame), box); + + button = gtk_check_button_new_with_label(_("OTU")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), visible_cols.otu); + 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")); + gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); + + box = gtk_hbox_new(FALSE, 6); + gtk_container_add(GTK_CONTAINER(frame), box); + + button = gtk_check_button_new_with_label(_("pO" UTF8_SUBSCRIPT_2)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), enabled_graphs.po2); + gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); + g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(po2_toggle), NULL); + + button = gtk_check_button_new_with_label(_("pN" UTF8_SUBSCRIPT_2)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), enabled_graphs.pn2); + gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); + g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(pn2_toggle), NULL); + + button = gtk_check_button_new_with_label(_("pHe")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), enabled_graphs.phe); + gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 6); + g_signal_connect(G_OBJECT(button), "toggled", G_CALLBACK(phe_toggle), NULL); + gtk_widget_show_all(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); if (result == GTK_RESPONSE_ACCEPT) { @@ -696,6 +739,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data) subsurface_set_conf("cuft", PREF_BOOL, BOOL_TO_PTR(output_units.volume == CUFT)); subsurface_set_conf("fahrenheit", PREF_BOOL, BOOL_TO_PTR(output_units.temperature == FAHRENHEIT)); subsurface_set_conf("lbs", PREF_BOOL, BOOL_TO_PTR(output_units.weight == LBS)); + subsurface_set_conf("TEMPERATURE", PREF_BOOL, BOOL_TO_PTR(visible_cols.temperature)); subsurface_set_conf("TOTALWEIGHT", PREF_BOOL, BOOL_TO_PTR(visible_cols.totalweight)); subsurface_set_conf("SUIT", PREF_BOOL, BOOL_TO_PTR(visible_cols.suit)); @@ -703,8 +747,14 @@ static void preferences_dialog(GtkWidget *w, gpointer data) subsurface_set_conf("NITROX", PREF_BOOL, BOOL_TO_PTR(visible_cols.nitrox)); subsurface_set_conf("SAC", PREF_BOOL, BOOL_TO_PTR(visible_cols.sac)); subsurface_set_conf("OTU", PREF_BOOL, BOOL_TO_PTR(visible_cols.otu)); + subsurface_set_conf("divelist_font", PREF_STRING, divelist_font); subsurface_set_conf("autogroup", PREF_BOOL, BOOL_TO_PTR(autogroup)); + + subsurface_set_conf("po2graph", PREF_BOOL, BOOL_TO_PTR(enabled_graphs.po2)); + subsurface_set_conf("pn2graph", PREF_BOOL, BOOL_TO_PTR(enabled_graphs.pn2)); + subsurface_set_conf("phegraph", PREF_BOOL, BOOL_TO_PTR(enabled_graphs.phe)); + new_default = strdup(gtk_button_get_label(GTK_BUTTON(button))); /* if we opened the default file and are changing its name, @@ -1052,6 +1102,10 @@ void init_ui(int *argcp, char ***argvp) visible_cols.otu = PTR_TO_BOOL(subsurface_get_conf("OTU", PREF_BOOL)); visible_cols.sac = PTR_TO_BOOL(subsurface_get_conf("SAC", PREF_BOOL)); + enabled_graphs.po2 = PTR_TO_BOOL(subsurface_get_conf("po2graph", PREF_BOOL)); + enabled_graphs.pn2 = PTR_TO_BOOL(subsurface_get_conf("pn2graph", PREF_BOOL)); + enabled_graphs.phe = PTR_TO_BOOL(subsurface_get_conf("phegraph", 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 7d3a4d5ee..1e6d523f3 100644 --- a/profile.c +++ b/profile.c @@ -11,6 +11,7 @@ #include "dive.h" #include "display.h" +#include "display-gtk.h" #include "divelist.h" #include "color.h" @@ -43,7 +44,7 @@ struct plot_info { /* Depth info */ int depth; int smoothed; - double po2; + double po2, pn2, phe; velocity_t velocity; struct plot_data *min[3]; struct plot_data *max[3]; @@ -1527,7 +1528,7 @@ void plot(struct graphics_context *gc, cairo_rectangle_t *drawing_area, struct d cairo_close_path(gc->cr); cairo_stroke(gc->cr); -// if (graphs_enabled.po2) + if (enabled_graphs.po2) plot_po2_profile(gc, pi); /* now shift the translation back by half the margin; -- cgit v1.2.3-70-g09d2 From 01fd6a57bce4cd501b23481591462161f2ae34d5 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 1 Nov 2012 11:44:18 -0700 Subject: Add vertical space to depth plot if we are showing partial pressure graphs Fairly simplistic change that modifies the way we calculate the "maxdepth" for a particular dive as that is used to scale the plot vertically. Signed-off-by: Dirk Hohndel --- display-gtk.h | 8 +++++--- profile.c | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'display-gtk.h') diff --git a/display-gtk.h b/display-gtk.h index ea4786b67..22ff9d626 100644 --- a/display-gtk.h +++ b/display-gtk.h @@ -27,6 +27,11 @@ typedef struct { gboolean phe; } enabled_graphs_t; +extern visible_cols_t visible_cols; +extern enabled_graphs_t enabled_graphs; + +#define GRAPHS_ENABLED (enabled_graphs.po2 || enabled_graphs.pn2 || enabled_graphs.phe) + typedef enum { PREF_BOOL, PREF_STRING @@ -59,9 +64,6 @@ extern void quit(GtkWidget *w, gpointer data); extern int is_default_dive_computer_device(const char *name); -extern visible_cols_t visible_cols; -extern enabled_graphs_t enabled_graphs; - extern const char *divelist_font; extern void set_divelist_font(const char *); diff --git a/profile.c b/profile.c index 1e6d523f3..d32224190 100644 --- a/profile.c +++ b/profile.c @@ -220,16 +220,28 @@ static int get_maxtime(struct plot_info *pi) } } +/* get the maximum depth to which we want to plot + * take into account the additional verical space needed to plot + * partial pressure graphs */ static int get_maxdepth(struct plot_info *pi) { unsigned mm = pi->maxdepth; + int md; + if (zoomed_plot) { /* Rounded up to 10m, with at least 3m to spare */ - return ROUND_UP(mm+3000, 10000); + md = ROUND_UP(mm+3000, 10000); } else { /* Minimum 30m, rounded up to 10m, with at least 3m to spare */ - return MAX(30000, ROUND_UP(mm+3000, 10000)); + md = MAX(30000, ROUND_UP(mm+3000, 10000)); + } + if (GRAPHS_ENABLED) { + if (md <= 20000) + md += 10000; + else + md += ROUND_UP(md / 3, 10000); } + return md; } typedef struct { -- cgit v1.2.3-70-g09d2