mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add cylinder equipment tooltips with gas volume
This adds tooltips for the equipment tab for each cylinder, showing the amount of gas used. When you mouse over the size and working pressure fields, the tooltip will show the amount of gas used (along with start and end gas volumes). And when you mouse over the start and end pressures, it will show the start and end gas volumes, and the Z factor used. I started doing this because of the gas volume questions in the last day or two (and a few from a few weeks ago). When even Robert Helling starts wondering about the effects of compressibility on the SAC calculation, our numbers are clearly too opaque. With these tooltips, at least you can see what went into the used gas calculations, instead of having to add debugging options to print out Z factors. [ This patch also adds a "rint()" to get the rounding right in the gas_volume() function. Although rounding to the nearst milliliter really doesn't matter, it's the right thing to do after doing FP calculations ;^] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
6637aee114
commit
638e7fb28f
2 changed files with 60 additions and 1 deletions
|
@ -872,7 +872,7 @@ int gas_volume(cylinder_t *cyl, pressure_t p)
|
|||
{
|
||||
double bar = p.mbar / 1000.0;
|
||||
double z_factor = gas_compressibility_factor(&cyl->gasmix, bar);
|
||||
return cyl->type.size.mliter * bar_to_atm(bar) / z_factor;
|
||||
return rint(cyl->type.size.mliter * bar_to_atm(bar) / z_factor);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -51,6 +51,58 @@ static QString get_cylinder_string(cylinder_t *cyl)
|
|||
return QString("%1").arg(value, 0, 'f', decimals) + unit;
|
||||
}
|
||||
|
||||
static QString gas_volume_string(int ml, const char *tail)
|
||||
{
|
||||
double vol;
|
||||
const char *unit;
|
||||
int decimals;
|
||||
|
||||
vol = get_volume_units(ml, NULL, &unit);
|
||||
decimals = (vol > 20.0) ? 0 : (vol > 2.0) ? 1 : 2;
|
||||
|
||||
return QString("%1 %2 %3").arg(vol, 0, 'f', decimals).arg(unit).arg(tail);
|
||||
}
|
||||
|
||||
static QVariant gas_usage_tooltip(cylinder_t *cyl)
|
||||
{
|
||||
pressure_t startp = cyl->start.mbar ? cyl->start : cyl->sample_start;
|
||||
pressure_t endp = cyl->end.mbar ? cyl->end : cyl->sample_end;
|
||||
|
||||
int start, end, used;
|
||||
|
||||
start = gas_volume(cyl, startp);
|
||||
end = gas_volume(cyl, endp);
|
||||
used = (end && start > end) ? start - end : 0;
|
||||
|
||||
if (!used)
|
||||
return QVariant();
|
||||
|
||||
return gas_volume_string(used, "(") +
|
||||
gas_volume_string(start, " -> ") +
|
||||
gas_volume_string(end, ")");
|
||||
}
|
||||
|
||||
static QVariant gas_volume_tooltip(cylinder_t *cyl, pressure_t p)
|
||||
{
|
||||
int vol = gas_volume(cyl, p);
|
||||
double Z;
|
||||
|
||||
if (!vol)
|
||||
return QVariant();
|
||||
|
||||
Z = gas_compressibility_factor(&cyl->gasmix, p.mbar / 1000.0);
|
||||
return gas_volume_string(vol, "(Z=") + QString("%1)").arg(Z, 0, 'f', 3);
|
||||
}
|
||||
|
||||
static QVariant gas_start_tooltip(cylinder_t *cyl)
|
||||
{
|
||||
return gas_volume_tooltip(cyl, cyl->start.mbar ? cyl->start : cyl->sample_start);
|
||||
}
|
||||
|
||||
static QVariant gas_end_tooltip(cylinder_t *cyl)
|
||||
{
|
||||
return gas_volume_tooltip(cyl, cyl->end.mbar ? cyl->end : cyl->sample_end);
|
||||
}
|
||||
|
||||
static QVariant percent_string(fraction_t fraction)
|
||||
{
|
||||
|
@ -176,6 +228,13 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
|||
case REMOVE:
|
||||
ret = tr("Clicking here will remove this cylinder.");
|
||||
break;
|
||||
case SIZE:
|
||||
case WORKINGPRESS:
|
||||
return gas_usage_tooltip(cyl);
|
||||
case START:
|
||||
return gas_start_tooltip(cyl);
|
||||
case END:
|
||||
return gas_end_tooltip(cyl);
|
||||
case DEPTH:
|
||||
ret = tr("Switch depth for deco gas. Calculated using Deco pO₂ preference, unless set manually.");
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue