mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Use plot_info for final remaining temperature and pressure data plots too
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>
This commit is contained in:
parent
82f143d229
commit
ec97a62f34
1 changed files with 17 additions and 26 deletions
43
profile.c
43
profile.c
|
@ -369,8 +369,7 @@ static void plot_temperature_text(struct graphics_context *gc, struct plot_info
|
||||||
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,
|
static void plot_temperature_profile(struct graphics_context *gc, struct plot_info *pi)
|
||||||
struct plot_info *pi)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
cairo_t *cr = gc->cr;
|
cairo_t *cr = gc->cr;
|
||||||
|
@ -380,20 +379,19 @@ static void plot_temperature_profile(struct dive *dive, struct graphics_context
|
||||||
return;
|
return;
|
||||||
|
|
||||||
set_source_rgba(gc, 0.2, 0.2, 1.0, 0.8);
|
set_source_rgba(gc, 0.2, 0.2, 1.0, 0.8);
|
||||||
for (i = 0; i < dive->samples; i++) {
|
for (i = 0; i < pi->nr; i++) {
|
||||||
struct sample *sample = dive->sample+i;
|
struct plot_data *entry = pi->entry + i;
|
||||||
if (sample->time.seconds > dive->duration.seconds)
|
int mkelvin = entry->temperature;
|
||||||
break; /* let's not plot surface temp events */
|
int sec = entry->sec;
|
||||||
int mkelvin = sample->temperature.mkelvin;
|
|
||||||
if (!mkelvin) {
|
if (!mkelvin) {
|
||||||
if (!last)
|
if (!last)
|
||||||
continue;
|
continue;
|
||||||
mkelvin = last;
|
mkelvin = last;
|
||||||
}
|
}
|
||||||
if (last)
|
if (last)
|
||||||
line_to(gc, sample->time.seconds, mkelvin);
|
line_to(gc, sec, mkelvin);
|
||||||
else
|
else
|
||||||
move_to(gc, sample->time.seconds, mkelvin);
|
move_to(gc, sec, mkelvin);
|
||||||
last = mkelvin;
|
last = mkelvin;
|
||||||
}
|
}
|
||||||
cairo_stroke(cr);
|
cairo_stroke(cr);
|
||||||
|
@ -409,33 +407,26 @@ static int get_cylinder_pressure_range(struct graphics_context *gc, struct plot_
|
||||||
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)
|
||||||
{
|
{
|
||||||
int i, sec = -1;
|
int i;
|
||||||
|
|
||||||
if (!get_cylinder_pressure_range(gc, pi))
|
if (!get_cylinder_pressure_range(gc, pi))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cairo_set_source_rgba(gc->cr, 0.2, 1.0, 0.2, 0.80);
|
cairo_set_source_rgba(gc->cr, 0.2, 1.0, 0.2, 0.80);
|
||||||
|
|
||||||
move_to(gc, 0, dive->cylinder[0].start.mbar);
|
move_to(gc, 0, pi->maxpressure);
|
||||||
for (i = 1; i < dive->samples; i++) {
|
for (i = 1; i < pi->nr; i++) {
|
||||||
int mbar;
|
int mbar;
|
||||||
struct sample *sample = dive->sample + i;
|
struct plot_data *entry = pi->entry + i;
|
||||||
|
|
||||||
mbar = sample->cylinderpressure.mbar;
|
mbar = entry->pressure;
|
||||||
if (!mbar)
|
if (!mbar)
|
||||||
continue;
|
continue;
|
||||||
sec = sample->time.seconds;
|
line_to(gc, entry->sec, mbar);
|
||||||
if (sec <= dive->duration.seconds)
|
|
||||||
line_to(gc, sec, mbar);
|
|
||||||
}
|
}
|
||||||
/*
|
line_to(gc, pi->maxtime, pi->minpressure);
|
||||||
* 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);
|
|
||||||
cairo_stroke(gc->cr);
|
cairo_stroke(gc->cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,10 +695,10 @@ void plot(struct graphics_context *gc, int w, int h, struct dive *dive)
|
||||||
gc->maxy = (h - 2*topy);
|
gc->maxy = (h - 2*topy);
|
||||||
|
|
||||||
/* Temperature profile */
|
/* 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 */
|
/* Depth profile */
|
||||||
plot_depth_profile(gc, pi);
|
plot_depth_profile(gc, pi);
|
||||||
|
|
Loading…
Reference in a new issue