Commit graph

202 commits

Author SHA1 Message Date
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
Joakim Bygdell
f3b35d175a QML UI: add function to get cylinder pressures
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-09 12:10:50 -08:00
Joakim Bygdell
9c5b97e6cf Add helper to parse pressure strings.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-09 12:10:36 -08:00
Dirk Hohndel
2df1e0b342 Don't run time consuming gas interpolation without any data
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-07 07:22:41 -08:00
Dirk Hohndel
ad7fb80d0a DiveObjectHelper: check if dive has only one weightsystem
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-05 22:53:12 -08:00
Dirk Hohndel
535a6b9b25 Simplify sumWeight function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05 22:52:30 -08:00
Dirk Hohndel
587456190f Add helper function to parse weight strings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05 22:51:46 -08:00
Dirk Hohndel
130f4cd7ac Do not run the deco calculations in the mobile app
We don't show the calculated ceilings and calculating them is compute
intensive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05 20:45:18 -08:00
Miika Turkia
24e2f83d67 Allow merging of dives with zero depth/duration
Fixes #1003

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-04 12:38:48 -08:00
Miika Turkia
520f505d20 Fix Liquivision import crash
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-03 06:06:23 -08:00
Robert C. Helling
c32f5cc278 Silence compiler warnings
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-01 18:01:05 -08:00
Miika Turkia
448abec769 Mark CCR dive's divetype properly
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-31 13:06:39 -08:00
Joakim Bygdell
9342dedb26 Move helper function to DiveObjectsHelper
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-27 11:18:44 -08:00
Dirk Hohndel
35e60a7355 QML UI: don't combine multiple trips to the same location into one
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-26 20:06:30 -08:00
Tomaz Canabrava
ccf29679ae Fix usage of QString
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-26 09:51:14 -08:00
Tomaz Canabrava
8b7427c56d Move CloudStorage out of the widgets
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-26 09:50:32 -08:00
Tomaz Canabrava
411f455291 Fix bug on the visibility of the Ruler Graph
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:39 -08:00
Tomaz Canabrava
2d96139566 Changed quite a few shorts to bool on the c++ implementtion
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-25 13:04:16 -08:00
Tomaz Canabrava
2c5fad73e8 Start to use the QSettings ObjectWrapper
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-25 13:04:01 -08:00
Tomaz Canabrava
fd175e8781 Make it compile
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-24 21:27:05 -08:00
Tomaz Canabrava
b01bca7953 Finalize the Settings
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>
2016-01-24 21:26:57 -08:00
Tomaz Canabrava
ac3ba70fdb Remove prefs already implemented.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-24 21:26:52 -08:00
Tomaz Canabrava
c3137cf07c Language Settings Wrapper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-24 21:26:45 -08:00
Tomaz Canabrava
15fece7da2 Added Display Settings
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-24 21:26:38 -08:00
Tomaz Canabrava
e7412b11b9 Added a GeneralSettingsWrapper
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-24 21:26:35 -08:00
Anton Lundin
451293f1a0 configure OSTC/OSTC3: Add safety stop parameters
This adds the configure parameters for safety stops on the hwOS(OSTC3)
and OSTC computers.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-22 06:50:22 -08:00
Anton Lundin
91a72f45d4 configure OSTC3: Add temperature sensor offset
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-22 06:50:18 -08:00
Anton Lundin
128fc39274 Use libdivecomputer libc wrappers instead of Qt
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-22 06:50:10 -08:00
Anton Lundin
b2da9abae1 Remove unused headers
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-22 06:50:06 -08:00
Anton Lundin
e59e067042 Remove workaround for OSTC Sport 10.22 and below
Now with firmware 10.23, the settings behave as they should, and won't
hang the communication.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-22 06:50:01 -08:00
Dirk Hohndel
c2eeda44e6 Avoid precision loss on GPS fixes
It appears that the Qt documentation might be incorrect. It claims that
the precision value is digits after the decimal point, but we have seen
examples where the values posted to the server appear to have a total of 6
digits, including the digits ahead of the decimal point.

Upping this to 9 shouldn't hurt if Qt gets fixed, but should work around
the issue reported by a tester.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-22 06:41:43 -08:00
Dirk Hohndel
6faf33047e Return a value when getting SAC rate
Obvious "mass edit" error.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-21 12:41:40 -08:00