Commit graph

74 commits

Author SHA1 Message Date
Martin Měřinský
92e9c6606f Use consistent aliases for all icons.
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase.
With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs.
prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some
icons didn't have alias at all.

This changes all icon aliases to one, easy grep-able style which complies
to Freedesktop Icon Naming Specification (Guidelines).

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29 11:46:35 +01:00
Berthold Stoeger
82898a837d Fix toggling of partial pressure graphs
When toggling the display of the partial pressure graph, the graph was
either not shown correctly or unnecessary ticks were left in the graph.
Calling the settingsChanged() method of the profileYAxis object solves
the problem by initializing the ticks according to the selected graphs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-25 15:42:44 -08:00
Stefan Fuchs
5da6362679 In strings change tank to cylinder
Change the word "tank" to "cylinder" or "cyl." in two occurences.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 15:41:28 -08:00
Robert C. Helling
088db5e12b Hand planner variables to profile
Pass the planner state struct to the profile computation so it can use
deco_time and first ceiling to display VPM-B ceiling.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-11-25 20:13:01 +01:00
Berthold Stoeger
178dcbc0c6 Fix obscure display bug in profile widget, where heat map wasn't shown
Fixes an obscure bug, which happened under very specific circumstances.
Precodition: fresh program start and neither of the partial pressure
graphs, nor the heat maps are shown. User clicks on heat map icon.
Bug: The heat map is not shown at the bottom of the graph.

The fix consists in replacing two percentageAxis->setLine() calls
by precentageAxis->animateChangeLine() calls.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-23 14:15:00 -08:00
Berthold Stoeger
f8fcd65bc4 Prevent signed/unsigned comparison warning
Change an unsigned integer to a signed integer in profilewidget2.cpp,
because commit 1f8506c changed the definition of duration_t from
unsigned to signed.

Since this value represents the number of seconds since a dive started,
there is no possible chance of overflow problems.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-18 21:50:43 +01:00
Dirk Hohndel
e64dcd12bd desktop UI: no longer attempt to manually show error notifications
report_error() now does this automatically. So all these odd places in which we tried
to make sure that we show errors are no longer needed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-26 15:55:49 +02:00
Stefan Fuchs
022b3e450b Translate dc text in profile also if string has suffix for > 1 DC
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-20 06:38:20 -04:00
Stefan Fuchs
c3857db23b Hide outdated gas name strings in profile in planner
When deleting dive planner points in the planner we currently sometimes
miss to hide the outdated gas name strings printed close to the profile
legs.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-08 23:19:23 +02:00
Dirk Hohndel
aabcff9c54 Move unused code into the disabled block
These varaiables are only used in the code that we currently
aren't compiling.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26 12:11:44 -07:00
Linus Torvalds
e1b880f444 Profile support for multiple concurrent pressure sensors
This finally handles multiple cylinder pressures, both overlapping and
consecutive, and it seems to work on the nasty cases I've thrown at it.

Want to just track five different cylinders all at once, without any
pesky gas switch events? Sure, you can do that.  It will show five
different gas pressures for your five cylinders, and they will go down
as you breathe down the cylinders.

I obviously don't have any real data for that case, but I do have a test
file with five actual cylinders that all have samples over the whole
course of the dive.  The end result looks messy as hell, but what did
you expect?

HOWEVER.

The only way to do this sanely was

 - actually make the "struct plot_info" have all the cylinder pressures
   (so no "sensor index and pressure" - every cylinder has a pressure for
   every plot info entry)

   This obviously makes the plot_info much bigger. We used to have
   MAX_CYLINDERS be a fairly generous 8, which seems sane. The planning
   code made that 8 be 20. That seems questionable. But whatever.

   The good news is that the plot-info should hopefully get freed, and
   only be allocated one dive at a time, so the fact that it is big and
   nasty shouldn't be a scaling issue, though.

 - the "populate_pressure_information()" function had to be rewritten
   quite a bit. The good news is that it's actually simpler now, although
   I would not go so far as to really call it simple. It's still
   complicated and suble, but now it explicitly just does one cylinder at
   a time.

   It *used* to have this insanely complicated "keep track of the pressure
   ranges for every cylinder at once". I just couldn't stand that model
   and keep my sanity, so it now just tracks one cylinder at a time, and
   doesn't have an array of live data, instead the caller will just call
   it for each cylinder.

 - get rid of some of our hackier stuff, like the code that populates the
   plot_info data code with the currently selected cylinder number, and
   clears out any other pressures. That obviously does *not* work when you
   may not have a single primary cylinder any more.

Now, the above sounds like all good things. Yeah, it mostly is.

BUT.

There's a few big downsides from the above:

 - there's no sane way to do this as a series of small changes.

   The change to make the plot_info take an array of cylinder pressures
   rather than the sensor+pressure model really isn't amenable to "fix up
   one use at a time". When you switch over to the new data structure
   model, you have to switch over to the new way of populating the
   pressure ranges. The two just go hand in hand.

 - Some of our code *depended* on the "sensor+pressure" model. I fixed all
   the ones I could sanely fix. There was one particular case that I just
   couldn't sanely fix, and I didn't care enough about it to do something
   insane.

   So the only _known_ breakage is the "TankItem" profile widget. That's
   the bar at the bottom of the profile that shows which cylinder is in
   use right now. You'd think that would be trivial to fix up, and yes it
   would be - I could just use the regular model of

     firstcyl = explicit_first_cylinder(dive, dc)
     .. then iterate over the gas change events to see the others ..

   but the problem with the "TankItem" widget is that it does its own
   model, and it has thrown away the dive and the dive computer
   information. It just doesn't even know. It only knows what cylinders
   there are, and the plot_info. And it just used to look at the sensor
   number in the plot_info, and be done with that. That number no longer
   exists.

 - I have tested it, and I think the code is better, but hey, it's a
   fairly large patch to some of the more complex code in our code base.
   That "interpolate missing pressure fields" code really isn't pretty. It
   may be prettier, but..

Anyway, without further ado, here's the patch. No sign-off yet, because I
do think people should look and comment. But I think the patch is fine,
and I'll fix anythign that anybody can find, *except* for that TankItem
thing that I will refuse to touch. That class is ugly. It needs to have
access to the actual dive.

Note how it actually does remove more lines than it adds, and that's
despite added comments etc. The code really is simpler, but there may be
cases in there that need more work.

Known missing pieces that don't currently take advantage of concurrent
cylinder pressure data:

 - the momentary SAC rate coloring for dives will need more work

 - dive merging (but we expect to generally normally not merge dive
   computers, which is the main source of sensor data)

 - actually taking advantage of different sensor data from different
   dive computers

But most of all: Testing.  Lots and lots of testing to find all the
corner cases.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-27 14:45:58 -07:00
Linus Torvalds
1e38d9239a Start cleaning up sensor indexing for multiple sensors
This is a very timid start at making us actually use multiple sensors
without the magical special case for just CCR oxygen tracking.

It mainly does:

 - turn the "sample->sensor" index into an array of two indexes, to
   match the pressures themselves.

 - get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index},
   since a CCR dive should now simply set the sample->sensor[] indices
   correctly instead.

 - in a couple of places, start actually looping over the sensors rather
   than special-case the O2 case (although often the small "loops" are
   just unrolled, since it's just two cases.

but in many cases we still end up only covering the zero sensor case,
because the CCR O2 sensor code coverage was fairly limited.

It's entirely possible (even likely) that this migth break some existing
case: it tries to be a fairly direct ("stupid") translation of the old
code, but unlike the preparatory patch this does actually does change
some semantics.

For example, right now the git loader code assumes that if the git save
data contains a o2pressure entry, it just hardcodes the O2 sensor index
to 1.

In fact, one issue is going to simply be that our file formats do not
have that multiple sensor format, but instead had very clearly encoded
things as being the CCR O2 pressure sensor.

But this is hopefully close to usable, and I will need feedback (and
maybe test cases) from people who have existing CCR dives with pressure
data.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-21 16:33:19 -07:00
Stefan Fuchs
b8347d2387 Translate the strings "planned dive" and "manually added dive" in the profile
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-06-22 10:38:54 +09:00
Robert C. Helling
53a8075bd8 Fix right boundary when moving last handle in planner
There was a bug in the old code due to confusion between minutes
and seconds as the unit of the time axis. But rather than limiting
the time for the last handle in terms of the time axis (which
potentially includes long deco and allowing that for bottom time
quickly leads to dives many many hours long) limit it to 150%
of the previous bottom time.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:46:41 -07:00
Dirk Hohndel
49d0bb8406 Add SPDX header to profile widgets
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Jan Mulder
5a235aea12 minimal pO2 threshold: color the p02 graph also for minumum
Color the p02 graph also in red for going under the minumum p02 value as
set in the Preferences.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-03-28 11:17:03 -07:00
Jan Mulder
bb31c77597 minimal pO2 threshold: split max threshold into min and max
Nothing really special here. Just a split of the only p02 max threshold into
a min threshold and max threshold, and the adaptation of the UI. Change of
translatable strings included.

ref: https://github.com/Subsurface-divelog/subsurface/issues/259

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-03-28 11:17:03 -07:00
Joakim Bygdell
bd0c99dfb7 MOBILE: Display pO2 and Setpoint for CCR dives
For CCR dives we want to display the setpoint and pO2 information,
due to the limited screensize we have to remove the temperature graph or
the view will be to cluttered.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-03-26 21:57:57 -07:00
Jeremie Guichard
597539ce39 Fix double to int truncation in C++ code
Wfloat-conversion enabled for C++ part of the code
Fix warnings raised by the flag using lrint

Original issue reported on the mailing list:
The ascent/descent rates are sometimes not what is expected.
E.g. setting the ascent rate to 10m/min results in an actual
ascent rate of 9m/min.
This is due to truncating the ascent rate preference,
then effectively rounding up the time to reach each stop to 2s intervals.
The result being that setting the ascent rate to 10m/min
results in 20s to ascend 3m (9m/min), when it should be exactly 18s.

Reported-by: John Smith <noseygit@hotmail.com>
Reported-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-24 09:39:25 -07:00
Dirk Hohndel
08284275e7 Merge branch 'master' of https://github.com/dje29/subsurface 2017-03-11 08:41:41 -08:00
Martin Měřinský
dcf2542215 Use abbreviations with dots. 2017-03-11 08:09:07 -08:00
Robert C. Helling
eae4bd82a5 Change type of divedatepoint.depth to depth_t
... for consistency, while we are at it.

There are still some internal depth variables which are ints
somebody might take a go at those.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-03-11 08:03:25 -08:00
Jeremie Guichard
406e4287eb Change calls to rint into lrint avoiding conversion warnings
Using gcc option "-Wfloat-conversion" is useful to catch
potential conversion errors (where lrint should be used).
rint returns double and still raises the same warning,
this is why this change updates all rint calls to lrint.
In few places, where input type is a float, corresponding
lrinf is used.

Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
2017-03-08 14:04:17 +07:00
Martin Měřinský
b14301a84c heartrate, heartbeat > heart rate 2017-03-04 12:08:17 -08:00
Martin Měřinský
59d18a00db divecomputer > dive computer 2017-03-04 12:08:17 -08:00
Stefan Fuchs
7eda24d6b1 Correct "set-point" -> "setpoint" and window title setpoint change
Change 2x "set-point" to "setpoint".
Correct window title for "Add setpoint change" window.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-03-04 12:04:20 -08:00
Joakim Bygdell
12c33a038f Mobile: Do not show tankbar for CCR dives
If we are showing the setpoint and sensor pO2 we need the space.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-02-05 12:20:33 -08:00
Joakim Bygdell
11ccadbab5 MOBILE: Reposition objects in the profile
Add the tankbar to the profile and change the relative positions of the depth
and temperature curves to minimize overlap.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-02-05 11:59:47 -08:00
Robert C. Helling
2516ae7e5f Let cylinderid = -1 mean same gas as before
It's not too clever to give 0 a special meaning (as here:
use same gas as for previous leg) when 0 is a legitimate
value.

This should solve Willem's gas disappearance problem when
reediting a dive in the planner.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-02-04 07:09:35 -08:00
Dirk Hohndel
f5a4838519 Fix dive visual editor being too quick to rescale time
When moving the last handle of a dive (in the planner, in dive add, or
when editing a dive), we rescaled the time axis whenever our idea of the
maximum duration that we should show changed. That lead to the odd
situation that you couldn't get to certain dive durations with the
visual editor (e.g. 64 minutes) because just as you approach that time
the scale changes and the dive duration jumps past the desired value.

Fixes issue #174

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-01-28 21:04:50 -08:00
Joakim Bygdell
f7cecf506f Don't let the tankbar overlap the tissue heatmap
Shift the position of the tankbar to prevent it from overlapping the tissue heatmap

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
2017-01-21 06:07:31 -08:00
Robert C. Helling
bb4bf639c3 Fix deco_mode confusion
We have two prefernces determining the deco_mode (BUEHLMANN vs VPMB
vs RECREATIONAL): One for the planner (deco_mode) and one for
displaying dives (display_deco_mode). The former is set in the planner
settings while the latter is set in the preferences.

This patch clears up a confusion which of the two to use by introducing
a helper function that selects the correct variable.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-01-06 20:43:23 -08:00
Tomaz Canabrava
37e3e7e69a Deco mode for plannining is not deco mode for showing
We had (in the wrong place, imo) a new feature that
should differentiate the different deco_modes, you could
plan your dive in buelhman and see it in vpm-b, for instance
but both of them accessed the same pref.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:41:17 -07:00
Tomaz Canabrava
27d1385c65 Use the new preferences object to set the preferences
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-11-01 09:40:06 -07:00
Rick Walsh
7e09a6c7bc Separate VPM-B conservatism preference for planner and profile
Separate the VPM-B conservatism preference into diveplan.vpmb_conservatism for
planning dives and prefs.vpmb_conservatism for profile ceiling display of
saved dives.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24 08:30:11 -07:00
Rick Walsh
7b891904e7 Rename conservatism_level to vpmb_conservatism
Make the variable purpose less ambiguous

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-24 08:29:56 -07:00
Robert C. Helling
893bea700c Introduce heat map
This replaces the tissue percentage graph that probably nobody ever
understood with a heat map like the one used in the discussion
of bubble model deco. The information shown is the same but the
saturation is now in the color while the tissue determines the y
position.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-17 13:39:54 -07:00
Rick Walsh
b1ed04a7f4 Have divedatapoint store cylinder id instead of gasmix
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-07-09 12:07:25 -07:00
Dirk Hohndel
7be962bfc2 Move subsurface-core to core and qt-mobile to mobile-widgets
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-04-04 22:33:58 -07:00
Linus Torvalds
2d760a7bff Don't write back dive data that hasn't changed in git
This caches the git ID for the dive on load, and avoids building the
dive directory and hashing it on save as long as nothing has invalidated
the git ID cache.

That should make it much faster to write back data to the git
repository, since the dive tree structure and the divecomputer blobs in
particular are the bulk of it (due to all the sample data).  It's not
actually the git operations that are all that expensive, it's literally
generating the big blob with all the snprintf() calls for the data.

The git save used to be a fairly expensive with large data sets,
especially noticeable on mobile with much weaker CPU's.  This should
speed things up by at least a factor of two.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04 17:27:10 -07:00
Dirk Hohndel
bff3588c25 Undo two more unsigned changes that are no longer needed
With this master should compile without signed / unsigned warning,
hopefully without any more breakage.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 10:11:39 -07:00
Rick Walsh
cbd332fbcc Profile widget: Display gradient factors used in plan
Currently, the gradient factors displayed at the top of the profile are the
gradient factors set in preferences.  This is correct for saved dives, but
when planning dives, the gradient factors displayed at the top of the profile
should be the gradient factors used in the plan.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-19 11:31:13 -07:00
Dirk Hohndel
4156bc3651 Silence warnings in profilewidget2.cpp
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-09 21:50:23 -08:00
Tomaz Canabrava
98e8a04d01 Silence warnings in Profilewidget2
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08 20:58:09 -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
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
17134be96d Profile: don't compile code that isn't needed on mobile
We were creating a couple dozen objects that we never needed and because
of that triggered several dozen callbacks whenever the model data changed.
All for UI elements of the profile that are either not used in the mobile
app (like the calculated ceiling or the partial pressure / tissue
saturation graphs), or are only useful when using the profile
interactively (which we also don't do on mobile).

I don't know if this will make a significant impact on performance, but it
seems like the right thing to do either way.

A positive side effect is that the odd blue line on top of the rendered
profile is gone as well.

Fixes #1007

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-06 13:29:31 -08:00
Tomaz Canabrava
2d3f7f0a90 More Profile Itens on the new Settings
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-25 13:04:21 -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
Joakim Bygdell
f747abaeb2 Small changes to the profile
Due to the small screen of mobile devices,
the positions of the temperature graph and the time axis needs to be shifted
upwards a bit to prevent them from overlapping with the dive computer name.

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-05 10:58:11 -08:00