mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Bugfix: Fix Incorrect Volumes Displayed for Tank Types.
Fix an issue introduced in #4148. Essentially the refactoring missed the fact that in the imperial system tank size is tracked as the free gas volume, but in the metric system (which is the one used in most of Subsurface's calculations) tank size is tracked as water capacity. So when updating a tank template tracking imperial measurements, the given (metric) volume in l has to be multiplied by the working pressure, and vice versa. This also combines all the logic dealing with `tank_info` data in one place, hopefully making it less likely that this will be broken by inconsistencies in the future. Fixes #4239. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
a8c9781205
commit
10fc3bfd47
5 changed files with 38 additions and 39 deletions
|
@ -13,17 +13,15 @@ QVariant TankInfoModel::data(const QModelIndex &index, int role) const
|
|||
return defaultModelFont();
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||
const struct tank_info &info = tank_info_table.infos[index.row()];
|
||||
int ml = info.ml;
|
||||
double bar = (info.psi) ? psi_to_bar(info.psi) : info.bar;
|
||||
|
||||
if (info.cuft && info.psi)
|
||||
ml = lrint(cuft_to_l(info.cuft) * 1000 / bar_to_atm(bar));
|
||||
volume_t size = {0};
|
||||
pressure_t pressure = {0};
|
||||
extract_tank_info(&info, &size, &pressure);
|
||||
|
||||
switch (index.column()) {
|
||||
case BAR:
|
||||
return bar * 1000;
|
||||
return pressure.mbar;
|
||||
case ML:
|
||||
return ml;
|
||||
return size.mliter;
|
||||
case DESCRIPTION:
|
||||
return info.name;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue