enum {MIDDLE,TOP,BOTTOM} valign;
} text_render_options_t;
-static void plot_text(struct graphics_context *gc, text_render_options_t *tro,
+static void plot_text(struct graphics_context *gc, const text_render_options_t *tro,
double x, double y, const char *fmt, ...)
{
cairo_t *cr = gc->cr;
cairo_show_text(cr, buffer);
}
+static void render_depth_sample(struct graphics_context *gc, struct sample *sample, const text_render_options_t *tro)
+{
+ int sec = sample->time.seconds;
+ depth_t depth = sample->depth;
+ const char *fmt;
+ double d;
+
+ switch (output_units.length) {
+ case METERS:
+ d = depth.mm / 1000.0;
+ fmt = "%.1f";
+ break;
+ case FEET:
+ d = to_feet(depth);
+ fmt = "%.0f";
+ break;
+ }
+ plot_text(gc, tro, sec, depth.mm, fmt, d);
+}
+
/*
* Find the next minimum/maximum point.
*
result = NULL;
for (;;) {
- int time, depth;
+ int depth;
sample++;
if (sample >= end)
return NULL;
- time = sample->time.seconds;
depth = sample->depth.mm;
if (minmax) {
return result;
}
-static void render_depth_sample(struct graphics_context *gc, struct sample *sample)
-{
- text_render_options_t tro = {14, 1.0, 0.2, 0.2, CENTER, TOP};
- int sec = sample->time.seconds;
- depth_t depth = sample->depth;
- const char *fmt;
- double d;
-
- switch (output_units.length) {
- case METERS:
- d = depth.mm / 1000.0;
- fmt = "%.1f";
- break;
- case FEET:
- d = to_feet(depth);
- fmt = "%.0f";
- break;
- }
- plot_text(gc, &tro, sec, depth.mm, fmt, d);
-}
-
static void plot_text_samples(struct graphics_context *gc, struct sample *a, struct sample *b)
{
+ static const text_render_options_t deep = {14, 1.0, 0.2, 0.2, CENTER, TOP};
+ static const text_render_options_t shallow = {14, 1.0, 0.2, 0.2, CENTER, BOTTOM};
+
for (;;) {
if (b <= a)
break;
a = next_minmax(a, b, 1);
if (!a)
- return;
- render_depth_sample(gc, a);
+ break;
+ render_depth_sample(gc, a, &deep);
a = next_minmax(a, b, 0);
if (!a)
break;
+ if (a->depth.mm < 2500)
+ continue;
+ render_depth_sample(gc, a, &shallow);
}
}