mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-03 15:43:09 +00:00
diveplanner: adjust sac-factor calculation.
The real values are 1.0 to 10.0, but QML needs int so mobile gets values 10.0 to 100.0 add sacfactor() to QMLInterface and update QML. Signed-off-by: jan Iversen <jan@casacondor.com>
This commit is contained in:
parent
cd3c2266f9
commit
86fd49f2d7
4 changed files with 27 additions and 16 deletions
|
@ -105,10 +105,18 @@ void plannerShared::set_decosac(double value)
|
||||||
|
|
||||||
double plannerShared::sacfactor()
|
double plannerShared::sacfactor()
|
||||||
{
|
{
|
||||||
return qPrefDivePlanner::sacfactor() / 100.0;
|
return qPrefDivePlanner::sacfactor() /
|
||||||
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
10.0;
|
||||||
|
#else
|
||||||
|
100.0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void plannerShared::set_sacfactor(double value)
|
void plannerShared::set_sacfactor(double value)
|
||||||
{
|
{
|
||||||
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
value /= 10.0;
|
||||||
|
#endif
|
||||||
// NO conversion, this is done in the planner model.
|
// NO conversion, this is done in the planner model.
|
||||||
DivePlannerPointsModel::instance()->setSacFactor(value);
|
DivePlannerPointsModel::instance()->setSacFactor(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -261,15 +261,15 @@ Kirigami.ScrollablePage {
|
||||||
text: qsTr("SAC factor")
|
text: qsTr("SAC factor")
|
||||||
}
|
}
|
||||||
TemplateSpinBox {
|
TemplateSpinBox {
|
||||||
from: 20
|
from: 10
|
||||||
to: 99
|
to: 99
|
||||||
stepSize: 1
|
stepSize: 1
|
||||||
value: Planner.sacfactor
|
value: Backend.sacfactor
|
||||||
textFromValue: function (value, locale) {
|
textFromValue: function (value, locale) {
|
||||||
return (value / 10).toFixed(1)
|
return (value / 10).toFixed(1)
|
||||||
}
|
}
|
||||||
onValueModified: {
|
onValueModified: {
|
||||||
Planner.sacfactor = value
|
Backend.sacfactor = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TemplateLabel {
|
TemplateLabel {
|
||||||
|
|
|
@ -69,6 +69,9 @@ void QMLInterface::setup(QQmlContext *ct)
|
||||||
instance(), &QMLInterface::bottomsacChanged);
|
instance(), &QMLInterface::bottomsacChanged);
|
||||||
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::decosacChanged,
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::decosacChanged,
|
||||||
instance(), &QMLInterface::decosacChanged);
|
instance(), &QMLInterface::decosacChanged);
|
||||||
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::sacfactorChanged,
|
||||||
|
instance(), &QMLInterface::sacfactorChanged);
|
||||||
|
|
||||||
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_runtimeChanged,
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_runtimeChanged,
|
||||||
instance(), &QMLInterface::display_runtimeChanged);
|
instance(), &QMLInterface::display_runtimeChanged);
|
||||||
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_durationChanged,
|
connect(qPrefDivePlanner::instance(), &qPrefDivePlanner::display_durationChanged,
|
||||||
|
|
|
@ -79,13 +79,13 @@ void TestPlannerShared::test_gas()
|
||||||
{
|
{
|
||||||
// test independent of metric/imperial
|
// test independent of metric/imperial
|
||||||
plannerShared::set_sacfactor(4.2);
|
plannerShared::set_sacfactor(4.2);
|
||||||
QCOMPARE(qPrefDivePlanner::sacfactor(), 420);
|
QCOMPARE(qPrefDivePlanner::sacfactor(), 42);
|
||||||
plannerShared::set_sacfactor(3.5);
|
plannerShared::set_sacfactor(3.5);
|
||||||
QCOMPARE(qPrefDivePlanner::sacfactor(), 350);
|
QCOMPARE(qPrefDivePlanner::sacfactor(), 35);
|
||||||
qPrefDivePlanner::set_sacfactor(280);
|
qPrefDivePlanner::set_sacfactor(280);
|
||||||
QCOMPARE(plannerShared::sacfactor(), 2.8);
|
QCOMPARE(plannerShared::sacfactor(), 28);
|
||||||
qPrefDivePlanner::set_sacfactor(200);
|
qPrefDivePlanner::set_sacfactor(200);
|
||||||
QCOMPARE(plannerShared::sacfactor(), 2.0);
|
QCOMPARE(plannerShared::sacfactor(), 20);
|
||||||
|
|
||||||
// Set system to use meters
|
// Set system to use meters
|
||||||
qPrefUnits::set_unit_system(METRIC);
|
qPrefUnits::set_unit_system(METRIC);
|
||||||
|
@ -139,26 +139,26 @@ void TestPlannerShared::test_gas()
|
||||||
qPrefUnits::set_unit_system(IMPERIAL);
|
qPrefUnits::set_unit_system(IMPERIAL);
|
||||||
|
|
||||||
plannerShared::set_bottomsac(0.9);
|
plannerShared::set_bottomsac(0.9);
|
||||||
QCOMPARE(qPrefDivePlanner::bottomsac(), 25485);
|
QCOMPARE(qPrefDivePlanner::bottomsac(), 255);
|
||||||
plannerShared::set_bottomsac(0.01);
|
plannerShared::set_bottomsac(0.01);
|
||||||
QCOMPARE(qPrefDivePlanner::bottomsac(), 283);
|
QCOMPARE(qPrefDivePlanner::bottomsac(), 3);
|
||||||
|
|
||||||
// Remark return will from qPref is in m / 1000.
|
// Remark return will from qPref is in m / 1000.
|
||||||
qPrefDivePlanner::set_bottomsac(2830);
|
qPrefDivePlanner::set_bottomsac(2830);
|
||||||
QCOMPARE(int(plannerShared::bottomsac() * 1000), 99);
|
QCOMPARE(int(plannerShared::bottomsac()), 9);
|
||||||
qPrefDivePlanner::set_bottomsac(16000);
|
qPrefDivePlanner::set_bottomsac(16000);
|
||||||
QCOMPARE(int(plannerShared::bottomsac() * 1000), 565);
|
QCOMPARE(int(plannerShared::bottomsac()), 56);
|
||||||
|
|
||||||
plannerShared::set_decosac(0.9);
|
plannerShared::set_decosac(0.9);
|
||||||
QCOMPARE(qPrefDivePlanner::decosac(), 25485);
|
QCOMPARE(qPrefDivePlanner::decosac(), 255);
|
||||||
plannerShared::set_decosac(0.01);
|
plannerShared::set_decosac(0.01);
|
||||||
QCOMPARE(qPrefDivePlanner::decosac(), 283);
|
QCOMPARE(qPrefDivePlanner::decosac(), 3);
|
||||||
|
|
||||||
// Remark return will from qPref is in m / 1000.
|
// Remark return will from qPref is in m / 1000.
|
||||||
qPrefDivePlanner::set_decosac(11500);
|
qPrefDivePlanner::set_decosac(11500);
|
||||||
QCOMPARE(int(plannerShared::decosac() * 1000), 406);
|
QCOMPARE(int(plannerShared::decosac()), 40);
|
||||||
qPrefDivePlanner::set_decosac(19800);
|
qPrefDivePlanner::set_decosac(19800);
|
||||||
QCOMPARE(int(plannerShared::decosac() * 1000), 699);
|
QCOMPARE(int(plannerShared::decosac()), 69);
|
||||||
|
|
||||||
// Remark bottompo2 is in BAR, even though unit system is
|
// Remark bottompo2 is in BAR, even though unit system is
|
||||||
// Imperial, the desktop version is like that.
|
// Imperial, the desktop version is like that.
|
||||||
|
|
Loading…
Reference in a new issue