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(-) 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