summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-10-19 09:47:46 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-10-19 09:47:46 -0700
commit0a33d0bd7d52c1bee6307926ff25d4037fb0e3aa (patch)
treeb5c672dc68ce3088a46f58cd4e9a7680dd65095a /profile.c
parent9dce78c89fe77a107af7a8c962da19780485c3e2 (diff)
downloadsubsurface-0a33d0bd7d52c1bee6307926ff25d4037fb0e3aa.tar.gz
Start some rough multi-cylinder pressure data plot infrastructure
It doesn't actually do multiple cylinders correctly yet, but it should be a nice framework for it. And accidentally (not) it also ends up drawing the final line for the end pressure of a single-cylinder dive that has been fixed up by hand too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/profile.c b/profile.c
index bc78ac3b4..10692535f 100644
--- a/profile.c
+++ b/profile.c
@@ -25,6 +25,7 @@ struct plot_info {
int endpressure; /* start pressure better be max pressure */
int mintemp, maxtemp;
struct plot_data {
+ unsigned int same_cylinder:1;
int sec;
int pressure, temperature;
/* Depth info */
@@ -496,8 +497,7 @@ static void plot_cylinder_pressure(struct graphics_context *gc, struct plot_info
set_source_rgba(gc, 0.2, 1.0, 0.2, 0.80);
- move_to(gc, 0, pi->maxpressure);
- for (i = 1; i < pi->nr; i++) {
+ for (i = 0; i < pi->nr; i++) {
int mbar;
struct plot_data *entry = pi->entry + i;
@@ -505,7 +505,10 @@ static void plot_cylinder_pressure(struct graphics_context *gc, struct plot_info
if (!mbar)
continue;
have_pressure = TRUE;
- line_to(gc, entry->sec, mbar);
+ if (entry->same_cylinder)
+ line_to(gc, entry->sec, mbar);
+ else
+ move_to(gc, 0, pi->maxpressure);
}
/* if we have valid samples, we don't want to draw a line to the minpressure
* but just end wherever the dive ended (think valve shutdowns during dive)
@@ -691,6 +694,7 @@ static struct plot_info *analyze_plot_info(struct plot_info *pi)
*/
static struct plot_info *create_plot_info(struct dive *dive)
{
+ int cylinderindex = -1;
int lastdepth, lastindex;
int i, nr = dive->samples + 4, sec;
size_t alloc_size = plot_info_size(nr);
@@ -711,6 +715,9 @@ static struct plot_info *create_plot_info(struct dive *dive)
sec = entry->sec = sample->time.seconds;
depth = entry->val = sample->depth.mm;
+
+ entry->same_cylinder = sample->cylinderindex == cylinderindex;
+ cylinderindex = sample->cylinderindex;
entry->pressure = sample->cylinderpressure.mbar;
entry->temperature = sample->temperature.mkelvin;
@@ -727,6 +734,10 @@ static struct plot_info *create_plot_info(struct dive *dive)
i = dive->samples + 2;
pi->entry[i].sec = sec + 20;
pi->entry[i+1].sec = sec + 40;
+ if (cylinderindex >= 0) {
+ pi->entry[i].pressure = dive->cylinder[cylinderindex].end.mbar;
+ pi->entry[i].same_cylinder = 1;
+ }
pi->nr = lastindex+1;
pi->maxtime = pi->entry[lastindex].sec;