aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/cylindermodel.cpp
AgeCommit message (Collapse)Author
2017-04-29Add SPDX header to Qt modelsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-24Don't erroneously mark the cylinder pressure red - second tryGravatar Stefan Fuchs
Second attempt to do the thing with the red background color for cylinder start and end pressure correctly. This now should cover all scenarios. This rewrites and partitially reverts commit b8e044d Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-13Correctly trigger update of cylinder table trash icons in plannerGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Correct trash or trashforbidden icon and tooltip in cylinder tableGravatar Stefan Fuchs
Display the correct trash or trashforbidden icon and tooltip in the cylinder table. This should fit together with if it is really possible to remove a cylinder. Search for "same gas" based on used cylinders only. Otherwise one could remove a used cylinder because there is an unused cylinder with same gas. ToDo: In planner update trash icon on change of planner points. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Add units (m or ft) for MOD and MND in cylinder table in plannerGravatar Stefan Fuchs
We do display the unit for "Gas change at" today so we should also display it for MOD and MND. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Use abbreviations with dots.Gravatar Martin Měřinský
2017-03-11Don't erroneously mark the cylinder pressure red and set font italicGravatar Stefan Fuchs
In the cylinder table today the cylinder start and end pressure fields are marked red and the end pressure font is set to italic if cyl->end is 0. But sometimes with planned dives there is no cyl->end but only cyl->sample_end. This is taken into account now. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-11Fix cyclinder table issue "workingpressure" in plannerGravatar Stefan Fuchs
Fixes the issue that the cylinder table in the planner is messed up after changing the table header. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-02-26Call the cylinder working pressure "starting pressure" in plannerGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-03Revert "In statistics, ignore gas use of planned dives"Gravatar Dirk Hohndel
This reverts commit 1d8662006cbb5edae941315e30ede381c23a817b. Mistakenly pushed to master Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-02-02In statistics, ignore gas use of planned divesGravatar Robert C. Helling
When merged with real dives, those would double count otherwise. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-23Allow user to disable a cylinder in plannerGravatar Robert C. Helling
In the cylinder table, the last column ("use") always showed OC-GAS. Editing was enabled, but the user had to guess to enter a small integer meaning dilluent or CCR oxygen cylingder. I guess, nobody has ever done that. This patch makes this column clickable. A click toggles if the cylinder is used for planning or not. This wait it is much easier to investigate the consequences of gas loss on a plan. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-16Revert "Show both the nominal and "real" size for an imperial cylinder"Gravatar Dirk Hohndel
This reverts commit adaeb506b7a1485cab741f12450abeb76e109276. commit a8e8d56ec016 ("Tweak cylinder equipment tooltips") does a much better job allowing the user to know the true volume of the cylinder (given the gas entered) and clutters the UI a lot less.
2017-01-16Tweak cylinder equipment tooltipsGravatar Linus Torvalds
While playing around with the current subsurface, I realized that while we give the gas volume and Z factor for the beginning/end pressures in the newly added tooltips, there is no way to actually see that same information for the working pressure. So if you have filled in cylinder type information, but don't have any actual gas usage information, there will be no cylinder tooltips at all. But you might still want to know what the actual volume for a particular cylinder is, and what the Z value for that working pressure is. So this tweaks the tool-tips a bit. When mousing over the pressure fields (ie "working pressure", "start" and "end"), it now always gives the cylinder gas volume and Z factor for that pressure, so for example on an AL72 that has a working pressure of 3000 psi and that contains air the tooltip will say: 69 cuft, Z=1.040 when you mouse over the working pressure field (that's obviously with imperial units, in metric you'll see liters of gas). When mousing over the type/size field, it gives the used gas amounts, ie something like this: 37 cuft (82 cuft -> 45 cuft) but if the cylinder doesn't have starting/ending pressures (and thus no used gas information), this patch will make subsurface show the working pressure data instead, so that you at least get something. This all seems more useful than what my first version gave. NOTE! This makes commit adaeb506b7a1 ("Show both the nominal and "real" size for an imperial cylinder") kind of pointless. You now see the real size in the tooltip when you mouse over the size, and now it actually works both for imperial and metric people, so the tooltip is in many ways the better model. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-12Add cylinder equipment tooltips with gas volumeGravatar Linus Torvalds
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>
2016-08-10CylindersModel: add tooltips for Deco switch at, Bot MOD and MNDGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Remove unnecessary DivePlannerPointsModel functions and variablesGravatar Rick Walsh
Commit b1ed04a means that DivePlannerPointsModel::rememberTanks() and related functions and variables are no longer required Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Relabel cylindermodel "Deco MOD" column to "Deco switch at"Gravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Planner: update cylinder mixes and MND and MOD when prefs are changedGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Fixup: don't capitalise best_HeGravatar Rick Walsh
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Planner: automate calculation of best mix for max depthGravatar Rick Walsh
Add option to calculate the best mix portion of O2 and He for the dive's max depth if the user enters * in the MOD and MND cylinder fields. Gas portions are automatically recalculated if the max depth of the dive changes. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Be more clear about deco MOD / switch depth and bottom MODGravatar Rick Walsh
The switch depth of a decompression gas is its MOD. By renaming the heading to "Deco MOD", it is more clearly distinguished from the bottom MOD, and it is more obvious how they relate to the Bottom pO2 and Deco pO2 preferences. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Add MOD and MND fields to cylindermodelGravatar Rick Walsh
Adds fields to the planner cylinder model for maximum operating depth (MOD) for a bottom mix gas, and maximum narcotic depth (MND). Fields are read/write, so changing MOD changes %O2 and vice-versa. Changing MND changes %He and vice-versa. When setting MOD directly, the %O2 is truncated (rounded down) to an integer, which re-calculates the MOD, which is sometimes a few metres greater than the input depth. This is desireable behaviour, as the rounding is conservative. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Update gas deco MOD when deco pO2 is changedGravatar Rick Walsh
This fix is reasonably straightforward when the divedatapoint structure stores the cylinder rather than gasmix. Fixes #970 Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-09Have divedatapoint store cylinder id instead of gasmixGravatar Rick Walsh
Determining the correct cylinder index from a known gas mix can be complicated, but it is trivial to look up the gasmix from the cylinder_t structure. It makes sense to remember which cylinder is being used. This simplifies handling changing a cylinder's gas mix, either directly by the user, or indirectly in the planner. It also permits tracking of multiple cylinders of the same mix, e.g. independent twins / sidemount. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-28Add some gas mix validation to the plannerGravatar Rick Walsh
A few basic rules for gas validation: We can't have <0%, or >100% of either O2 or He O2 + He must not be >100% Switch depth can't be <0% This places limits on user-input values Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-05-21Add best mix function to planner cylinder modelGravatar Rick Walsh
This allows calculation and selection of best mix in the planner cylinder entry, by entering the gas depth, followed by "b" for best (trimix) mix, or "bn" for best nitrox mix. The UI is not intuitive, but it is quick and easy. At the very least, it should be documented. Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-29CylindersModel: clamp the "cylinderuse" valuesGravatar Lubomir I. Ivanov
If the value for "use" is negative or larger than the number of elements in "enum cylinderuse", later CylindersModel::data() can request a string in the lines of cylinderuse_text[cyl->cylinder_use], which can SIGSEGV. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08Silence warnings in CylinderModelGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07Silence more warningsGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25Show both the nominal and "real" size for an imperial cylinderGravatar Linus Torvalds
This is questionable, but perhaps useful. When showing imperial cylinder sizes, show both the nominal value (with no compensation for compressibility of the gas) and the "actual" amount of gas the cylinder contains. So an AL80 will show as a size of "80 (77)cuft", because while 80 is the nominal size, the actual amount of gas that will fit is just 77 cuft. [Dirk Hohndel: adjusted to take translation of the unit into account] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25Don't use "get_volume_string()" for cylinder size stringGravatar Linus Torvalds
We had two totally different usage cases for "get_volume_string()": one that did the obvious "show this volume as a string", and one that tried to show a cylinder size. The function used a magic third argument (the working pressure of the cylinder) to distinguish between the two cases, but it still got it wrong. A metric cylinder doesn't necessarily have a working pressure at all, and the size is a wet size in liters. We'd pass in zero as the working pressure, and if the volume units were set to cubic feet, the logic in "get_volume_string()" would happily convert the metric wet size into the wet size in cubic feet. But that's completely wrong. An imperial cylinder size simply isn't a wet size. If you don't have a working pressure, you cannot convert the cylinder size to cubic feet. End of story. So instead of having "get_volume_string()" have magical behavior depending on working pressure, and getting it wrong anyway, just make get_volume_string do a pure volume conversion, and create a whole new function for showing the size of a cylinder. Now, if the cylinder doesn't have a working pressure, we just show the metric size, even if the user had asked for cubic feet. [Dirk Hohndel: added call to translation functions for the units] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-22Fixing annoying compiler warningGravatar Guido Lerch
Adding { } to if clause to avoid dangling warning /Users/guidolerch/src/subsurface/qt-models/cylindermodel.cpp:117: warning: add explicit braces to avoid dangling else [-Wdangling-else] [Dirk Hohndel: combined two of Guido's patches to one that is simpler] Signed-off-by: Guido Lerch <guido.lerch@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-19Show correct icon when only one gasmix in the listGravatar Joakim Bygdell
When there is only one gasmix in the list we should show the icon that tells the user that they can't remove the last gasmix from the list. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05Round MOD of gas rather than truncateGravatar Robert C. Helling
For the proper calculation, we need to take salinity and surface pressure into account (rather than depth = bar * 10 - 10) Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Cylinder model: fix an obscure case that would access cylinder -1Gravatar Dirk Hohndel
If we remove a cylidner for a unique gas and that is allowable, then don't try to copy from cylinder with index same_gas (which is still -1). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29Move Tankinfomodel to its own fileGravatar Tomaz Canabrava
Another change to make it easier to program the mobile ui. This was a fairly easy patch: just moved the contents of the file and fixed the includes. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29Move DivePlannerModel and CylinderModel to qt-modelsGravatar Tomaz Canabrava
Still trying to make it easier for the Mobile Port: This patch is a bit bigger than I hopped, but it was the smallest that I could get. A lot of TODO items where added where I broke the code because the current implementation would break the QML implementtion on the designer. I'll most probably fix those myself when I finish the transition to the models to the new folder. I only moved both models at once because there's an interdependency between them (seems inevitable, tough, but I'll take a better look at it later). Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>