Commit graph

26 commits

Author SHA1 Message Date
Stefan Fuchs
c866b82f35 Planner notes min gas: Remove incorrect line wrap inside printf string
With old code the tabs at the start of the second line were incorrectly
added to the string.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Stefan Fuchs
81e9b230ca Planner notes ICD: Format HTML with DIV, do table title differently
In the planner notes format the HTML for different sections with
div tags.

Put the table title for the ICD table outside the table because then the
alignment looks a little bit nicer.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Stefan Fuchs
d3bcf02bbc Planner notes ICD: Coding style change only
Avoid the need for a char array for the "old_gas_name" by passing
two pointers to the gasmixes to the add_icd_entry function and
calling helper function gasname() there twice.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Stefan Fuchs
e408e32ed6 Planner notes ICD: Print correct runtime for gaschange
If a gaschange happens at the beginning of a segment, currently the
wrong runtime (end of segment time) is printed in the ICD table.

This is corrected here.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21 09:56:35 +01:00
Willem Ferguson
f2fe389abd Move function isobaric_counterdiffusion()
Move the above function from plannernotes.c to dive.c so that
it is available to be called from the dive log part of the
software, and not only from the planner. The following was done:

1) Edit the comment above the code to make it more accurate
2) Move the structure icd_data to dive.h
3) Create an external reference in dive.h for the above function
4) Copy the body of isobaric_counterdiffusion() to dive.c

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-20 10:10:09 +01:00
Willem Ferguson
f072f78c29 Implement ICD calculations in planner output
This patch implements the calculation and printing of icd parameters
in the dive planner output. It does:
1) icd parameters are calculated following the rule-of-fifths for
   OC trimix dives. For each gas change on the ascent that involves
   helium, the change in gas composition as well as the change in
   partial pressures are shown. If rule-of-fifths is exceeded, a
   warning message is prinetd.
2) An independent function is provided that in principle enables
   calculation of icd paramaters outside of the context of the
   dive planner.

Further updates to icd calculations

These changes respond to #1047. Code style conventions have been
improved. The ICD table is now also printed when the planner is
set to verbatim mode. The code that created the html icd results
has been moved to a function. This does not make the code more
efficient (many parameters passed) but it makes the code more clean.

Free a new dynamic variable (old_gas_name)

Stylistic changes to new code in plannernotes.c

Changes in comments to explain some of the changes I made.
Preparation of comments and functioning of isobaric_counterdiffusion()
and its dependent data structure for possible transfer to dive.c
and dive.h after finalisation and merging of the present PR.
Smaller stylistic changes to conform to our coding rules.

The several comments and suggestions during github review
(@atdotde, @leolit123, @sfuchs79) are incorporated.

Fixed up mis-aligned comments and text descriptions by replacing
tab characters with space characters, thereby hard-forcing
alignment of indented lines of text.

Remove parameter *dive from function isobaric_counterdiffusion().

Improve a few constructs to conform to our style rules.

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-19 19:43:16 +02:00
Willem Ferguson
082def8162 Fix indentations for plannernotes.c
The last 2 commits have now been squashed.
S Fuchs's comment on line 315 has been fixed

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-11 21:47:04 +01:00
Rick Walsh
34236e3c84 Planner notes: don't omit deco stops with rapid ascent rates
This fixes a bug where if the user entered very high ascent (or less commonly
descent) rates such that the time to ascend (or descend) from one level to the
next was less than 10s, that leg would be skipped in the dive plan notes.

Reported-by: Alexander Maier <maieralex@me.com>
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-12-28 19:11:31 -08:00
Dirk Hohndel
424e757094 Cleanup: avoid memory leak
Coverity CID 208308

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-26 15:57:44 -08:00
Berthold Stoeger
a748e7f239 Unify float calulations: use double
Internal floating point (FP) calculations should be performed using double
unless there is a very good reason. This avoids headaches with conversions.
Indeed, the vast majority of FP calculations were already done using double.
This patch adapts most remaining calculations. Not converted where things
that were based on binary representations and variables which weren't used
anyway.

An analysis of all instances follows:

core/plannernotes.c, l.404:

This was a comparison between two floats. On the left side, first an integer
was cast to float then multiplied with and integer and divided by a constant
double. The right hand side was an integer cast to a float. Simply divide by
1000.0 first to convert to double and continue with calculations. On the right
hand side, remove the cast, because the integer will be implicitely cast to
double for comparison. This conversion actually emits less instructions,
because no conversion to double and back is performed.

core/planner.c, l.613:

Same analysis as previous case.

subsurface-desktop-main.cpp, l.155:

A local variable representing the version OpenGL version. Turn this into
integer logic. Not only does this avoid dreaded FP rounding issues, it also
works correctly for minor version > 10 (not that such a thing is to be
expected anytime soon).

abstractpreferenceswidget.[h/cpp]:

A widget where the position is described as a float. Turn into double.

desktop-widgets/divelogexportdialog.cpp, l.313:

total_weight is described as float. Use double arithmetics instead. This
instance fixes a truncation warning emitted by gcc.
2017-12-17 09:02:44 -08:00
Robert C. Helling
d8350ef238 Document background computation of variations
Update changelog, update user manual, clarify
meaning in dive notes.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-12-01 15:47:51 -08:00
Rick Walsh
1985bcb29e Disable plan variation in recreational mode
Calculating variations when in recreational mode doesn't make sense, and can
prevent variations from being calculated when switching back to Buhlmann or
VPM-B modes.

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
2017-12-01 15:47:51 -08:00
Stefan Fuchs
f6b00fb3dd Round up diveplan duration the same way values in diveplan are rounded
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-12-01 15:47:51 -08:00
Stefan Fuchs
72318f2897 In strings start lower case in parenthesis
Start with lower case letter inside a parenthesis.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-25 15:41:28 -08:00
Berthold Stoeger
ebb8e1dc27 Trivial: fix indentation
Fix an obvious indentation bug where one line more than intended
was indented.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-19 00:21:45 +01:00
Stefan Fuchs
16f330e6c9 Planner remove unnecessary gas consumption info from notes
If we consumed 0l/0bar in total from a cylinder there is no need to also
state that we consumed 0l/0bar during ascend.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-30 21:45:56 +01:00
Salvador Cuñat
1095b78071 Planner: Do not translate VARIATIONS
This string is substituted with the runtime increments derived of slight
variations in depth or bottom time in:

diveplannermodel.cpp:1058:
displayed_dive.notes = strdup(notes.replace("VARIATIONS", QString(buf)).toUtf8().data());

Translating it avoids substitution and we just get the translated
string.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
2017-10-28 08:19:18 +02:00
Stefan Fuchs
4158a4c7de init_deco correctly identify previous dives and report overlapping dives
When changing the date/time of a dive in the planner the dive may end
up in a totaly new position in respect to date/time of other dives in
dive list table. It can be moved to the past or the future before or after
other existing dives. It also could overlap with an existing dive.

This change enables identification of a new "virtual" dive list position
and based on this starts looking for previous dives.
Then it (as before the change) does init the deco calculation with any
applicable previous dive and surface interval.
If some of these applicable dives overlap it returns a neg. surface time
which is then used in the planner notes to prohibit display of results.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 23:19:13 +02:00
Stefan Fuchs
ba7be8f335 plannernotes.c coding style fixes
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 17:41:42 +02:00
Stefan Fuchs
94e563a94e Minimum gas calculation: Change text colors for delta value output...
and adapt the strings for translation to s.th. which can be handled more
easily.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 17:41:42 +02:00
Stefan Fuchs
8786003c11 Planner minimum gas calculation: Print delta pressure in results
Print the delta between the required minimum gas result and the cylinder
pressure at last bottom datapoint in results.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-04 08:46:14 +02:00
Robert C. Helling
a6f186279f Add a checkbox to turn off plan variations
... as those come with a performance penalty

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-09-20 08:54:41 -07:00
Robert C. Helling
aed5b7d267 Show variations in Runtime string
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
58d7948871 Change color to red if minimum gas is violated.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29 06:49:44 -07:00
Robert C. Helling
c979d9f166 Always show the ascent to the initial deco stop
...even when not showing transitions, this makes the
first stop look more like a stop (since it does not include
several minutes of ascent).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-03 11:17:33 -07:00
Robert C. Helling
b1ccd2fc43 Move planner notes to separate file
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-05-26 15:44:36 -07:00