summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2011-09-06 16:44:20 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-06 18:37:57 -0700
commita5a3cba574d5f4a742f57eef590c44da6355d6f6 (patch)
tree920a5a75c52c31db555d877851bee0d888f02be6
parentd314b053014bf74b59050d99516527dced75d483 (diff)
downloadsubsurface-a5a3cba574d5f4a742f57eef590c44da6355d6f6.tar.gz
Fix drawing artifacts with dives that have samples past the dive duration
The UEMIS Zurich SDA keeps recording samples for quite a while after the dive ended. These provide no additional information, but confuse our drawing algorithm as they can cause us to draw both the depth and tank pressure plots beyond the right edge of our canvas. Stop drawing if sample->time.seconds is larger than dive->duration.seconds. Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--profile.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/profile.c b/profile.c
index 3fb0735ba..b1c98bcd5 100644
--- a/profile.c
+++ b/profile.c
@@ -197,11 +197,13 @@ static void plot_depth_profile(struct dive *dive, cairo_t *cr,
for (i = 1; i < dive->samples; i++) {
sample++;
sec = sample->time.seconds;
- depth = to_feet(sample->depth);
- cairo_line_to(cr, SCALE(sec, depth));
+ if (sec <= maxtime) {
+ depth = to_feet(sample->depth);
+ cairo_line_to(cr, SCALE(sec, depth));
+ }
}
scaley = 1.0;
- cairo_line_to(cr, SCALE(sec, 0));
+ cairo_line_to(cr, SCALE(MIN(sec,maxtime), 0));
cairo_line_to(cr, SCALE(begins, 0));
cairo_close_path(cr);
cairo_set_source_rgba(cr, 1, 0.2, 0.2, 0.20);
@@ -269,7 +271,8 @@ static void plot_cylinder_pressure(struct dive *dive, cairo_t *cr,
if (!mbar)
continue;
sec = sample->time.seconds;
- cairo_line_to(cr, SCALE(sec, mbar));
+ if (sec <= dive->duration.seconds)
+ cairo_line_to(cr, SCALE(sec, mbar));
}
/*
* We may have "surface time" events, in which case we don't go