summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk-gui.c2
-rw-r--r--profile.c55
2 files changed, 42 insertions, 15 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 2434a57fc..17cfe9bf5 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1332,7 +1332,7 @@ static gboolean profile_tooltip (GtkWidget *widget, gint x, gint y,
}
get_plot_details(gc, time, plot, sizeof(plot));
- snprintf(buffer, sizeof(buffer), " %d:%02d%c%s%c%s", time / 60, time % 60,
+ snprintf(buffer, sizeof(buffer), "@ %d:%02d%c%s%c%s", time / 60, time % 60,
*plot ? '\n' : ' ', plot,
*event ? '\n' : ' ', event);
gtk_tooltip_set_text(tooltip, buffer);
diff --git a/profile.c b/profile.c
index 700f5d08a..ecec7bb8f 100644
--- a/profile.c
+++ b/profile.c
@@ -2005,33 +2005,60 @@ void plot(struct graphics_context *gc, struct dive *dive, scale_mode_t scale)
}
}
-static void plot_string(struct plot_data *entry, char *buf, size_t bufsize)
+static void plot_string(struct plot_data *entry, char *buf, size_t bufsize, int depth, int pressure, int temp)
{
- int depth_decimals, pressure;
- const char *depth_unit, *pressure_unit;
- double depth;
-
- depth = get_depth_units(entry->depth, &depth_decimals, &depth_unit);
- pressure = get_pressure_units(GET_PRESSURE(entry), &pressure_unit);
-
- snprintf(buf, bufsize, "%.*f %s\n%d %s",
- depth_decimals, depth, depth_unit,
- pressure, pressure_unit);
+ int pressurevalue;
+ const char *depth_unit, *pressure_unit, *temp_unit;
+ char *buf2 = malloc(bufsize);
+ double depthvalue, tempvalue;
+
+ depthvalue = get_depth_units(depth, NULL, &depth_unit);
+ snprintf(buf, bufsize, "D:%.1f %s", depthvalue, depth_unit);
+ if (pressure) {
+ pressurevalue = get_pressure_units(pressure, &pressure_unit);
+ memcpy(buf2, buf, bufsize);
+ snprintf(buf, bufsize, "%s\nP:%d %s", buf2, pressurevalue, pressure_unit);
+ }
+ if (temp) {
+ tempvalue = get_temp_units(temp, &temp_unit);
+ memcpy(buf2, buf, bufsize);
+ snprintf(buf, bufsize, "%s\nT:%.1f %s", buf2, tempvalue, temp_unit);
+ }
+ if (partial_pressure_graphs.po2) {
+ memcpy(buf2, buf, bufsize);
+ snprintf(buf, bufsize, "%s\npO" UTF8_SUBSCRIPT_2 ":%.1f", buf2, entry->po2);
+ }
+ if (partial_pressure_graphs.pn2) {
+ memcpy(buf2, buf, bufsize);
+ snprintf(buf, bufsize, "%s\npN" UTF8_SUBSCRIPT_2 ":%.1f", buf2, entry->pn2);
+ }
+ if (partial_pressure_graphs.phe) {
+ memcpy(buf2, buf, bufsize);
+ snprintf(buf, bufsize, "%s\npHe:%.1f", buf2, entry->phe);
+ }
+ free(buf2);
}
void get_plot_details(struct graphics_context *gc, int time, char *buf, size_t bufsize)
{
struct plot_info *pi = gc->plot_info;
+ int pressure = 0, temp = 0;
+ struct plot_data *entry;
*buf = 0;
if (pi) {
int i;
for (i = 0; i < pi->nr; i++) {
- struct plot_data *entry = pi->entry + i;
+ entry = pi->entry + i;
+ if (entry->temperature)
+ temp = entry->temperature;
+ if (GET_PRESSURE(entry))
+ pressure = GET_PRESSURE(entry);
if (entry->sec >= time) {
- plot_string(entry, buf, bufsize);
- break;
+ plot_string(entry, buf, bufsize, entry->depth, pressure, temp);
+ return;
}
}
+ plot_string(entry, buf, bufsize, entry->depth, pressure, temp);
}
}