mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
b304562fa8
commit
502e2b0e86
2 changed files with 41 additions and 14 deletions
|
@ -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);
|
||||
|
|
53
profile.c
53
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;
|
||||
int pressurevalue;
|
||||
const char *depth_unit, *pressure_unit, *temp_unit;
|
||||
char *buf2 = malloc(bufsize);
|
||||
double depthvalue, tempvalue;
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue