X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=profile.c;h=6f4839d24b48bde55d995ec406bd0532e74af912;hb=28cadad14460ba5702cae1dac7c700f34a9add6d;hp=9443130d29814f50c53f1ed609eea507f5f790d8;hpb=2d9ac73e380ea0863119ddca4c72ea4d96327465;p=ext%2Fsubsurface.git diff --git a/profile.c b/profile.c index 9443130..6f4839d 100644 --- a/profile.c +++ b/profile.c @@ -32,8 +32,8 @@ struct plot_info { int sec; int val; int smoothed; - int min[3]; - int max[3]; + struct plot_data *min[3]; + struct plot_data *max[3]; int avg[3]; } entry[]; }; @@ -234,6 +234,47 @@ static void plot_depth_text(struct dive *dive, struct graphics_context *gc) plot_text_samples(gc, sample, end); } +static void plot_smoothed_profile(struct graphics_context *gc, struct plot_info *pi) +{ + int i; + struct plot_data *entry = pi->entry; + + cairo_set_source_rgba(gc->cr, 1, 0.2, 0.2, 0.20); + move_to(gc, entry->sec, entry->smoothed); + for (i = 1; i < pi->nr; i++) { + entry++; + line_to(gc, entry->sec, entry->smoothed); + } + cairo_stroke(gc->cr); +} + +static void plot_minmax_profile_minute(struct graphics_context *gc, struct plot_info *pi, + int index, double a) +{ + int i; + struct plot_data *entry = pi->entry; + + cairo_set_source_rgba(gc->cr, 1, 0.2, 1, a); + move_to(gc, entry->sec, entry->min[index]->val); + for (i = 1; i < pi->nr; i++) { + entry++; + line_to(gc, entry->sec, entry->min[index]->val); + } + for (i = 1; i < pi->nr; i++) { + line_to(gc, entry->sec, entry->max[index]->val); + entry--; + } + cairo_close_path(gc->cr); + cairo_fill(gc->cr); +} + +static void plot_minmax_profile(struct graphics_context *gc, struct plot_info *pi) +{ + plot_minmax_profile_minute(gc, pi, 2, 0.1); + plot_minmax_profile_minute(gc, pi, 1, 0.1); + plot_minmax_profile_minute(gc, pi, 0, 0.1); +} + static void plot_depth_profile(struct dive *dive, struct graphics_context *gc, struct plot_info *pi) { int i; @@ -279,6 +320,9 @@ static void plot_depth_profile(struct dive *dive, struct graphics_context *gc, s gc->scalex = maxtime; + plot_smoothed_profile(gc, pi); + plot_minmax_profile(gc, pi); + entry = pi->entry; cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.80); begins = entry->sec; @@ -460,8 +504,9 @@ static void analyze_plot_info_minmax_minute(struct plot_data *entry, struct plot { struct plot_data *p = entry; int time = entry->sec; - int seconds = 60*(index+1); - int min, max, avg, nr; + int seconds = 90*(index+1); + struct plot_data *min, *max; + int avg, nr; /* Go back 'seconds' in time */ while (p > first) { @@ -471,7 +516,8 @@ static void analyze_plot_info_minmax_minute(struct plot_data *entry, struct plot } /* Then go forward until we hit an entry past the time */ - min = max = avg = p->val; + min = max = p; + avg = p->val; nr = 1; while (++p < last) { int val = p->val; @@ -479,10 +525,10 @@ static void analyze_plot_info_minmax_minute(struct plot_data *entry, struct plot break; avg += val; nr ++; - if (val < min) - min = val; - if (val > max) - max = val; + if (val < min->val) + min = p; + if (val > max->val) + max = p; } entry->min[index] = min; entry->max[index] = max;