Commit graph

360 commits

Author SHA1 Message Date
Tomaz Canabrava
00c97e710f Remove a Lot of Dead Code.
This is just removal of dead code from the old profile, probably there's
still a bit more to remove, but this is a very good cleanup already.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07 08:56:06 -08:00
Dirk Hohndel
211ff0e63b Fix theoretical uninitialized read
We should never read cur_pr[cyl] if cyl isn't used during a dive - but for
cylinders that are used cur_pr[cyl] is initialized. But just to catch
errors elsewhere, let's not leave cur_pr[cyl] uninitialized.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06 16:16:10 -08:00
Dirk Hohndel
d24d2288f3 Remove pointless assignments
tissue_tolerance wasn't used after it was assigned.
type was overwritten after it was assigned.
serial was overwritten after the last /= 100.
event is assigned in the for loop.
clear isn't used after the assignment

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 21:40:56 -08:00
Dirk Hohndel
7c535452f9 Whitespace cleanup
Minor change to the perl postprocessing script and resulting changes to
the affected source files.

This deals with two issues:
- "foreach"-like structures were not always treated correctly
- some longer calculations that ended on "+ constant" were reformatted in
  a rather unatractive manner

In one source file (divelist.c) I ended up adding braces to the sources...
trying to cascade the indentation further down without having the block
there seemed a lot more trouble than it's worth.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 13:29:22 -08:00
Dirk Hohndel
76e6420f6b Massive automated whitespace cleanup
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 20:09:57 -08:00
Tomaz Canabrava
8c56b2f45e Store zoomed plot in preferences
This patch makes the 'Zoomed Plot' a preference that can be stored and
retrieved, this way if the user sets the plot to be 'zoomed', this
information will persist even if they closed or opened subsurface again.

Also, added the 'Scale' button on the new profile, but didn't did the glue
code yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27 10:48:35 -08:00
Andrey Zhdanov
fdc11abe68 Typesetting in profile infobox
There should be a space between the colon and the value in the information
box in the profile.  The vertical speed should have only one digit after
the decimal point.

Fixes #443

Signed-off-by: Andrey Zhdanov <andrjufka@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-26 15:38:46 -08:00
Dirk Hohndel
41abab7253 Calculate minimum and maximum heartrate
And setup the axis accordingly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-23 14:32:25 -08:00
Dirk Hohndel
4c68d4c616 Make sure that there are plot_info entries for events
We use the plot_info as basis for our dataModel in the new profile. In
order to be able to place events at the right spot we need to have a
plot_info entry when the event happens. So let's add interpolated entries
not only based on time but also whenever there's an event between them.

This should address Robert's comment in commit 0474fe70fc ("New profile:
add image pixmaps for image events").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-23 08:36:20 -08:00
Dirk Hohndel
8a4a693cb7 Don't use the same variable for new and old profile
This will make no difference when we remove the old profile, but for now I
worry that this could cause us trouble.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 19:50:19 -08:00
Dirk Hohndel
4e5e87c51d Don't return a stack variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 19:10:35 -08:00
Linus Torvalds
23baf20f56 Use "rint()" instead of rounding manually with "+ 0.5"
rint() is "round to nearest integer", and does a better job than +0.5
(followed by the implicit truncation inherent in integer casting).  We
already used 'rint()' for values that could be negative (where +0.5 is
actively wrong), let's just make it consistent.

Of course, as is usual for the messy C math functions, it depends on the
current rounding mode.  But the default round-to-nearest is what we want
and use, and the functions that explicitly always round to nearest
aren't standard enough to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:49 -08:00
Linus Torvalds
e58f54cac1 Fix ATM-vs-bar confusion
SAC should be calculated in relationship to surface pressure, not "1 bar".

I also realize that we have a few other cases where we do the same
mistake: the partial pressure calculations do things like

    po2 = o2 / 1000.0 * depth_to_mbar(sample->depth.mm, dive);

which is wrong as well - the partial pressure is also relative to
standard atmospheric pressures.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11 14:05:54 -08:00
Boris Barbulovski
3e41047d41 Fix plot_info calculate_max_limits_new() function return value
The return value(structure) was not fully initialized, thus random data
returned for uninitialized members possibly causing random bahavior.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:54:17 -08:00
Linus Torvalds
50424df653 Use 'struct membuffer' for profile info string generation
The profile info was generated using nasty string concatenation that the
membuffers are much better at anyway.  And membuffers don't need those
arbitrarily sized fixed buffers (500 bytes? Why 500 bytes?).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:03:27 -08:00
Linus Torvalds
22f66501ac Add support for heartrate and bearing information in samples
libdivecomputer already supports this, but we didn't save it.

Tested-by: Oscar Isoz <jan.oscar.isoz@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10 07:03:24 -08:00
Tomaz Canabrava
40cb57b202 Adapt the ToolTip to work on the new profile
With this patch the tooltip is ready to work on the new profile, we just
need to actually use it.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06 06:29:19 -08:00
Tomaz Canabrava
25b0a846af Created a method to check if calculations should take place.
Created a method to check if calculations should take place
taking into consideration what changed on the model. if the
model changes *everything*, them, all calculations should
be done, but if just some of the columns of the model are
changed, only those columns should trigger an visual update
on the items.

In theory this patch looks right, but something is wrong (
calculations are not being made. ), so I'll commit this any
how, and fix on the next commit.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05 06:30:33 -08:00
Tomaz Canabrava
92446f0009 Always calculate deco data, independent of preferences
This is a better way since we can enable / disable the deco by changing
the preferences later, and that will not need to recalculate everything
just because a polygon was set to invisible.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-29 09:33:45 -08:00
Tomaz Canabrava
c99089e1fa Add settings awareness for the PP graph
This commit is rather big, and I forgot to cut it in pieces.
The first part creates a new 'calculate_gas_information' that will not
fill the profile_info->maxpp member ( that should be removed from it as
soon as the new dialog is finished ). The reason for that is that all of
the profile data will be calculated and the graph needs to update
dynamically, so whenever the settings changes, I ask for the model which
is the biggest graph and replot only the ones we need.

The second part adds a new animation function 'animdelete' to fade-out and
delete the item when it's done. the old function 'hide' did just that but
a hide shouldn't delete anything.

The third part is preferenes awareness for the PP graphs. I created two
new functions that receive the settings key for visibility and use the
QSettings to show / hide them. This also works quite well for the axis;
if no graph is visible, the axis will also hide itself.

The fourth part is colors. The pp graphs now have the correct colors.

And a bit of code cleanup too.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27 09:15:28 -08:00
Tomaz Canabrava
779c1b6738 Create a version of create_graph_info that doesn't depend on GC.
This version of the create plot info is the same as before, with the
difference that it doesn't depends on the gc.
Also fixed a crash.

The Pressure Index, Information and interpolated seems wrong,
I'm getting only zeroes.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17 14:04:47 -08:00
Dirk Hohndel
a27f67c026 Whitespace and coding style updates
Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...

This commit should ONLY change whitespace

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 11:50:56 +07:00
Tomaz Canabrava
dd64f1792d Reworked the calculate_max_limits and plotted the dive.
Created a new version of calculate_max_limits that doesn't have a
graphics_context and returns a plot_info. The code is basically the same
as the old calculate_max_limits, so there's not much to talk about.

The rest of the code is just boilerplate to plug the Profile
code with the axis and model stuff, to be plotted on screen.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:31 +07:00
Tomaz Canabrava
7d5cf32501 Added a Model that should handle the Dive Profile
This model encapsulates the plot_info struct and provides
a consistent way to show it using the Qt Model view system
in the C++ and QML way. For a QGraphicsItem that should show
a Profile, this is the start.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 10:12:30 +07:00
Anton Lundin
33391a77e9 Convert the C code to using stdbool and true/false
Earlier we converted the C++ code to using true/false, and this converts
the C code to using the same style.

We already depended on stdbool.h in subsurfacestartup.[ch], and we build
with -std=gnu99 so nobody could build subsurface without a c99 compiler.

[Dirk Hohndel: small change suggested by Thiago Macieira: don't include
               stdbool.h for C++]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16 09:34:50 +07:00
Rodrigo Severo
c32c28d40b Interpolated pressure should always be set
Interpolated pressure should always be set, even it we didn't
calculate a new one. In this case we should just use the last one.

Signed-off-by:Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09 07:08:57 +08:00
Dirk Hohndel
fef4d15965 When interpolating tank pressures, don't devide by zero
When an interpolated segment is on the surface we get no pressure time -
and try to divide by zero.

(plus a small whitespace issue that slipped throught the cracks earlier)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 21:05:16 +08:00
Rodrigo Severo
eec5dba1c2 Reinstating SURFACE_THRESHOLD test in pressure_time function
The small straight parts at the end of tank pressure lines are more of a
aesthetic issue, not causing real harm so it is no reason to remove the
SURFACE_THRESHOLD test from pressure_time function only because of this.

Also improved interpolate data debuging, rearranged
get_pr_interpolate_data and removed an unused variable from
get_pr_interpolate_data. No real change here, just trying to make the code
clearer.

[Dirk Hohndel: clean up whitespace damage from this and the previous
               commit]

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 20:38:17 +08:00
Rodrigo Severo
8f0c8be245 Discontinuity and stall on tank pressure interpolated lines
Interpolated lines for tank pressures were presenting discontinuities
(sudden drops) and stalls (horizontal lines) with certain dive profiles.

The main reason seems to be that the discrete interpolation of tank
pressure was adding small pressure increments that could be rounded down
or up repeatedly generating cumulative rounding errors that would mean
either a delay on pressure drop that would be drawn as a sudden drop or as
a premature pressure drop that would result in a flat line.

This patch changes the way the discrete interpolation is done, so that we
don't have cumulative rounding errors distorting tank pressure lines.

To calculate accumulated pressure_time values the get_pr_interpolate_data
function was created. The fact that get_pr_interpolate_data transverses
the beginning of the plot_info entry list for each entry that needs
interpolated tank pressure isn't optimal at all. There might be a way to
properly track the data necessary to interpolate tank pressures from
inside the main pi->entry loop in fill_missing_tank_pressures.
Unfortunately I didn't manage to do it inside fill_missing_tank_pressures
so we have get_pr_interpolate_data.

The SURFACE_THRESHOLD test from pressure_time function was also removed as
no matter how shallow the diver is, if he is using the cylinder to breathe
the cylinders tank pressure should be affected.

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08 20:35:07 +08:00
Rodrigo Severo
763c64d0da Typos on comments
Fixing 2 typos on comments.

Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-01 09:44:51 -08:00
Anton Lundin
c49f7133c3 Add preprocessor directives around debug functions
These adds some ifdef's around some debug functions to disable them when
not using them.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Anton Lundin
25c3eb26dc Remove some dead code
last_pressure is updated a couple of lines later, so no need to do it
here.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11 03:13:30 +01:00
Anton Lundin
01fdd2876a Plug memory leaks in compare_samples
Free temporary buffer before returning.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11 03:13:30 +01:00
Anton Lundin
04bbfe2ab1 Disable calc_ndl_tts for print
NDL and TTS doesn't show up in the printed profiles, and it takes
significant time to calculate, so just don't do it.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03 15:22:49 -08:00
Alexandre Belloni
197b8e0bee Ruler: display maximum descent and ascent speed
While playing with the ruler, I figured that it happened only once that
my minimum speed was not 0 for a segment long enough to get any display.
And it was a "dive" in an hyperbaric chamber...

This patch replaces the minimum speed with the maximum descent speed and
the maximum speed with the maximum ascent speed.

Signed-off-by: Alexandre Belloni <alexandre.belloni@piout.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 07:18:01 -08:00
Alexandre Belloni
b244226fa8 compare_samples: Remove unnecessary space before units
Signed-off-by: Alexandre Belloni <alexandre.belloni@piout.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 07:15:54 -08:00
Anton Lundin
ea9b179933 Don't interpolate gas consumption when at surface
Don't calculate pressure-track for depth above SURFACE_THRESHOLD,
because then we would guess that were actually at surface breathing.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-20 14:36:12 -08:00
Anton Lundin
f6b29d093f Use get_cylinder_index in per_cylinder_mean_depth
Use get_cylinder_index that handles SAMPLE_EVENT_GASCHANGE and
SAMPLE_EVENT_GASCHANGE2.

This also removes the need for a special case where get_gasidx returns
-1, because get_cylinder_index always returns the "closest" gas that it
finds.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-20 11:21:48 -08:00
Anton Lundin
2d8cd44370 Make the info box look as it did in 3.1
In the Gtk version there were no option to disable the showing of time
in the mouse over, so this removes that option to limit the amount of
clutter in the settings panel.

This also renames the time and temperature to match the names they used
to have. T -> @, Temp -> T

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15 06:06:57 +09:00
Anton Lundin
179a5f6f33 Remove duplicated SAC data from information overlay
When reordering the info overlay content to make it jump around less,
somehow the SAC data got printed twice.

[Dirk Hohndel: rewrote incorrect commit message]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 07:10:49 +09:00
Anton Lundin
39a4e38eea Break calculated deco info to separate vars
Store the calculated values in separate variables in the plot_data
struct, and display them separate. This makes sure we don't confuse the
calculated values with the ones from a dc, and now we can compare the
two.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14 07:08:57 +09:00
Anton Lundin
c58dc29542 Break up calculate_deco_information
Break the huge calculate_deco_information into three different functions.
One for the current deco calculations, one for the ndl/tts/deco stop and
one for the gas calculations.
This makes it easier to disable/enable different functionality.

This also gets rid if the ccrdive state variable, and keeps that state
in the plot_data struct. Now we calculate the deco before we calculate
the gas properties, so if we have a po2, we're in ccr-mode, and if we
don't, we're in oc mode.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 11:55:49 +09:00
Anton Lundin
fc2c55dabd Reorder info in information window
When moving along the plot, it's hard to look at a certain value when its
place in the info box moves due to values being added or removed above it.
This commit moves the "stable" values up top in the info box and the
values that come and go further down, so that the box expands downwards.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 11:55:39 +09:00
Anton Lundin
373c26cf00 Remove the special handling of ndl < 3m
This changes the special handling of ndl calculations when we deem that we
are too shallow for doing them. Previously we just set ndl to -1 and
printed a "-", now we return and print max_ndl, just as how most
divecomputers work.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 11:55:33 +09:00
Anton Lundin
4bb8368a20 Introduce an on/off switch for calculating ndl/tts
Let the user choose if the calculation of ndl and tts is worth the time
it takes.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 11:55:19 +09:00
Anton Lundin
dbd4a471ec Fill up plot_data with temperature all the way
This will fill out the gaps of temperature data between all the points
so we always have a temperature to show in the info box.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 11:54:59 +09:00
Anton Lundin
8873381496 Use configured vertical speed units in ruler
Ruler was hard-coded to use seconds as speed unit. This makes it use
get_vertical_speed_units to switch between seconds and minutes.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-20 06:41:30 +02:00
Anton Lundin
579d1cb915 Show SAC in the mouseover.
This is really nice to have when looking at specific parts of a dive.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17 14:56:52 -07:00
Anton Lundin
437246d3ed Move sac-calculation to profile.c
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17 14:54:11 -07:00
Anton Lundin
0bdf11b094 Rename T: to Temp: in Information box
D as in depth, T as in time and not another T as in temp.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17 14:51:19 -07:00