mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Clean up type handling of cylinder pressure plot
Soon we'll show things in psi or bar depending on user choice. Let's not get confused about units before we do. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
05857e0a05
commit
75cb94f067
1 changed files with 17 additions and 18 deletions
35
profile.c
35
profile.c
|
@ -214,18 +214,17 @@ static void plot_depth_profile(struct dive *dive, cairo_t *cr,
|
||||||
|
|
||||||
/* gets both the actual start and end pressure as well as the scaling factors */
|
/* gets both the actual start and end pressure as well as the scaling factors */
|
||||||
static int get_cylinder_pressure_range(struct dive *dive, double *scalex, double *scaley,
|
static int get_cylinder_pressure_range(struct dive *dive, double *scalex, double *scaley,
|
||||||
double *startp, double *endp)
|
pressure_t *startp, pressure_t *endp)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
double min, max;
|
int min, max, mbar;
|
||||||
double bar;
|
|
||||||
|
|
||||||
*scalex = round_seconds_up(dive->duration.seconds);
|
*scalex = round_seconds_up(dive->duration.seconds);
|
||||||
|
|
||||||
max = 0;
|
max = 0;
|
||||||
min = 5000;
|
min = 5000000;
|
||||||
if (startp)
|
if (startp)
|
||||||
*startp = *endp = 0.0;
|
startp->mbar = endp->mbar = 0;
|
||||||
|
|
||||||
for (i = 0; i < dive->samples; i++) {
|
for (i = 0; i < dive->samples; i++) {
|
||||||
struct sample *sample = dive->sample + i;
|
struct sample *sample = dive->sample + i;
|
||||||
|
@ -233,18 +232,18 @@ static int get_cylinder_pressure_range(struct dive *dive, double *scalex, double
|
||||||
/* FIXME! We only track cylinder 0 right now */
|
/* FIXME! We only track cylinder 0 right now */
|
||||||
if (sample->cylinderindex)
|
if (sample->cylinderindex)
|
||||||
continue;
|
continue;
|
||||||
if (!sample->cylinderpressure.mbar)
|
mbar = sample->cylinderpressure.mbar;
|
||||||
|
if (!mbar)
|
||||||
continue;
|
continue;
|
||||||
bar = sample->cylinderpressure.mbar;
|
if (mbar && startp && !startp->mbar)
|
||||||
if (bar != 0.0 && startp && *startp == 0.0)
|
startp->mbar = mbar;
|
||||||
*startp = bar;
|
if (mbar < min)
|
||||||
if (bar < min)
|
min = mbar;
|
||||||
min = bar;
|
if (mbar > max)
|
||||||
if (bar > max)
|
max = mbar;
|
||||||
max = bar;
|
|
||||||
}
|
}
|
||||||
if (endp)
|
if (endp)
|
||||||
*endp = bar;
|
endp->mbar = mbar;
|
||||||
if (!max)
|
if (!max)
|
||||||
return 0;
|
return 0;
|
||||||
*scaley = max * 1.5;
|
*scaley = max * 1.5;
|
||||||
|
@ -332,16 +331,16 @@ static void plot_cylinder_pressure_text(struct dive *dive, cairo_t *cr,
|
||||||
double maxx, double maxy)
|
double maxx, double maxy)
|
||||||
{
|
{
|
||||||
double scalex, scaley;
|
double scalex, scaley;
|
||||||
double startp,endp;
|
pressure_t startp, endp;
|
||||||
|
|
||||||
cairo_set_font_size(cr, 10);
|
cairo_set_font_size(cr, 10);
|
||||||
|
|
||||||
if (get_cylinder_pressure_range(dive, &scalex, &scaley,
|
if (get_cylinder_pressure_range(dive, &scalex, &scaley,
|
||||||
&startp, &endp)) {
|
&startp, &endp)) {
|
||||||
text_render_options_t tro = {0.2, 1.0, 0.2, LEFT};
|
text_render_options_t tro = {0.2, 1.0, 0.2, LEFT};
|
||||||
plot_text(cr, &tro, SCALE(0, startp), "%3.0f bar", startp/1000.0);
|
plot_text(cr, &tro, SCALE(0, startp.mbar), "%3.0f bar", startp.mbar/1000.0);
|
||||||
plot_text(cr, &tro, SCALE(dive->duration.seconds, endp),
|
plot_text(cr, &tro, SCALE(dive->duration.seconds, endp.mbar),
|
||||||
"%3.0f bar", endp/1000.0);
|
"%3.0f bar", endp.mbar/1000.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue