aboutsummaryrefslogtreecommitdiffstats
path: root/backend-shared/plannershared.cpp
AgeCommit message (Collapse)Author
2020-07-11Make MND display depend on O2 narcotic preferenceGravatar Robert C. Helling
A while ago, we introduced a preference whether O2 should be considered narcotic. We used this when computing best mix or when entering the He content via MND. But we forgot to make the displayed MND depend on this preference. This patch add this. Fixes #2895 Signed-off-by: Robert C. Helling <helling@atdotde.de>
2020-02-11Planner: don't filter cylindersGravatar Berthold Stoeger
In the planner we used to filter out "unused" cylinders as in the equipment tab. It is unclear whether that makes sense or can even easily be reproduced, since such cylinders have to come from an imported dive. To be on the save side, let's not do this. Replace the CylindersFilteredModel introduced recently by a plain CylindersModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Planner: make cylinder-model subobject of planner-modelGravatar Berthold Stoeger
The cylinder-model had an instance() function, but actually there were two cylinder models: one used by the equipment tab, one used by the planner. This is misleading. Therefore, remove the instance() function and make the cylinder-model a subobject of the planner-model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-11Cylinders: Add CylindersModelFilteredGravatar Berthold Stoeger
When the show_unused_cylinders flag is not set, the cylinder tables in the equipment tab and the planner should not show unused cylinders. However, the code in CylindersModel is fundamentally broken if the unused cylinders are not at the end of the list: The correct number of cylinders is shown, but not the correct cylinders. Therefore, add a higher-level CylindersModelFiltered model on top of CylindersModel that does the actual filtering. Some calls are routed through to the base model (notably those that take indexes, as these have to be mapped), for some calls the caller has to get access to the source model first. We might want to adjust this. For filtering, reuse the already existing show_cylinder function and export it via CylindersModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-02-04Cleanup: rename plannerShared to PlannerSharedGravatar Berthold Stoeger
Usually, we use PascalCase (i.e. camelCase with a capital letter at the start) for class names. For consistency, let's do it here as well. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-31Remove plannerShared::instance()Gravatar Berthold Stoeger
This class contains only static functions (i.e. it does not contain any state). There does not seem to be a reason to have an instance of that class. Therefore, remove the instance() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-01-25diveplanner: add comments explaining different scalingGravatar jan Iversen
In some case the scaling (real value <-> UI value) is different for mobile and desktop. In order to make the difference understandable comments are added to each function. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25backend-shared: correct wrong commentGravatar jan Iversen
Remove comment that was very false (next line contradicted the comment). Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25diveplanner: move mobile specific calc to diveplannermodelGravatar jan Iversen
setBottomSac, setDecoSac and setFactor in diveplannermodel receives display value which are then converted. subsurface-mobile have slightly different values, move the correction of these from plannershared to diveplannermodel, in order to keep the whole convert in one place. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25dive-planner: removed unused QML interfaceGravatar jan Iversen
Remove Q_PROPERTY and signals from plannershared, since they are no longer used (transferred to qmlinterface). Unregister object plannershared, since it is no longer used in QML. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-25diveplanner: add surface_segment to plannersharedGravatar jan Iversen
Add surface_segment to plannerShared and then update desktop-widgets. Signed-off-by: jan Iversen <jan@casacondor.com> desktop-widgets: use plannerShared for surface_segment Change getter/setter for surface_segment to plannerShared, in order to share the conversion with mobile diveplanner Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25diveplanner: adjust sac-factor calculation.Gravatar jan Iversen
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>
2020-01-25dive planner: correct bottomsac/decosac calc.Gravatar jan Iversen
Move conversion cuft <-> liter from desktop-widget/diveplanner.cpp to plannerShared, to facilitate the same results in mobile diveplanner Use Backend for bottomsac/decosac and update to check for switch LITER <-> CUFT Add bottomsac/decosac to QMLinterface. Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-25diveplanner: call planner model directly for simple variables.Gravatar jan Iversen
Variables without conversion, do not need to pass plannerShared (due to the QML interface). Simple variables do not pass plannerShared, but diveplanner in desktop-widgets and qmlinterface in mobile-widgets call the implementation directly. Signed-off-by: jan Iversen <jan@casacondor.com>
2020-01-24backendShared: remove length slotGravatar jan Iversen
Length variables are updated from the QML and desktop directly. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-24mobile: move dive planner notes access to pure interfaceGravatar jan Iversen
Make notes rates available to QML through the Backend interface. Remove the corresponding variables from plannerShared. Getters are from prefs. while setters are linked to diveplan model. Remark: signals from qPrefDivePlanner is used, because the diveplanner model sets qPrefDivePlanner but do not issue special signals. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-20backend-shared: remove asc/desc functionsGravatar jan Iversen
Ascent/Descent rate functions are fully implemented in diveplannermodel, therefore remove these functions. Signed-off-by: jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-01-04backend-shared: add slot to detect switch METER <-> FEETGravatar jan Iversen
This allows to update plannermodel etc. and thus avoiding a restart when changing units for length. Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-31backend: correct deco2() problem in plannerSharedGravatar jan Iversen
Divided by 1000 (int) instead of 1000.0 (float) which caused precision problems. Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-30backendShared: correct set_verbatim_plan in plannerShared.Gravatar jan Iversen
Correct copy/paste error, set_verbatim_plan() should not call setSacFactor() but setVerbatim(). Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-28planner: correct rating calculations.Gravatar jan Iversen
Test show that the ratings calculations were off by +/- 1, due to rounding errors. Found due to test cases in tests (other commits) The calculations are copied 1-1 from diveplanner.cpp, but are used slightly different in plannerShared.cpp Correct calculations, by securing the calculation is done with float precision and the rounded with lrint(). Signed-off-by: Jan Iversen <jan@casacondor.com>
2019-12-26plannerShared: add notes variablesGravatar jan Iversen
Add display_runtime display_duration display_transitions verbatim_plan display_variations Get is direct from qPrefDivePlanner and set is plannerModel Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26desktop-widgets: replace o2narcotic from plannerModel to plannerSharedGravatar jan Iversen
Use plannerShared setter to update o2narcotic. This will also signal the cylindermodel to calculate a new bestmix. Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26plannerShared: add o2narcoticGravatar jan Iversen
Add include of cylinderModel Add o2narcotic the set function is special because it first informs the plannerModel that there is a new value and then ask cylindermodel to calculate a new bestmix Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26plannerShared: add variables from plannerModelGravatar jan Iversen
the variables are set through set functions in DivePlannerPointsModel, but read via getters from qPrefDivePlanner. Variables: bottomsac decosac problemsolvingtime sacfactor Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26plannerShared: add variables from plannerModel with conversionGravatar jan Iversen
the variables are set through set functions in DivePlannerPointsModel, but read via getters from qPrefDivePlanner and converted Variables: min_switch_duration Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26plannerShared: add variables that reference qPrefDivePlannerGravatar jan Iversen
These are simple pass-through functions (normally optimized away by the compiler), and serve to make a consistent backend interface which have a simpler use especially in QML. Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26plannerShared: add variables from plannerModelGravatar jan Iversen
the variables are set through set functions in DivePlannerPointsModel, but read via getters from qPrefDivePlanner. Variables: drop_stone_mode last_stop switch_at_req_stop Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26plannerShared: add variables that reference qPrefDiveplannerGravatar jan Iversen
These are simple pass-through functions (normally optimized away by the compiler), and serve to make a consistent backend interface which have a simpler use especially in QML. Variables: dobailout Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-26plannerShared: add variables from plannerModelGravatar jan Iversen
the variables are set through set functions in DivePlannerPointsModel, but read via getters from qPrefDivePlanner. Variables: planner_deco_mode reserveGas safetyStop gflow gfhigh vpmb_conservatism Signed-off-by: Jan Iversen <jan@casacondor.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-12-24build-system: move plannerShared to backend-sharedGravatar jan Iversen
WARNING: multi directory commit, needed to secure it builds. move the core/plannerShared.* to backend-shared. update CMakeLists.txt to include backend-shared lib in link process. update ios project to reflect new directory Signed-off-by: Jan Iversen <jan@casacondor.com>