- set_label(info_stat_w.gas_used, "");
- /* and now do the statistics */
- set_label(info_stat_w.total_time, get_time_string(info_stat.total_time.seconds, 0));
- set_label(info_stat_w.avg_time, get_time_string(info_stat.total_time.seconds / dive_table.nr, 0));
- value = get_depth_units(info_stat.max_depth.mm, &decimals, &unit);
- set_label(info_stat_w.max_overall_depth, "%.*f %s", decimals, value, unit);
- value = get_depth_units(info_stat.avg_depth.mm, &decimals, &unit);
- set_label(info_stat_w.avg_overall_depth, "%.*f %s", decimals, value, unit);
- value = get_volume_units(info_stat.max_sac.mliter, &decimals, &unit);
- set_label(info_stat_w.max_sac, "%.*f %s/min", decimals, value, unit);
- value = get_volume_units(info_stat.min_sac.mliter, &decimals, &unit);
- set_label(info_stat_w.min_sac, "%.*f %s/min", decimals, value, unit);
- value = get_volume_units(info_stat.avg_sac.mliter, &decimals, &unit);
- set_label(info_stat_w.avg_sac, "%.*f %s/min", decimals, value, unit);
+ set_label(single_w.gas_used, "");
+}
+
+static void show_total_dive_stats(struct dive *dive)
+{
+ double value;
+ int decimals;
+ const char *unit;
+ stats_t *stats_ptr;
+
+ if (amount_selected < 2)
+ stats_ptr = &stats;
+ else
+ stats_ptr = &stats_selection;
+
+ set_label(stats_w.selection_size, "%d", stats_ptr->selection_size);
+ if (stats_ptr->min_temp) {
+ value = get_temp_units(stats_ptr->min_temp, &unit);
+ set_label(stats_w.min_temp, "%.1f %s", value, unit);
+ }
+ if (stats_ptr->combined_temp && stats_ptr->combined_count)
+ set_label(stats_w.avg_temp, "%.1f %s", stats_ptr->combined_temp / (stats_ptr->combined_count * 1.0), unit);
+ if (stats_ptr->max_temp) {
+ value = get_temp_units(stats_ptr->max_temp, &unit);
+ set_label(stats_w.max_temp, "%.1f %s", value, unit);
+ }
+ set_label(stats_w.total_time, get_time_string(stats_ptr->total_time.seconds, 0));
+ set_label(stats_w.avg_time, get_time_string(stats_ptr->total_time.seconds / stats_ptr->selection_size, 0));
+ set_label(stats_w.longest_time, get_time_string(stats_ptr->longest_time.seconds, 0));
+ set_label(stats_w.shortest_time, get_time_string(stats_ptr->shortest_time.seconds, 0));
+ value = get_depth_units(stats_ptr->max_depth.mm, &decimals, &unit);
+ set_label(stats_w.max_overall_depth, "%.*f %s", decimals, value, unit);
+ value = get_depth_units(stats_ptr->min_depth.mm, &decimals, &unit);
+ set_label(stats_w.min_overall_depth, "%.*f %s", decimals, value, unit);
+ value = get_depth_units(stats_ptr->avg_depth.mm, &decimals, &unit);
+ set_label(stats_w.avg_overall_depth, "%.*f %s", decimals, value, unit);
+ value = get_volume_units(stats_ptr->max_sac.mliter, &decimals, &unit);
+ set_label(stats_w.max_sac, "%.*f %s/min", decimals, value, unit);
+ value = get_volume_units(stats_ptr->min_sac.mliter, &decimals, &unit);
+ set_label(stats_w.min_sac, "%.*f %s/min", decimals, value, unit);
+ value = get_volume_units(stats_ptr->avg_sac.mliter, &decimals, &unit);
+ set_label(stats_w.avg_sac, "%.*f %s/min", decimals, value, unit);
+}
+
+void show_dive_stats(struct dive *dive)
+{
+ /* they have to be called in this order, as 'total' depends on
+ * calculations done in 'single' */
+ show_single_dive_stats(dive);
+ show_total_dive_stats(dive);