diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-02-08 20:44:04 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-08 20:44:04 -0800 |
commit | 15112712019817e4e64b5c35b7bb38315125e920 (patch) | |
tree | d09295d8284cb8978815d6b38784341fee636e10 | |
parent | b8c7992bbfe03dce665cbd5ba6144b0c8b59b6fd (diff) | |
download | subsurface-15112712019817e4e64b5c35b7bb38315125e920.tar.gz |
Add maxdepth back to the dive structure
Populate during dive fixup as the maximum depth shown by all the
divecomputers. Use this value (instead of the one in the first
divecomputer) in printing, statistics, etc.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | dive.c | 3 | ||||
-rw-r--r-- | dive.h | 1 | ||||
-rw-r--r-- | divelist.c | 10 | ||||
-rw-r--r-- | print.c | 4 | ||||
-rw-r--r-- | profile.c | 6 | ||||
-rw-r--r-- | statistics.c | 12 |
6 files changed, 19 insertions, 17 deletions
@@ -626,7 +626,8 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc) update_depth(&dc->meandepth, depthtime); update_temperature(&dc->watertemp, mintemp); update_depth(&dc->maxdepth, maxdepth); - + if (maxdepth > dive->maxdepth.mm) + dive->maxdepth.mm = maxdepth; fixup_dc_events(dc); } @@ -321,6 +321,7 @@ struct dive { /* Calculated based on dive computer data */ temperature_t mintemp, maxtemp; + depth_t maxdepth; pressure_t surface_pressure; int salinity; // kg per 10000 l diff --git a/divelist.c b/divelist.c index 417cb1b77..7d887d353 100644 --- a/divelist.c +++ b/divelist.c @@ -55,7 +55,7 @@ enum { DIVE_NR, /* int: dive->nr */ DIVE_DATE, /* timestamp_t: dive->when */ DIVE_RATING, /* int: 0-5 stars */ - DIVE_DEPTH, /* int: dive->dc.maxdepth in mm */ + DIVE_DEPTH, /* int: dive->maxdepth in mm */ DIVE_DURATION, /* int: in seconds */ DIVE_TEMPERATURE, /* int: in mkelvin */ DIVE_TOTALWEIGHT, /* int: in grams */ @@ -1317,7 +1317,7 @@ static void fill_dive_list(void) DIVE_INDEX, i, DIVE_NR, dive->number, DIVE_DATE, dive->when, - DIVE_DEPTH, dive->dc.maxdepth, + DIVE_DEPTH, dive->maxdepth, DIVE_DURATION, get_duration_in_sec(dive), DIVE_LOCATION, dive->location, DIVE_LOC_ICON, icon, @@ -1330,7 +1330,7 @@ static void fill_dive_list(void) DIVE_INDEX, i, DIVE_NR, dive->number, DIVE_DATE, dive->when, - DIVE_DEPTH, dive->dc.maxdepth, + DIVE_DEPTH, dive->maxdepth, DIVE_DURATION, get_duration_in_sec(dive), DIVE_LOCATION, dive->location, DIVE_LOC_ICON, icon, @@ -1673,7 +1673,7 @@ static int copy_tree_node(GtkTreeIter *a, GtkTreeIter *b) DIVE_NR, &store_dive.number, DIVE_DATE, &store_dive.when, DIVE_RATING, &store_dive.rating, - DIVE_DEPTH, &store_dive.dc.maxdepth, + DIVE_DEPTH, &store_dive.maxdepth, DIVE_DURATION, &store_dive.dc.duration, DIVE_TEMPERATURE, &store_dive.dc.watertemp.mkelvin, DIVE_TOTALWEIGHT, &totalweight, @@ -1690,7 +1690,7 @@ static int copy_tree_node(GtkTreeIter *a, GtkTreeIter *b) DIVE_NR, store_dive.number, DIVE_DATE, store_dive.when, DIVE_RATING, store_dive.rating, - DIVE_DEPTH, store_dive.dc.maxdepth, + DIVE_DEPTH, store_dive.maxdepth, DIVE_DURATION, store_dive.dc.duration, DIVE_TEMPERATURE, store_dive.dc.watertemp.mkelvin, DIVE_TOTALWEIGHT, totalweight, @@ -97,7 +97,7 @@ static void show_dive_header(struct dive *dive, cairo_t *cr, double w, people = ""; } - depth = get_depth_units(dive->dc.maxdepth.mm, &decimals, &unit); + depth = get_depth_units(dive->maxdepth.mm, &decimals, &unit); snprintf(buffer, sizeof(buffer), _("Max depth: %.*f %s\nDuration: %d min\n%s"), decimals, depth, unit, @@ -585,7 +585,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w, curwidth = curwidth + colwidth; // Col 3: Depth - depth = get_depth_units(dive->dc.maxdepth.mm, &decimals, &unit); + depth = get_depth_units(dive->maxdepth.mm, &decimals, &unit); len = snprintf(buffer, sizeof(buffer), "%.*f %s", decimals, depth, unit); cairo_move_to(cr, curwidth / PANGO_SCALE, 0); @@ -1543,9 +1543,9 @@ static void calculate_max_limits(struct dive *dive, struct divecomputer *dc, str pi = &gc->pi; memset(pi, 0, sizeof(*pi)); - /* This should probably have been per-dive-computer */ - maxdepth = dive->dc.maxdepth.mm; - mintemp = maxtemp = dive->dc.watertemp.mkelvin; + maxdepth = dive->maxdepth.mm; + mintemp = dive->mintemp.mkelvin; + maxtemp = dive->maxtemp.mkelvin; /* Get the per-cylinder maximum pressure if they are manual */ for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { diff --git a/statistics.c b/statistics.c index c08324d54..5c6777f8a 100644 --- a/statistics.c +++ b/statistics.c @@ -135,10 +135,10 @@ static void process_dive(struct dive *dp, stats_t *stats) stats->longest_time.seconds = duration; if (stats->shortest_time.seconds == 0 || duration < stats->shortest_time.seconds) stats->shortest_time.seconds = duration; - if (dp->dc.maxdepth.mm > stats->max_depth.mm) - stats->max_depth.mm = dp->dc.maxdepth.mm; - if (stats->min_depth.mm == 0 || dp->dc.maxdepth.mm < stats->min_depth.mm) - stats->min_depth.mm = dp->dc.maxdepth.mm; + if (dp->maxdepth.mm > stats->max_depth.mm) + stats->max_depth.mm = dp->maxdepth.mm; + if (stats->min_depth.mm == 0 || dp->maxdepth.mm < stats->min_depth.mm) + stats->min_depth.mm = dp->maxdepth.mm; process_temperatures(dp, stats); @@ -415,7 +415,7 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) memset(&stats, 0, sizeof(stats)); if (dive_table.nr > 0) { stats.shortest_time.seconds = get_duration_in_sec(dive_table.dives[0]); - stats.min_depth.mm = dive_table.dives[0]->dc.maxdepth.mm; + stats.min_depth.mm = dive_table.dives[0]->maxdepth.mm; stats.selection_size = dive_table.nr; } @@ -554,7 +554,7 @@ static void show_single_dive_stats(struct dive *dive) get_time_string(dive->when - (prev_dive->when + get_duration_in_sec(prev_dive)), 4)); else set_label(single_w.surf_intv, _("unknown")); - value = get_depth_units(dive->dc.maxdepth.mm, &decimals, &unit); + value = get_depth_units(dive->maxdepth.mm, &decimals, &unit); set_label(single_w.max_depth, "%.*f %s", decimals, value, unit); value = get_depth_units(dive->dc.meandepth.mm, &decimals, &unit); set_label(single_w.avg_depth, "%.*f %s", decimals, value, unit); |