summaryrefslogtreecommitdiffstats
path: root/subsurface-core
AgeCommit message (Collapse)Author
2016-03-03Don't access undefined diveGravatar Dirk Hohndel
When walking the dive table we need to stop before accessing the yet-to-be-added new dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-03Avoid dangling else warningsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-03gas model: simplify and improve our Z factor calculationsGravatar Linus Torvalds
Lubomir found better compressibility data for the pure gases that we need for scuba, making the air table superfluous: we get good values from just regular linear mixing of the Oxygen, Nitrogen and Helium calculations. Also, rather than using a quintic polynomial, a cubic one does sufficiently well, making for smaller code and fewer coefficients. And judging by the reactions from people on G+ (as well as just looking at how good the fit is with the air data), this is all the right way to do this, and this thus removes the Redlich-Kwong equation. All-credit-goes-to: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02gas model: add polynomials for Z factors of oxygen/nitrogen/heliumGravatar Linus Torvalds
.. and use a linear mix of them for arbitrary gas mixes. For the special case of air, we continue to use the air-specific polynomial. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02gas model: replace Redlich-Kwong with least-square quinticGravatar Linus Torvalds
This goes back to just doing air compressibility, but using the least-squares quintic polynomial equation that Lubomir generated based on the Wikipedia table for air at 300K in the 1-500 bar range. We might be able to do similar things for mixed gases.. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02gas model: split up gas compressibility into a file of its ownGravatar Linus Torvalds
The gas compressibility is such a specialized thing that I really prefer having it separate. This keeps Robert's Redlich-Kwong equation as-is, but let's experiment with other models soon... Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-02QML UI: create a chronological dive list when manually adding diveGravatar Dirk Hohndel
The dive list might contain dives in the future, don't add the new dive to then end but instead add it at the correct spot in the list Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-29This computes the compressibility of the gas depending on the mixture.Gravatar Robert C. Helling
As it turns out, the van der Waals equation gives results that are numerically not really useful, so we use the Redlich Kwong equation which is, according to Wikipedia, much more accurate, which can be confirmed given the empirical values for air. As opposed to the previous approach with a look-up table, this takes into account the actual gasmix. This always assumes the gas to be at 20 degrees Centigrade. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-29DiveHelperObject: add the weightList and cylinderList propertiesGravatar Lubomir I. Ivanov
"weights" and "cylinders" are QStringList Q_PROPERTIES, and Grantlee should be able to render them, but it doesn't. To be able to print the whole list of weights and cylinders we introduce two new QString properties "weightList" and "cylinderList". The variable replacement in the previous patch deals with the conversation of the user side HTML, e.g.: USER -> INTERNAL "{{ dive.weights }} -> {{ dive.weightList }}" "{{ dive.cylinders }} -> {{ dive.cylinderList }}" Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-28If salinity is not density, add density of fresh waterGravatar Robert C. Helling
There was a reported case of an import of a dive that gave a salinity of 35g/l. This is an actual salinity (an amount of salt in the water) but for subsurface the salinity is actually the density of the water. So for too small values of the salinity add the density of fresh water. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25gas pressures: use an actual compressibility table for airGravatar Linus Torvalds
We could in theory make this dependent on the gasmix, but for now let's just assume (incorrectly) that everything we breathe acts like air. 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>
2016-02-25gas pressures: do not use gas compressibility for cylinder namingGravatar Linus Torvalds
This actually didn't make a difference for the common case, since our simplified gas compressibility model had a compressibility factor of 1.0 up to 200 bar, and increased smoothly from there. As a result, the common 2400 and 3000 psi workpressures didn't really see an effect from this. Not taking compressibility into account does kind of make sense for cylinder naming, since the cylinder may be used for different gases with very different compressibility characteristics. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25gas pressures: do some initial cleanupGravatar Linus Torvalds
This marks "surface_volume_multiplier()" static in preparation for changing it to use an actual honest-to-goodness compressibility estimation. Without that, it wasn't obvious that the function wasn't used in other random places. Also, remove the "wet_volume()" function. It was unused, but more importantly, it was wrong. Yes, it was the inverse of "gas_volume()", but when you calculate wet volumes from the imperial sizes, you don't actually use the "real" gas volume, you use the idealized one. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-24Correctly round total weight displayedGravatar Dirk Hohndel
The code was wrong (and in the case of metric display for weights >= 20kg, spectacularly wrong) in more or less all cases. Rounding. It's good for the sole. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21pressure interpolation: incrementally update interpolation dataGravatar Linus Torvalds
Instead of re-calculating all the interpolation data for each plot entry (which means that we have a quadratic algorithm that walks over all the plot-info points for each plot-info point), we can just update it incrementally within any particular interpolation segment. The previous cleanups made the code sane enough to understand, and makes it trivial to see how you don't have to recalculate the full thing. This gets rid of the O(n**2) algorithm, and it instead becomes O(n*m) where 'n' is the number of plot entries, and 'm' is the number of gas segments (which is usually a much smaller numer, typically "1"). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21pressure interpolation: further code simplificationGravatar Linus Torvalds
With the two bigger simplications, this just re-organizes the code to do the "interpolate.pressure_time" update that is shared among all the "after segment start" cases in just one place. That leaves the get_pr_interpolate_data() much simpler, and makes it much clearer what it actually does. In particular, it becomes very obvious that "interpolate.pressure_time" is constant for one particular segment (it's the total pressure time), and that "interpolate.acc_pressure_time" is the one that gets updated for every entry. The next step is to only call this for the first entry, and then update just the "acc_pressure_time" in the caller. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21pressure interpolation: simplify codeGravatar Linus Torvalds
Getting rid of the pointless always-zero pressure now makes it obvious how some of the remaining code can just be removed too: there is no point in re-initializing the pressure_time entries to zero at the segment start, because they started out zero and we just checked that we don't do anything to them before we hit the segment start. Similarly, now that the silly pressure testing is gone, it is obvious that the code for "i < cur" and "i == curr" cases is identical, and the two cases can just be collapsed. Signed-off-by: Linus Torvalds <torvalds@ linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-21pressure interpolation: get rid of pointless and confusing codeGravatar Linus Torvalds
In the function fill_missing_tank_pressures(), we only ever call get_pr_interpolate_data() if "pressure" is zero. So passing it in as an argument, and then testing whether it is zero or not, is just totally pointless, and only obfuscates things. This whole thing seems to be due to people editing the code over time, with the tests becoming superfluous as the code around it changed, and nobody looking at whether it actually made sense any more. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-20QML UI: make unit matching case insensitiveGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-20Add option to allocate the samples in fake_dc()Gravatar Dirk Hohndel
We (ab)use fake_dc() to create a pleasing profile for a manually added dive. Based on it's intended use, fake_dc() simply handed back a dc structure that pointed at staticly allocated samples - that's obviously (now that I think about it) going to blow up in my face if I edit a manually added dive more than once. So now we have an option for fake_dc() to actually allocate the samples - this way the rest of the code can treat these samples as we would treat samples created any other way. We can free them and replace them with a new set. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-15Clean up conversion helpersGravatar Dirk Hohndel
- coding style (ugh - I should have fixed that when I first committed them) - remove redundant variables - add similar code to the length and temperature helpers Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-14Add dive property to easily test if there isn't an actual diveGravatar Dirk Hohndel
Right now this just tests for zero duration, but maybe this should also return true for positive duration and max depth of 0. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-14Grab pressures from samples if requiredGravatar Miika Turkia
If cylinder does not have start and end pressures assigned, attempt to grab them from the samples instead. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-14Test cylinder usage properlyGravatar Miika Turkia
It is better to use the proper function to test if cylinder is in use than just checking the description. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-13Add helper function to parse gasmix stringsGravatar Joakim Bygdell
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-13Add helper function to retrieve first gasGravatar Joakim Bygdell
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-13While parsing weight and pressure we should not change the users settings.Gravatar Joakim Bygdell
Now it is possible to enter a specific unit that is different from the unit stored in the preferences. If only numbers are inputed the unit will be the same as specified by the users preferences. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-12Don't connect to remote if git_local_only is setGravatar Dirk Hohndel
If there was no local cache we still tried to connect to the remote, even with git_local_only set. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-10Don't just keep going when opening a git URL failsGravatar Dirk Hohndel
Once we identified that our filename is actually a git designator (as seen by the fact that it ends in a [branchname] surrounded by '[]'), we shouldn't try to open that filename in order to try other ways of parsing the data; instead we should just return an error to the caller. This way the calling code can tell that an error occured. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-09QML UI: add function to get cylinder pressuresGravatar Joakim Bygdell
Since we only show the first cylinder we can also only edit the first cylinder. Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-09Add helper to parse pressure strings.Gravatar Joakim Bygdell
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-07Don't run time consuming gas interpolation without any dataGravatar Dirk Hohndel
If the user hasn't set any pressures at all there is no point in trying to interpolate all these data. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05DiveObjectHelper: check if dive has only one weightsystemGravatar Dirk Hohndel
The mobile app should only allow editing the weight entry if there is no second weight defined. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05Simplify sumWeight functionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05Add helper function to parse weight stringsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05Do not run the deco calculations in the mobile appGravatar Dirk Hohndel
We don't show the calculated ceilings and calculating them is compute intensive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-04Allow merging of dives with zero depth/durationGravatar Miika Turkia
Fixes #1003 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-03Fix Liquivision import crashGravatar Miika Turkia
When we detect a redundant DC we free the memory reserved for the model. Thus we need to malloc that memory here. Fixes #1002 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-01Silence compiler warningsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-31Mark CCR dive's divetype properlyGravatar Miika Turkia
We used to mark CCR dives by having "SP change" event at time 0:00. As we nowadays mark CCR dives by setting dc->divemode appropriately, better to convert the old dives to this format as well. This way we do not have to take the special old format into account on multiple places in the source. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-27Move helper function to DiveObjectsHelperGravatar Joakim Bygdell
As per Tomaz recomendation the helper functions from 19588ce and e072596 are moved from qmlmanager to DiveObjectsHelper. [Dirk Hohndel: merged with the latest code] Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-26QML UI: don't combine multiple trips to the same location into oneGravatar Dirk Hohndel
The way sectioning of the dive list works is by watching for different strings in the section.property. In order to be able to tell different trips apart we combine the address of the dive trip variable with the location (which will create a new section for a new trip, even if the location text is the same) and then strip that information out before showing the trip header. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-26Fix usage of QStringGravatar Tomaz Canabrava
1 - Pass QStrings by const-ref 2 - Don't initialize empty strings with "", they are empty by default 3 - Don't compare empty strings with "", use .isEmpty() 4 - don't append or prepend " ", use QChar(' ') 5 - don't compare QStrings with "constant string", use QLatin1String(" constant string" ) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-26Move CloudStorage out of the widgetsGravatar Tomaz Canabrava
Cloud Storage is a non-gui based class, we currently use two different approaches for cloud storage, one on the desktop target and other on the mobile target, we should use only one. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25Fix bug on the visibility of the Ruler GraphGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25Changed quite a few shorts to bool on the c++ implementtionGravatar Tomaz Canabrava
The shorts where being used on the preferences since a long while and we cannot just simply change them to bool since this could break the preferences files, so work around that by changing them to booleans, since it's the correct type for a true / false answer. Also, move some plot curves to the new settings style Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25Start to use the QSettings ObjectWrapperGravatar Tomaz Canabrava
start of the QSettinsg Object Wrapper usage on the code this first patch removes two macros that generated around 200 lines in runtime for something like a quarter of it Basically, whenever we changed anything we called the PreferencesDialog::settingsChanged and connected everythign to that signal, now each setting has it's own changed signal and we can call it directly. The best thing about this approach is that we don't trigger repaints for things that are not directly profile related. ( actually we still do, but the plan is to remove them in due time) this commit breaks correct atualization of the profile (because everything was connected to PreferencesDialog::settingsChanged) and now I need to hunt a bit for the correct connections Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-24Make it compileGravatar Tomaz Canabrava
This is not hoocked up on Subsurface code yet, but it's already being compilled. now I just need to hoock things up. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-24Finalize the SettingsGravatar Tomaz Canabrava
This was the hammer part of the settings, now I need to make it able to compile ;p Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>