mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Sanity check on gas percentages
O2 + He + N2 = 100% (well, there are some other gases, but this is close enough) Since N2 can't be negative that means we should refuse any change where O2 + He > 100% (or o2.permille + he.permille > 1000). Fixes #280 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4619bfd9ca
commit
1a5e94006c
1 changed files with 10 additions and 4 deletions
|
@ -284,14 +284,20 @@ bool CylindersModel::setData(const QModelIndex& index, const QVariant& value, in
|
|||
break;
|
||||
case O2:
|
||||
if (CHANGED(toDouble, "%", "%")) {
|
||||
cyl->gasmix.o2.permille = value.toString().remove('%').toDouble() * 10 + 0.5;
|
||||
changed = true;
|
||||
int o2 = value.toString().remove('%').toDouble() * 10 + 0.5;
|
||||
if (cyl->gasmix.he.permille + o2 <= 1000) {
|
||||
cyl->gasmix.o2.permille = o2;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HE:
|
||||
if (CHANGED(toDouble, "%", "%")) {
|
||||
cyl->gasmix.he.permille = value.toString().remove('%').toDouble() * 10 + 0.5;
|
||||
changed = true;
|
||||
int he = value.toString().remove('%').toDouble() * 10 + 0.5;
|
||||
if (cyl->gasmix.o2.permille + he <= 1000) {
|
||||
cyl->gasmix.he.permille = he;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DEPTH:
|
||||
|
|
Loading…
Add table
Reference in a new issue