Commit graph

233 commits

Author SHA1 Message Date
Tomaz Canabrava
91ee285d93 Silence warnings in deco.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:43:57 -08:00
Tomaz Canabrava
f81dd80a48 Silence warnings in cochran.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:43:43 -08:00
Tomaz Canabrava
19b4477cd9 Silence warnings in libdivecomputer.c
There was also a function not being used that could be safely removed.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:42:56 -08:00
Tomaz Canabrava
2258939566 Silence warnings in parse-xml.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:42:30 -08:00
Tomaz Canabrava
b77c1d0d95 Silence warnings in load-git.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:42:26 -08:00
Tomaz Canabrava
3b782da960 Silence warnings in liquivision.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:34:17 -08:00
Tomaz Canabrava
62bdc9e3ec Silence warnings in git-access.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:32:41 -08:00
Tomaz Canabrava
9d3be5a165 Silence warnings in gaspressures.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 16:32:18 -08:00
Tomaz Canabrava
04e39704e2 Fix annoyances on file.c
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 11:24:10 -08:00
Tomaz Canabrava
d7d8660bbb Clean up more unused variables
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 11:21:44 -08:00
Tomaz Canabrava
5bf0e48700 Remove unused variable
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 11:17:16 -08:00
Tomaz Canabrava
726e251ffc Simplify Q_FOREACH
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 11:16:44 -08:00
Tomaz Canabrava
3a003cb4fa Silence warnings for the GpsLocation
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 11:13:11 -08:00
Tomaz Canabrava
f25dce8511 Create a constructor with default parameters for some structs
Structs and classes in C++ are basically the same thing and we want to
create a few zero-initialized values for some of them; Sadly, C++ doesn't
have the nice static struct initialization that C has.

One way to deal with that is to create a constructor and pass default
values to it, another is lambda-initialization, but we don't use C++11,
yet.

Since we initializate stuff on the constructor, we don't need to
re-initializate things again on the initialization list (which is also why
I removed the QStrings from the initialization lists, they are
automatically initialized to empty)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 11:13:11 -08:00
Tomaz Canabrava
2745beca5f Silence warning about unused parameter
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-07 11:00:27 -08:00
Tomaz Canabrava
933b69a7cc qt-gui.h shouldn't include QApplication
[Dirk Hohndel: refactored the iOS patches]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-06 11:03:00 -08:00
Tomaz Canabrava
997ee6fb40 iOS build: don't include CoreServices on iOS
[Dirk Hohndel: refactored the iOS patches]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-06 11:03:00 -08:00
Tomaz Canabrava
39313c5b33 Clean up handling of various include file
This is in the context of the iOS port and shouldn't impact any of the
other builds.

[Dirk Hohndel: refactored the iOS patches]

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-06 11:03:00 -08:00
Dirk Hohndel
d42b7f55c4 Introduce separate version number for Subsurface-mobile
This is hard coded in version.cmake for now. The intent is to go to 1.0 in
the first release version and to increment from there whenever we create
an update.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-05 17:00:14 -08:00
Linus Torvalds
afadb6f05c gas model: use virial cubic polynomial form
The "virial" form of the Z compression factor is of the form

   Z = 1.0 + A*p + B*p^2 + C*p^3 + ..

and it's considered the "right" polynomial form to use.  It happens to
also make for one constant less per gas (since the 1.0 can be added
later), and can be used to simplify the expression and avoid a few
floating point operations.

However, in order for that kind of expression simplification to make
sense, we need to make sure that we don't calculate the powers of the
pressure multiple times either, and that means we have to inline all the
actual calculations.

Our compiler options still mean that the generated code isn't optimal,
but that's a separate issue. And it is a lot better than it used to be.

Being clever about this does potentially make the code a tiny bit less
legible, but maybe that's not too bad for something that we'd expect to
not ever touch once we get it right.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-04 10:18:07 -08:00
Dirk Hohndel
01ae4af13d Don't access undefined dive
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-03 14:29:29 -08:00
Dirk Hohndel
bf798390fa Avoid dangling else warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-03 14:29:19 -08:00
Linus Torvalds
a173a3ce79 gas model: simplify and improve our Z factor calculations
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-03 14:19:45 -08:00
Linus Torvalds
055316e4a9 gas model: add polynomials for Z factors of oxygen/nitrogen/helium
.. 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-02 18:09:41 -08:00
Linus Torvalds
3260dd9c15 gas model: replace Redlich-Kwong with least-square quintic
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-02 18:08:28 -08:00
Linus Torvalds
3f30832471 gas model: split up gas compressibility into a file of its own
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-02 18:08:18 -08:00
Dirk Hohndel
62f54b54a2 QML UI: create a chronological dive list when manually adding dive
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-03-02 04:50:00 -08:00
Robert C. Helling
84769dc2f6 This computes the compressibility of the gas depending on the mixture.
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-29 08:58:16 -08:00
Lubomir I. Ivanov
1d06c383a2 DiveHelperObject: add the weightList and cylinderList properties
"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-29 07:33:31 -08:00
Robert C. Helling
26779a9af5 If salinity is not density, add density of fresh water
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-28 15:39:52 +01:00
Linus Torvalds
45ed0ec757 gas pressures: use an actual compressibility table for air
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-25 01:22:32 +01:00
Linus Torvalds
288aff9dbb Don't use "get_volume_string()" for cylinder size string
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-25 00:58:09 +01:00
Linus Torvalds
7ebc31c1ec gas pressures: do not use gas compressibility for cylinder naming
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-25 00:45:38 +01:00
Linus Torvalds
82c003c914 gas pressures: do some initial cleanup
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-25 00:45:35 +01:00
Dirk Hohndel
86ec3d06a2 Correctly round total weight displayed
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-24 08:20:24 +01:00
Linus Torvalds
10ae00db3c pressure interpolation: incrementally update interpolation data
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-21 16:36:10 -08:00
Linus Torvalds
b71fc7ffb2 pressure interpolation: further code simplification
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-21 16:34:46 -08:00
Linus Torvalds
398cd5d9cc pressure interpolation: simplify code
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-21 16:33:39 -08:00
Linus Torvalds
1f7f3c4af5 pressure interpolation: get rid of pointless and confusing code
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-21 16:32:45 -08:00
Dirk Hohndel
a550467e8b QML UI: make unit matching case insensitive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-20 22:00:07 -08:00
Dirk Hohndel
38ab11a6c0 Add option to allocate the samples in fake_dc()
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-20 09:36:14 -08:00
Dirk Hohndel
75bd37e3e5 Clean up conversion helpers
- 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-15 07:50:30 -08:00
Dirk Hohndel
06ad45c48f Add dive property to easily test if there isn't an actual dive
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-14 16:26:37 -08:00
Miika Turkia
8e4b4c788a Grab pressures from samples if required
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-14 12:37:37 -08:00
Miika Turkia
8c38dbf3b7 Test cylinder usage properly
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-14 12:37:30 -08:00
Joakim Bygdell
8cc4463a1a Add helper function to parse gasmix strings
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-13 10:04:00 -08:00
Joakim Bygdell
a01bcd82aa Add helper function to retrieve first gas
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-13 10:03:56 -08:00
Joakim Bygdell
6252d0cd3b While parsing weight and pressure we should not change the users settings.
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-13 10:03:50 -08:00
Dirk Hohndel
9367613a77 Don't connect to remote if git_local_only is set
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-12 22:01:20 -08:00
Dirk Hohndel
055ec05e0f Don't just keep going when opening a git URL fails
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-10 21:03:52 -08:00