From 7db08ae1283bab866931fef8f9820366e6b66b5d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 10 Nov 2012 09:23:19 +0100 Subject: Instead of the ugly red boxes make the surface come down to ceiling Based on suggestions from Linus (and a few iterations) we now simply have the surface (i.e., background color / pattern) come down to where the ceiling is. And we only do the angry red shading when the diver violates the ceiling. I think this looks much better. Signed-off-by: Dirk Hohndel --- profile.c | 60 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/profile.c b/profile.c index c6ab46649..e20527986 100644 --- a/profile.c +++ b/profile.c @@ -843,7 +843,6 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi struct plot_data *entry; int maxtime, maxdepth, marker; int increments[8] = { 10, 20, 30, 60, 5*60, 10*60, 15*60, 30*60 }; - gboolean plotting = FALSE; /* Get plot scaling limits */ maxtime = get_maxtime(pi); @@ -935,8 +934,37 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi move_to(gc, 0, 0); for (i = 0; i < pi->nr; i++, entry++) line_to(gc, entry->sec, entry->depth); + + /* Show any ceiling we may have encountered */ + for (i = pi->nr - 1; i >= 0; i--, entry--) { + if (entry->ceiling < entry->depth) { + line_to(gc, entry->sec, entry->ceiling); + } else { + line_to(gc, entry->sec, entry->depth); + } + } 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); + 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++) + line_to(gc, entry->sec, entry->depth); + + for (i = pi->nr - 1; i >= 0; i--, entry--) { + if (entry->ceiling > entry->depth) { + line_to(gc, entry->sec, entry->ceiling); + } else { + line_to(gc, entry->sec, entry->depth); + } + } + cairo_close_path(gc->cr); cairo_fill(gc->cr); /* Now do it again for the velocity colors */ @@ -953,36 +981,6 @@ static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi line_to(gc, sec, depth); cairo_stroke(cr); } - - /* now on top of this the ceiling plot */ - entry = pi->entry; - pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale); - pattern_add_color_stop_rgba (gc, pat, 0.5, CEILING_DEEP); - pattern_add_color_stop_rgba (gc, pat, 0, CEILING_SHALLOW); - cairo_set_source(gc->cr, pat); - cairo_pattern_destroy(pat); - cairo_set_line_width_scaled(gc->cr, 2); - for (i = 0; i < pi->nr; i++, entry++) { - if (entry->ceiling > 0) { - if (!plotting) { - move_to(gc, entry->sec, 0); - plotting = TRUE; - } - line_to(gc, entry->sec, entry->ceiling); - } else { - if (plotting) { - line_to(gc, entry->sec, 0); - cairo_close_path(gc->cr); - cairo_fill(gc->cr); - plotting = FALSE; - } - } - } - if (plotting) { - line_to(gc, entry->sec, 0); - cairo_close_path(gc->cr); - cairo_fill(gc->cr); - } } static int setup_temperature_limits(struct graphics_context *gc, struct plot_info *pi) -- cgit v1.2.3-70-g09d2