mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Reworked the calculate_max_limits and plotted the dive.
Created a new version of calculate_max_limits that doesn't have a graphics_context and returns a plot_info. The code is basically the same as the old calculate_max_limits, so there's not much to talk about. The rest of the code is just boilerplate to plug the Profile code with the axis and model stuff, to be plotted on screen. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
52064d9e02
commit
dd64f1792d
3 changed files with 104 additions and 1 deletions
61
profile.c
61
profile.c
|
@ -717,6 +717,67 @@ static void check_gas_change_events(struct dive *dive, struct divecomputer *dc,
|
|||
set_cylinder_index(pi, i, cylinderindex, ~0u);
|
||||
}
|
||||
|
||||
|
||||
struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer *dc)
|
||||
{
|
||||
struct plot_info pi;
|
||||
int maxdepth = dive->maxdepth.mm;
|
||||
int maxtime = 0;
|
||||
int maxpressure = 0, minpressure = INT_MAX;
|
||||
int mintemp = dive->mintemp.mkelvin;
|
||||
int maxtemp = dive->maxtemp.mkelvin;
|
||||
int cyl;
|
||||
|
||||
/* Get the per-cylinder maximum pressure if they are manual */
|
||||
for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
||||
unsigned int mbar = dive->cylinder[cyl].start.mbar;
|
||||
if (mbar > maxpressure)
|
||||
maxpressure = mbar;
|
||||
}
|
||||
|
||||
/* Then do all the samples from all the dive computers */
|
||||
do {
|
||||
int i = dc->samples;
|
||||
int lastdepth = 0;
|
||||
struct sample *s = dc->sample;
|
||||
|
||||
while (--i >= 0) {
|
||||
int depth = s->depth.mm;
|
||||
int pressure = s->cylinderpressure.mbar;
|
||||
int temperature = s->temperature.mkelvin;
|
||||
|
||||
if (!mintemp && temperature < mintemp)
|
||||
mintemp = temperature;
|
||||
if (temperature > maxtemp)
|
||||
maxtemp = temperature;
|
||||
|
||||
if (pressure && pressure < minpressure)
|
||||
minpressure = pressure;
|
||||
if (pressure > maxpressure)
|
||||
maxpressure = pressure;
|
||||
|
||||
if (depth > maxdepth)
|
||||
maxdepth = s->depth.mm;
|
||||
if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD) &&
|
||||
s->time.seconds > maxtime)
|
||||
maxtime = s->time.seconds;
|
||||
lastdepth = depth;
|
||||
s++;
|
||||
}
|
||||
} while ((dc = dc->next) != NULL);
|
||||
|
||||
if (minpressure > maxpressure)
|
||||
minpressure = 0;
|
||||
|
||||
pi.maxdepth = maxdepth;
|
||||
pi.maxtime = maxtime;
|
||||
pi.maxpressure = maxpressure;
|
||||
pi.minpressure = minpressure;
|
||||
pi.mintemp = mintemp;
|
||||
pi.maxtemp = maxtemp;
|
||||
return pi;
|
||||
}
|
||||
|
||||
void calculate_max_limits(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc)
|
||||
{
|
||||
struct plot_info *pi;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue