Commit graph

224 commits

Author SHA1 Message Date
Henrik Brautaset Aronsen
9f7c79557e CSS and translation improvements to dive plan
Use CSS styling to format the dive plan instead of deprecated HTML tags.
Also make sure that we aren't sending HTML tags to translate()

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:50:05 +08:00
Henrik Brautaset Aronsen
630ec88dd4 Be more consistent in partial pressure naming
Lets just use pO₂ instead of PO2, ppO2, ppO₂, PO₂.
They all mean the same, but it's better to be
consistent

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-23 06:48:54 +08:00
Robert C. Helling
2d7b02726e Have explicit "%s" format strings in printf style statements
Not having a format string that explicitly references the arguments is
considered a potential security issue in code.
This gets rid of a compiler warning that turned into an error on Fedora 21.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 13:58:20 -07:00
Dirk Hohndel
b70c877b3c Deal with some uninitialized variable warnings
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 09:37:12 -07:00
Dirk Hohndel
ecb5f4c792 Planner: use the actual setting for GF low at max depth
Using the default_prefs value makes no sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 09:08:51 -07:00
Lubomir I. Ivanov
32e89123a2 planner.c: prevent an uninitialized warning
"warning: 'bottom_time' may be used uninitialized in this
function"

we set it to zero for now.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 16:55:53 -07:00
Lubomir I. Ivanov
7451790660 planner.c: use implicit struct initializer
We should either use mplicit struct initializers (empty braces { }
or double braced zero {{ 0 }}) or memset the struct.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 16:55:09 -07:00
Dirk Hohndel
a3ce3221fd Fix incorrect argument order for %.*f
Strangely, *prinf() on Linux appears to do the right thing in either
order (my guess is based on the type of the two values?), but on Windows
things go badly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-09 11:23:05 -07:00
Robert C. Helling
e6fc5d2370 Planner: incease step size in deco ascends to 3 seconds
Triple time step in deco ascents to improve responsiveness of interactive
deco calculation.

[Dirk Hohndel: split commit into two]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-08 20:25:39 -07:00
Anton Lundin
58952b15b4 Switch to the new gasmix structure in dump_plan
dump_plan wasn't updated when the switch from he/o2 to gasmix was done
in the planner code, this makes it compile again.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05 08:46:24 -07:00
Robert C. Helling
9c7284b403 Planner: Avoid bogus segments with 0 time
Don't show a stop if we continue at this depth.

This resolves a problem when there are more than two waypoints during deco
at the same depth. This can happen at 6m when there is a gaschange to O2
and the last stop depth is 6m (which turns the 3m stop into another 6m
stop).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05 07:10:41 -07:00
Robert C. Helling
14eb0e23af Planner: Change 'lasttime' only if we printed something in the plan.
This makes the 'segment' durations equal the runtime differences even when
we don't display transitions in deco.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-05 07:09:58 -07:00
Robert C. Helling
40dd6f4c39 Disclaimer included in the printed diveplan
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04 14:45:54 -07:00
Dirk Hohndel
5bc5cae6dc Planner: only copy cylinders that were used in the template dive
This was only semi-implemented the first time around. Now we really only
copy the ones that are indeed used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 23:09:12 -07:00
Dirk Hohndel
9df3751c04 Planner: more accurately track assumed cylinder pressures
This makes things more consistent. The equipment view and the sample view
of the beginning and end pressure for each cylinder correspond (and the
beginning pressures of each cylinder segment are correctly reflected in
the samples).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 21:53:33 -07:00
Willem Ferguson
eaf6d56487 CCR code: Change to sample structure
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
     o2pressure_t
     bearing_t
3) The following variables were added:
     diluentpressure
     o2setpoint
     o2sensor[3]
4) Changes to a number of files were made to chanf
     sample->po2 to sample->po2.mbar
     bearing to bearring.degrees

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 17:05:25 -07:00
Dirk Hohndel
1bcb38dc49 Planner: make the warnings visually stand out more
HTML is nice here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 11:39:53 -07:00
Dirk Hohndel
d89cf361a0 Planner: add a few more line breaks in the html notes
This looks much better now.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 11:39:53 -07:00
Robert C. Helling
5a62eeffea Planner: Show gas changes at the correct depth.
Gas changes (can) have a bogus waypoint following at the same depth with 0
time. Those were confusing the decision whether to show a waypoint.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 11:39:49 -07:00
Robert C. Helling
1f1dcecc02 Planner: Show waypoints for gas changes but no double depths
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:54:01 -07:00
Robert C. Helling
575a092e7e Planner note logic and layout improved
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:38:28 -07:00
Robert C. Helling
2785d7bc3e Layout improvements to the dive plan
Changed to html.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:23:37 -07:00
Dirk Hohndel
db4a003ef5 Planner: fix typo that broke tank pressure tracking
Oops, that's embarrassing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 13:14:59 -07:00
Dirk Hohndel
9cae50acab Planner: warn about high pO2
If the user entered part of the plan exceeds a pO2 of 1.6, include a
warning about that in the notes.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 12:58:27 -07:00
Robert C. Helling
90885bfb8e Optionally strip diveplan to bare minimum
There are new check-boxes to modify the look of the diveplan in the notes.

The old behaviour appears with "verbatim display", others are shorter,
runtimes, stoplengths and transitions being optional.  Also round to full
meters and minutes to remove optical clutter.

To be done: Remember these setting in the config.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 12:40:36 -07:00
Dirk Hohndel
28093ae957 Remove is_air() and convert its users to gasmix
Also make gasname() and get_gas_string() global functions (which allows us
to delete code elsewhere).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 20:57:11 -07:00
Linus Torvalds
ee36bf8bf3 Create simple non-thread-safe "gasname()" function
Every single user of the get_gas_name() function wanted to just use the
result to create a message or printout, and that made the interface a bit
cumbersome.

This adds a "gasname()" wrapper that returns a static buffer with the
result in it, which is neither pretty nor thread-safe, but is a much
simpler interface to work with.

Our dive planning isn't multi-threaded, so nothing should care.

[ This also converts a few open-coded gasname debug printouts to use the
  helper function, resulting in prettier printouts and less code ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 20:40:03 -07:00
Dirk Hohndel
cfb93cb92c More cleanup for planner.c
Remove unused variables and make the ifdef'ed out debug code work again.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 17:45:00 -07:00
Dirk Hohndel
0d7ce2704d Change add_plan_to_notes() to operated on gasmix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 17:34:40 -07:00
Dirk Hohndel
bd142bbee2 Switch verify_gas_exists to take gasmix argument
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 16:27:19 -07:00
Dirk Hohndel
fece3f321f Switch more functions to use gasmix type
This time it's get_gas_string().

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 16:12:01 -07:00
Dirk Hohndel
fe773241ee Next step to using gasmix instead of o2/he
This changes the divedatapoints and functions that deal with them.

It changes plan_add_segment(), create_dp(), gasToStr(), and tankInUse() to
consume gasmix instead of o2/he.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:40:46 -07:00
Dirk Hohndel
2bf46381a8 Use proper types
This is step one of many to use gasmix instead of int o2/he.
Right now some of these changes look ridiculous because after changing a
few lines we immediately go back to o2 = get_o2(gas). The reason is that I
wanted to convert a hand full of functions at a time. So in this commit I
only change validate_gas(), get_gas_from_events() and get_gasidx() to use
a struct gasmix instead of int o2, int he.

This state builds and survived some mild testing. Let's continue on top of
that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 14:19:19 -07:00
Dirk Hohndel
1a04013453 Encapsulate the horrid gas encoding in gas change events
We should never pass permille values around as integers. And we shouldn't
have to decode the stupid value in more than one place.

This doesn't tackle all the places where we access O2 and He "too early"
and should instead keep passing around a gaxmix. But it's a first step.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 12:07:29 -07:00
Dirk Hohndel
fb4d9b34f8 Planner: correctly track gas used
This part of the algorithm was off as part of it (but not all of it -
crazy, I know) assumed the old semantic for gas changes where the new gas
was introduced at the end of the segment and not at the beginning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 10:16:59 -07:00
Dirk Hohndel
2a871d7fe5 Planner: track gas used even if we don't have a real cylinder
We tracked gas used by simulating a dive with a cylinder - but for that we
need a cylinder size and working pressure. If the user just enters a gas
but no cylinder data (likely in order to figure out how much gas is used
so that she then can pick a big enough cylinder), we didn't show any gas
consumption.

It kinda sucks to add another member to the cylinder structure, but this
seemed far more reasonable then some other, global structure that
independently tracks gas usage. This just seemed to make sense.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 10:16:59 -07:00
Dirk Hohndel
f44a7509b3 Planner: more fixes for gas tracking
Gas switches are now for the current segment, not for the next.

We can only track gas for cylinders for which we have size / working
pressure information. Print a warning for others.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 10:16:48 -07:00
Dirk Hohndel
81e3f77447 Planner: add warning if the plan consumes more gas than provided
If we have size information including working pressure for a cylinder, we
already track the expected pressure at each way point - this way we can
also alert the user if more gas is consumed than is available in the
cylinder.

This does not include sound planning strategies like "rule of thirds". It
simply assumes that you won't be able to breathe down the cylinder past
about 10bar (using 0 as cutoff seemed silly).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 07:55:28 -07:00
Dirk Hohndel
ed26dfdd6b Planner: don't include the disclaimer in the dive plan detail widget
We want the disclaimer in the final dive that can be printed, but it's
distracting when shown while planning the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 21:25:03 -07:00
Dirk Hohndel
b9946b89fa Planner: look harder to find the right gas
Silly bug - while we normally fill the cylinders in a tight group with no
"null" cylinders in the middle, since we copy from an existing dive and
since that may end up with an odd sequence of cylinders, we need to
continue looking at ALL cylinders and not stop with the first one that's
empty.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 13:49:51 -07:00
Dirk Hohndel
65f3135a92 Planner: don't do unnecessary work on empty dive plans
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 15:40:13 -07:00
Robert C. Helling
26dd86e437 Planner: start the ascend with the strongest allowed deco mix.
In analyze_gaslist() we were only keeping gases that had their .depth
above the current depth, i.e. where we could switch to in the future. Now
we take note as well of the strongest gas that we could have already
switched to and switch to it before we attempt to ascend.

[Dirk Hohndel: minor whitespace and code cleanup]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 09:06:22 -07:00
Dirk Hohndel
63c21d55de Planner: clean up the function that tracks our gases
This doesn't add gases. It just makes sure they are there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 17:36:39 -07:00
Dirk Hohndel
d054e8c457 Planner: track gas consumption in cylinders and samples
This commit is a little bigger than I usually prefer, but it's all
somewhat interconnected.

- we pass around the cylinders throughout the planning process and as we
  create the plan we calculate the gas consumption in every segment and
  track this both in the end pressure of the cylinder and over time in
  the samples
- because of that we no longer try to calculate the gas consumption after
  being done planning; we just use what we calculated along the way
- we also no longer add gases during the planning process - all gases
  have to come from the list of cylinders passed in (which makes sense
  as we should only use those gases that the user added in the UI or
  inherited from a the selected dive (when starting to plan with a dive
  already selected)

With this patch I think we are close do being able to move all of the
planning logic back into the planner.c code where it belongs. The one
issue that still bothers me is that we are juggling so many dive
structures and then keep copying content around. It seems like we should
be able to reduce that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 14:43:24 -07:00
Dirk Hohndel
b37422c447 Planner: record the new dive at the correct time
We don't want to do this when calling plan() from createTemporaryPlan() -
we only want to record the dive at the end of createPlan().

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 22:16:15 -07:00
Dirk Hohndel
4ed8b5f86f Planner: add missing disclaimer
This may not be the best way to do it, but it's better than just printing
"(null)".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 22:11:37 -07:00
Tomaz Canabrava
4e3793c053 Paint the dive red if the user is breaking ceiling on the planner.
This patch paints the dive red if the user is breaking ceiling
on the planner - it's quite fast, it analizes the depth over the
max(tissue_1 .. tissue_16) and changes the color of the profile.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 15:42:43 -07:00
Dirk Hohndel
0f023791f8 Fix warning
When converting from assert to if I forgot to invert the comparison...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 14:21:37 -07:00
Dirk Hohndel
9cc8e39d42 Merge branch 'Planner' 2014-05-26 13:28:18 -07:00
Dirk Hohndel
cf3701bbac Planner: convert assert into warning
We need to make sure we let the user know about this in a more user
friendly way...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:25:50 -07:00
Robert C. Helling
1093d6235b Reenabled copying the diveplan to dive notes.
Gas consumption calculation fixed. Pressure difference still needs cylinder size to be set.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 09:58:23 -07:00
Robert C. Helling
04b6b6aaf9 Use get_o2() and get_he() instead of accessing permilles directly
This gets rid of problems with air.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 08:12:32 -07:00
Robert C. Helling
a422aa2986 Planner: Add waipoints when changing ascend rate in planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 12:28:16 -07:00
Robert C. Helling
c3a3c1a1e7 Planner: Implement ascend rate according to GUE standard procedures
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08 12:28:09 -07:00
Dirk Hohndel
3063991e4e Fix bug in handling of fake SAMPLE_EVENT_PO2 events
In commit bcdd6192fe ("Show translated event names in tooltip") I was
too aggressive in replacing the checking for event names with checking for
event types. It turns out that we are abusing an existing event type in
the planner (and use a different event name to mark the difference). By
just checking for the type this now caused incorrect information to be
displayed in the info box (a simply "PO2 warning" on a Suunto D9 could
turn into a "Bailing out to OC" notice).

The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from
libdivecomputer. Once we have those, we can do this the right way. For now
we just fall back to also checking the event name (which is what I wanted
to get away from so translated names don't trip us up).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05 09:32:13 -07:00
Dirk Hohndel
bcdd6192fe Show translated event names in tooltip
In order for this to work we need to compare against the event type
instead of the event name - which makes much more sense to do, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-29 22:38:55 -07:00
Dirk Hohndel
d191f5af6f Remove unused variables and fix signed/unsigned mismatch
The depth types are unsigned for dive plan datapoints.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18 13:06:21 -07:00
Robert C. Helling
cb4daa85c3 Comments added to planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18 10:01:46 -07:00
Robert Helling
9ddef367b5 Improvement for various bits of the planner
Rewrite of the actual planner logic. Now ascend to the next potential stop
depth. There the state is cached and we try to ascend to the next stop
depth. If we hit the ceiling while doing that we go back to the cached
state and wait there for a minute. Then we try again. Then loop.

Converted all depth related variables from unsigned int to int. During
planning, in a time step the current depth can temporarily be negative and
comparisons of a negative int with an unsigned it have not the result I
expected ( (int) -2 < (unsigned int) 3 turns out to be false). And we
don’t really need the 32nd bit that unsigned buys us for depths.

Deco stops are now shown in the same table as manually entered stops in
boldface (I removed the second table to save screen estate).

The gas shown in the table is still misleading as it means the gas used on
the segment leading up to that event.

The update of the profile only works partially upon changes in the list of
available gases.

Treatment of various gases is basically there but needs some more love.

The ascent velocity is now provided by a function that takes the current
depth as argument. Currently it always returns 10m/min but that will later
be variable (and hopefully user configurable).

The profile is not redrawn while deco is computed (avoiding an infinite
recursion).

The table got a new column for the duration of a segment while the old
“duration” column was renamed “Runtime” to reflect what it actually shows.
Currently, only the run time but not the duration are editable.

All deco gases are used from the depth where their pO2 is 1.4bar. This
should become more flexible.

Calculation of the pressure drop in cylinders without configured volumes
is suppressed. This solves a problem with the planner crashing when saving
a dive where not all cylinders had been manually given a volume.

[Short rant break: Treating 0/0 as air bites back at so many places. E.g.
Cylinder data is initialized with memsetting the whole structures to 0.
Then later suddenly this totally unconfigured cylinder is being treated as
it would contain air. Maybe at some point this was a feature. But it lead
to a naughty bug which took me over an hour to resolve. We should
seriously reconsider this choice and better move to 209/0 being air if
changing this everywhere is not too much trouble]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17 07:29:44 -07:00
Dirk Hohndel
0de21c24fa Merge branch 'planner-mods'
Nothing exciting here, just a few independent changes close to each other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31 22:18:00 -07:00
Robert C. Helling
30bdfc8160 Distinguish between entered and calculated waypoints
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31 22:01:05 -07:00
Dirk Hohndel
6ba140571e Only use a default cylinder if it is explicitly set
We used to fall back to an AL80 default cylinder, but that meant that a
user who doesn't want a default cylinder at all had no way to indicate
that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 13:09:36 -07:00
Linus Torvalds
609715ab69 Convert other users of showError() to the new world order
The "report_error()" interface is a lot simpler, although some of the
C++ code uses QStrings which make them a bit annoying, especially for
the varargs model.  Still, even with the explicit conversion to UTF8 and
"char *", the report_error() model is much nicer.

This also just makes refreshDisplay() do the error reporting in the UI
automatically, so a number of error paths don't even have to worry.  And
the multi-line model of error reporting means that it all automatically
does the right thing, and reports errors for each file rather than just
for the last file that failed to open.

So this removes closer to a hundred lines of cruft, while being a
simpler interface and doing better error reporting.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14 12:36:06 -07:00
Dirk Hohndel
396106e307 Don't use negative gas index
This shouldn't happen, but in case we run out of gases we shouldn't use
the negative gas index (which is the error return of get_gas_idx()) for
the array. Let's fall back to the (incorrect) first gas.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03 21:54:52 -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
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
Anton Lundin
c46ae27c3b Match sizeof with pointer type
More to get clang-scan to quiet down that for the unlikely event that
unsigned int and int is different sizes.

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
0d4fb44c18 Remove some safety stop code in plan()
Some code in plan() left from the gtk days introduced a safety stop in the
plan. It created a un-editable diveplanpoint.

Fixes #349

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-10 08:00:52 +01:00
Anton Lundin
eae1624f24 Make local helpers static
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 09:41:54 +01:00
Anton Lundin
28943d2def Add some assert guard around gas finding code
The code would have leaved gasidx undefined if it doesn't find a correct
gas, so this asserts instead of using uninitialized variables as array
index.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-08 09:41:28 +01:00
Dirk Hohndel
4dc3061aa5 Use AL80 as default if no default cylinder is set
Otherwise the user could get uninitialized values for newly created
cylinders.

Fixes #345

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07 14:29:05 -08:00
Anton Lundin
70a9c280f4 Bugfix first deco stop finder
The previous code checked against the current depth to find the next
deco stop, not the ceiling we actually should head for.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-07 08:02:48 -08:00
Anton Lundin
d0fbfc7a9c Create a drop down to choose default cylinder
This also renames the ui element to match.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-24 15:07:25 -08:00
Dirk Hohndel
904c20feef Use the default cylinder if defined
With this every cylinder downloaded from a divecomputer that doesn't
provide cylinder data, and every cylinder manually added anywhere will
default to the default cylinder that is set in the preferences.

For people who most of the time dive with the same equipment (always on
dive boats with AL80, or almost always diving their personal HP119) this
should be a nice improvement.

If you don't like this behavior, simply leave the default cylinder setting
in the preferences empty.

This commit also fixes the incorrect s->value call (should be
s->setValue). I wonder what this did to the default filename before...

Fixes #145

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-23 22:01:11 -08:00
Patrick Valsecchi
fe2eabf375 Added a configuration option to have gf_low apply at max depth instead of at deepest ceiling.
Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 08:11:40 -08:00
Dirk Hohndel
33b15ea906 Silence some warnings when building on Mac
The *-clang* selector doesn't appear to work correctly in my build environment
(or I just don't understand how it is supposed to work). Either way, making
this conditional on !mac works.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-21 05:03:56 -08:00
Anton Lundin
746e6da75a Use add_gas_switch_event in instead of duplicate
There is a add_gas_switch_event, so don't duplicate the code.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-20 11:22:40 -08:00
Dirk Hohndel
36cb50fb37 Add gas change event from profile context menu
This allows to add missing gas change events to the currently shown dive
computer. Only gases defined in the Equipment section are offered.

Fixes: #250

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-19 20:35:15 -08:00
Dirk Hohndel
8ae8c81d3d Fix various issues with the dive add / edit manual dive code
- get_gas_from_events does NOT always set o2/he. It only updates them IFF
  a matching event is found; so we need to make sure we start out with a
  valid gas mix
- the way we tried to restore the edited dive in case of an edit to a
  manually added that is cancelled was completely bogus. Way too complex
  when we can simply and reliably simply store the dive and then copy it
  back

Fixes #270

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-18 11:55:56 -08:00
Dirk Hohndel
aa76d35923 Instead of a "Cylinder for planning" use a default cylinder
Right now hardcoded to AL80. This way in the future we'll have a volume of
gas that's available. And this makes much more sense then a random string
in the description field.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13 21:45:24 +09:00
Dirk Hohndel
ad4812c22e Make planner work again
This partially reverts changes in commit 1b655d5c806b ("Correctly track
gases when manually adding and then editing dives") as it turns out this
did NOT help us correctly track gases (which is ironic, given the title of
that commit). I didn't actually want to revert that commit as
infrastructure has changed since then and this made the patches look even
more incomprehensible.

So we are back to tracking the "gas on which we arrive at this spot" in
each dive plan node as this makes the rest of our planning so much easier
- I had forgotten about the reasons why we did things this way when I made
the above mentioned commit.

Instead we now make sure that our available tanks are added the correct
way, that such entries are ignored when planning and when drawing the
editable profile, and that at the end it all gets assembled correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-12 11:19:04 +09:00
Dirk Hohndel
edecb0fcf9 Don't access invalid elements with depth = 0
This is a corner case in the planner that was exposed by the recent
changes to the way the dive plan reflects the gases during the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-08 21:40:59 +09:00
Dirk Hohndel
8941e8677e Correctly track gases when manually adding and then editing dives
The code had quite a few odd special cases that may have been left-overs
from the old Gtk algorithm. With this the gas is actually in the dive plan
node where it's use starts. And we maintain the gas correctly between
multiple edit sessions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-08 21:22:59 +09:00
Dirk Hohndel
f2035bcd79 Don't translate the fake DC models
Since the model name is written into the XML file it has to be a literal
string that isn't translated. Otherwise a datafile written in one locale
behaves differently when opened by Subsurface under a different locale.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-07 16:52:39 +09:00
Miika Turkia
bdedf46e4c Get rid of compiler warning on format strings
This gets rid of compiler warnings "format not a string literal and no
format arguments [-Wformat-security]". E.g. when building distribution
packages these warnings are often treated as errors preventing the
build (with good reason).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2013-10-20 15:25:27 +02:00
Dirk Hohndel
193d20c479 Next step towards working translations
This may seem like a really odd change - but with this change the Qt tools
can correctly parse the C files (and qt-gui.cpp) and get the context for
the translatable strings right.

It's not super-pretty (I'll admit that _("string literal") is much easier
on the eye than translate("gettextFromC", "string literal") ) but I think
this will be the price of success.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09 22:51:59 -07:00
Dirk Hohndel
7180c708e9 Fix some signedness issues
I always worry if these are worth following up on - but these seem pretty
clear and obvious to me. As far as the planner is concerned, depth is
unsigned.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07 22:39:52 -07:00
Dirk Hohndel
2627ea927d Next round of code removal and header cleanup
None of this is used anywhere

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07 16:55:43 -07:00
Dirk Hohndel
34db6dc2be Delete code and files that are no longer used
Most of this is Gtk related, some of it is helpers that we don't need
anymore. I love the diffstat.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 17:32:50 -07:00
Dirk Hohndel
4d3e74a236 Trying to switch to Qt translation
This compiles and looks about right, but it doesn't appear to work, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:42:32 -07:00
Dirk Hohndel
4b12f28ca4 First steps towards removing glib dependencies
- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)

This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:41:44 -07:00
Dirk Hohndel
23ce6b8bec When adding a dive, make the final ascent slower
Simply trying to role-model safe behavior I guess. Fundamentally all this
should be configurable (so I added comments about that on the planner side
as well).

One of the interseting side effects of this implementation is that if the
user removes the safety stop and comes up directly from a deeper depth,
the slope of the ascent will change at 5m :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-20 07:50:19 -05:00
Dirk Hohndel
56535e4b3b Only calculate deco stops in planner mode
In add dive mode simply bring the diver safely back to the surface
(currently with a fixed ascent rate of 30ft/min (or 9m/min)).

We should make that rate configurable (for the planner as well as the dive
add function). Also, the dive add function should offer to automatically
include a safety stop.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-18 22:40:34 -05:00
Tomaz Canabrava
5e722a93e4 Gas choices working, both directions ( Planner and Table )
The gas choice now works and correctly ( I hope ) calculates
the gas choosen to show on the planner. User can choose the
gas from the list on the visual planner, and also on the table.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-08-30 15:06:26 -03:00
Robert Helling
8eb2dc3d65 Removes circle in plan
Remove circle in plan by starting the first line at the first point
rather than the last.

In addition marks all entered points as entered and not just the first and
sets line color accordingly.

Makes plan_add_segment return the added data point.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-27 19:51:04 +08:00
Dirk Hohndel
ef0272f5ef Perform deco calculation for plan
This uses a bunch of default values that we eventually need to get from
the UI, but it's a first step towards a working dive planner.

This exhibits some graphical artifacts when running, but other than that
appears to be mostly correct.

Things go far worse if I enable the changing of the scale once the deco
makes the dive longer than the displayed time window. Things quickly
spiral out of control.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-23 21:36:50 -07:00
Dirk Hohndel
596095389b Start hooking in the deco calculations
I expanded the DiveHandler to include the actual time / depth of each
node on the graph - this way things will stay consistent if we need to
rescale the graph.

One thing that this makes obvious is that the whole design for the
planner so far assumes metric data. We need to make sure this works well
with feet instead of meters as well (and that it uses the information in
the units settings).

With this change we actually create a dive based on the plan input and
add the deco stops (if needed) to it - but we don't do anything with the
results of those calculations, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-23 20:32:32 -07:00
Dirk Hohndel
f3f7bf51fa Merge branch 'Qt'
After the 3.1 release it is time to shift the focus on the Qt effort - and
the best way to do this is to merge the changes in the Qt branch into
master.

Linus was extremely nice and did a merge for me. I decided to do my own
merge instead (which by accident actually based on a different version of
the Qt branch) and then used his merge to double check what I was doing.

I resolved a few things differently but overall what we did was very much
the same (and I say this with pride since Linus is a professional git
merger)

Here's his merge commit message:

    This is a rough and tumble merge of the Qt branch into 'master',
    trying to sort out the conflicts as best as I could.

    There were two major kinds of conflicts:

     - the Makefile changes, in particular the split of the single
       Makefile into Rules.mk and Configure.mk, along with the obvious Qt
       build changes themselves.

       Those changes conflicted with some of the updates done in mainline
       wrt "release" targets and some helper macros ($(NAME) etc).

       Resolved by largely taking the Qt branch versions, and then editing
       in the most obvious parts of the Makefile updates from mainline.

       NOTE! The script/get_version shell script was made to just fail
       silently on not finding a git repository, which avoided having to
       take some particularly ugly Makefile changes.

     - Various random updates in mainline to support things like dive tags.

       The conflicts were mainly to the gtk GUI parts, which obviously
       looked different afterwards.  I fixed things up to look like the
       newer code, but since the gtk files themselves are actually dead in
       the Qt branch, this is largely irrelevant.

       NOTE! This does *NOT* introduce the equivalent Qt functionality.
       The fields are there in the code now, but there's no Qt UI for the
       whole dive tag stuff etc.

    This seems to compile for me (although I have to force
    "QMAKE=qmake-qt4" on f19), and results in a Linux binary that seems to
    work, but it is otherwise largely untested.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-17 22:01:41 -07:00
Anton Lundin
935af9e8af planning: Add option to have last stop at 6m/20ft
When diving in areas where there are risk of boats passing above you,
its common practise to do the last stop at 6m to better stay out of
harms way. When doing o2-deco, it doesn't matter for the deco time if
you are doing all the time at 6m, due to that you don't have any inert
gas in your breathing gas.

This code is a reintroduction of 0b8462bd lost somehow between
a70a8898..8fae0031

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03 11:43:50 -07:00
Dirk Hohndel
8677721e85 Remove the majority of the Gtk related code
- rip all Gtk code from qt-gui.cpp
- don't compile Gtk specific files
- don't link against Gtk libraries
- don't compile modules we don't use at all (yet)
- use #if USE_GTK_UI on the remaining files to disable Gtk related parts
- disable the non-functional Cochran support while I'm at it

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-03 11:37:09 -07:00