Ok, this is pretty much it now. Instead of having various random checks
for "is the time of the sample past the end of the dive" hacks, we not
plot all graphs from the cleaned-up plot_info structure instead of the
raw samples.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
plot_single_temp_text(gc, last, last_temperature);
}
plot_single_temp_text(gc, last, last_temperature);
}
-static void plot_temperature_profile(struct dive *dive, struct graphics_context *gc,
- struct plot_info *pi)
+static void plot_temperature_profile(struct graphics_context *gc, struct plot_info *pi)
{
int i;
cairo_t *cr = gc->cr;
{
int i;
cairo_t *cr = gc->cr;
return;
set_source_rgba(gc, 0.2, 0.2, 1.0, 0.8);
return;
set_source_rgba(gc, 0.2, 0.2, 1.0, 0.8);
- for (i = 0; i < dive->samples; i++) {
- struct sample *sample = dive->sample+i;
- if (sample->time.seconds > dive->duration.seconds)
- break; /* let's not plot surface temp events */
- int mkelvin = sample->temperature.mkelvin;
+ for (i = 0; i < pi->nr; i++) {
+ struct plot_data *entry = pi->entry + i;
+ int mkelvin = entry->temperature;
+ int sec = entry->sec;
if (!mkelvin) {
if (!last)
continue;
mkelvin = last;
}
if (last)
if (!mkelvin) {
if (!last)
continue;
mkelvin = last;
}
if (last)
- line_to(gc, sample->time.seconds, mkelvin);
+ line_to(gc, sec, mkelvin);
- move_to(gc, sample->time.seconds, mkelvin);
+ move_to(gc, sec, mkelvin);
last = mkelvin;
}
cairo_stroke(cr);
last = mkelvin;
}
cairo_stroke(cr);
return pi->maxpressure != 0;
}
return pi->maxpressure != 0;
}
-static void plot_cylinder_pressure(struct dive *dive, struct graphics_context *gc, struct plot_info *pi)
+static void plot_cylinder_pressure(struct graphics_context *gc, struct plot_info *pi)
if (!get_cylinder_pressure_range(gc, pi))
return;
cairo_set_source_rgba(gc->cr, 0.2, 1.0, 0.2, 0.80);
if (!get_cylinder_pressure_range(gc, pi))
return;
cairo_set_source_rgba(gc->cr, 0.2, 1.0, 0.2, 0.80);
- move_to(gc, 0, dive->cylinder[0].start.mbar);
- for (i = 1; i < dive->samples; i++) {
+ move_to(gc, 0, pi->maxpressure);
+ for (i = 1; i < pi->nr; i++) {
- struct sample *sample = dive->sample + i;
+ struct plot_data *entry = pi->entry + i;
- mbar = sample->cylinderpressure.mbar;
+ mbar = entry->pressure;
- sec = sample->time.seconds;
- if (sec <= dive->duration.seconds)
- line_to(gc, sec, mbar);
+ line_to(gc, entry->sec, mbar);
- /*
- * We may have "surface time" events, in which case we don't go
- * back to dive duration
- */
- if (sec < dive->duration.seconds)
- line_to(gc, dive->duration.seconds, dive->cylinder[0].end.mbar);
+ line_to(gc, pi->maxtime, pi->minpressure);
gc->maxy = (h - 2*topy);
/* Temperature profile */
gc->maxy = (h - 2*topy);
/* Temperature profile */
- plot_temperature_profile(dive, gc, pi);
+ plot_temperature_profile(gc, pi);
/* Cylinder pressure plot */
/* Cylinder pressure plot */
- plot_cylinder_pressure(dive, gc, pi);
+ plot_cylinder_pressure(gc, pi);
/* Depth profile */
plot_depth_profile(gc, pi);
/* Depth profile */
plot_depth_profile(gc, pi);