summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-11 17:12:09 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-11 17:18:14 +0100
commit502e2b0e86a8c961b82ea2824e9f3fd82e83eb72 (patch)
tree44980db2ad847f470a58103b1b1715e07774d2f4 /profile.c
parentb304562fa89aa67fd5639d6c14c6e12472287515 (diff)
downloadsubsurface-502e2b0e86a8c961b82ea2824e9f3fd82e83eb72.tar.gz
Add more data to our tool-tip display in the profile window
This shows the values for all the graphs that are shown (depth, temperature, tank pressure, pO2, pN2m pHe), but also correctly doesn't display them when they are turned off or no data is available (prior to this commit, tank pressure was always shown, even if no pressure samples were available for the dive). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c55
1 files changed, 41 insertions, 14 deletions
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);
}
}