diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-22 21:15:36 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-22 21:15:36 -0700 |
commit | bd0f2747717d55a8c6d21cb37cb746d71cb42fea (patch) | |
tree | e8d4f9727925318a8142997e9adef5c26e1f2b3f | |
parent | 1e42dc10e5df52822fff698573cae97b2efb3220 (diff) | |
download | subsurface-bd0f2747717d55a8c6d21cb37cb746d71cb42fea.tar.gz |
Show events on the dive profile
This is *really* ugly. We really should just create some kind of widget
that when moused over will show the event. Or something. Rather than
putting text on top of other text: the events - when they happen - are
usually bunched together (PO2 warnings, max depth, fast ascent leading
to mandatory safety stop, you name it).
But at least this way we see that the data is there, even if we see it
in ugly ways.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | profile.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -156,6 +156,33 @@ static void plot_text(struct graphics_context *gc, const text_render_options_t * cairo_show_text(cr, buffer); } +static void plot_one_event(struct graphics_context *gc, struct plot_info *pi, struct event *event, const text_render_options_t *tro) +{ + int i, depth = 0; + + for (i = 0; i < pi->nr; i++) { + struct plot_data *data = pi->entry + i; + if (event->time.seconds < data->sec) + break; + depth = data->val; + } + plot_text(gc, tro, event->time.seconds, depth, "%s", event->name); +} + +static void plot_events(struct graphics_context *gc, struct plot_info *pi, struct dive *dive) +{ + static const text_render_options_t tro = {14, 1.0, 0.2, 0.2, CENTER, TOP}; + struct event *event = dive->events; + + if (gc->printer) + return; + + while (event) { + plot_one_event(gc, pi, event, &tro); + event = event->next; + } +} + static void render_depth_sample(struct graphics_context *gc, struct plot_data *entry, const text_render_options_t *tro) { int sec = entry->sec, decimals; @@ -715,6 +742,7 @@ void plot(struct graphics_context *gc, int w, int h, struct dive *dive) /* Depth profile */ plot_depth_profile(gc, pi); + plot_events(gc, pi, dive); /* Text on top of all graphs.. */ plot_temperature_text(gc, pi); |