Commit graph

420 commits

Author SHA1 Message Date
Dirk Hohndel
936f057ddc Retain the start time when creating plan from dive
We need to make sure that the start time is set before we start adding
points.

Fixes #661

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-29 13:02:01 -07:00
Dirk Hohndel
1863452a25 Add dive: initialize start time of dive
commit f29f41ae9e ("Planner: fix start time handling") broke the start
time handling for Add dive. While in actual planner mode we set the start
time for the plan, we did not do this when simply adding a dive. The
moment the time / date was changed (which admittedly in real life a user
would most likely do) all was well, but if the user just accepted the
"now + 1h" default, things went badly wrong.

Fixes #658
See #655

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-26 07:30:09 -07:00
Dirk Hohndel
f29f41ae9e Planner: fix start time handling
We setup the startTime for the dive plan in too many places... but never
actually copied it into the planned dive.

Fixes #640

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-24 09:03:56 -07:00
Lubomir I. Ivanov
028568555f Planner: fix an enduring assert on startup
qt 5.3, win7 64bit.

beginRemoveRows() asserts in removeSelectedPoints()
because rowCount() - 1, becomes less than firstRow.

This needs a check in removeSelectedPoints() if the number
of passed rows is zero.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-23 08:19:45 -07:00
Anton Lundin
60c4587be6 De-duplicate planner default settings
All other default settings we get from subsurfacestartup.c's
initialization of the prefs struct. The planner had its defaults there
and in the retrieve of the settings from QSettings.

This changes so the defaults for planner settings will be read from the
defaults prefs struct as all other settings.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-19 10:24:07 -07:00
Dirk Hohndel
17bcd1bc60 get_gas_at_time needs to always give us a valid gas
Before this function was changed it was really supposed to just change a
gas that was passed in in case there was an event that changed the mix -
but with the new name the caller will assume that they get a valid gasmix.
And promptly we had one caller that didn't initialize gas to be based on
the first cylinder before calling get_gas_at_time().

Instead of adding yet one more spot that knows about the oddity of the old
API I simply changed get_gas_at_time() to do what it name appears to imply
and fixed the other callers not to bother to initialize the gasmix.

Fixes #647

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 18:46:51 -07:00
Anton Lundin
7806dbbd9e Convert get_gas_from_events to get_gas_at_time
This converts the get_gas_from_events to a get_gas_at_time function that
actually maps our events to what cylinder and thus gas we are breathing
at that time.

[Dirk Hohndel: fixed to actually use the gas that was looked up
               (and make things compile)]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 10:13:52 -07:00
Anton Lundin
9eeeba468a Use more of our propper types in the planner
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 10:02:11 -07:00
Henrik Brautaset Aronsen
606bf377c5 Use "6m" and "20ft" instead of "6m/20ft".
Get rid of unit type shortcut in planner.  Also use "to" instead of "-" in ascent rate intervals.

Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18 10:09:04 -07:00
Dirk Hohndel
24472a3b23 Planner: correctly deal with units in Ascent/descent rates
This adds two changes
a) it uses rint() to make sure we don't truncate the displayed values
b) it moves the update of the displayed values into a helper function that
   is also called whenever the settings change

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-17 08:06:15 -07:00
Robert C. Helling
13b8680b0c Planner: Ascent/descent rates are stored in mm/s not in m/min
So should be defaults.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-17 07:47:04 -07:00
Gaetan Bisson
e69bb1879e Store drop_stone_mode, bottomsac, decosac in prefs
The values for drop_stone_mode, bottomsac, and decosac are typically the
kind of personal data specific to a diver that is unlikely to change
from one dive plan to the next.

This patch stores/restores them to/from the preferences file. For this,
it adds bottomsac and decosac to the prefs structure; drop_stone_mode
was already there, though not stored/restored.

Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 23:09:56 -07:00
Sergey Starosek
387553f0b3 Translate velocity units in planner settings
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 22:54:52 -07:00
Sergey Starosek
14cc59898a Date picker l10n for profile and planner
- set application-wide locale from preferences
- use custom date format for display

Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16 13:58:06 -07:00
Tomaz Canabrava
887f9e63c3 Save and restore Dive Planner Settings
This patch adds the code that saves and restores the dive planner
settings.

Fixes #608

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15 17:05:38 -07:00
Dirk Hohndel
dff92f188a Planner: don't allow the user to remove the last point
This causes all kinds of assumptions to go wrong - and it makes no sense.
Move the point to where you want it or cancel the plan.

Fixes #623

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15 03:33:48 -07:00
Dirk Hohndel
133e104393 Planner: when adding new waypoint at the end, use previous gas
In commit b0da8c2707 ("When adding a waypoint, use the gasmix of the
_next_ waypoint.") we default to air when adding a waypoint at the end of
the plan by double-clicking. That seems silly since we could instead
continue using the last gas.

I wasn't able to reproduce the "gas list disappears" problem in bug #623,
but I did get a silly air segment added which was equally wrong. Maybe I'm
lucky and this fixes the problem that Henrik sees as well...

See #623

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-15 03:20:23 -07:00
Anton Lundin
b55218c2f4 Lower CCR setpoint min value in planner to 0
We signal a bailout to OC via setting the setpoint to zero. A setpoint
between 0.2 and 0 would be really wierd, but i couldn't figure out any
better way to keep the bailout deco planning.

Note:
The gas consumption of CCR dives are plain wrong, but this atleast lets
you plan your deco for a CCR bailout plan.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-12 08:03:46 -07:00
Anton Lundin
c4981f28a6 Add step size in our SpinBox delegates
For the Set point spinbox, it was kinda hard just stepping by the
default 1.0, so setting it to step by 0.1 makes much more sense.

The int SpinBox got a step size parameter for consistency.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-12 08:03:34 -07:00
Tomaz Canabrava
af9d62bac3 Fixed input in the DivePlanner table
Based on Glance's idea on rewritting the Delegates, but
we don't need to redo the wheel as Qt already gives us
the correct Delegate, we just need to set some boundaries
on it before returning.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-11 16:58:42 -07:00
Tim Wootton
7680863c0e diverplanner capitalisation consitency
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 16:29:01 -07:00
Henrik Brautaset Aronsen
a99349814c Use gasmix getters in diveplanner.cpp as well
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10 16:19:06 -07:00
Anton Lundin
2ff2daebd7 Move drop_stone_mode setting to prefs
There is no reason to treat drop_stone_mode different from the rest of
the planner settings, so move it to our prefs structure.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 14:40:36 -07:00
Robert C. Helling
b509eeda1d Refresh display after toggling backgas breaks.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09 08:55:12 -07:00
Robert C. Helling
a7969d1083 Planner: don't allow negative depths
This patch allows only non-negative depths in the divepoints table as
negative depths confuse the planenr/deco algortihm. The spinbox appearing
in the table should get a setMinimum(0) but I was not able to find the
correct way to implement that.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-07 09:18:07 -07:00
Dirk Hohndel
3d511fe26b UI restructure: remove the backupDive we no longer need
Since we have a dedicated dive that we use to display things, we can
simply get the information from the current dive and use it to setup said
displayed_dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-06 12:56:37 -07:00
Dirk Hohndel
cd5b2a372f UI restructure: cleanup the code when canceling an edit
This was way too complicated because we used to edit a "live" dive that
was on the dive list. All we really need to do is systematically make
sure that all the widgets are in the correct state.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-06 12:50:30 -07:00
Robert C. Helling
b0da8c2707 When adding a waypoint, use the gasmix of the _next_ waypoint.
This corrects the logic of adding a waypoint actually meaning that
a previous segment is subdivided into two. Both new segments should
by default use the gas of the old one. Since the gas is stored
in the waypoint (divedatapoint) at the end, we need to use the _next_
gas.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-05 07:43:41 -07:00
Dirk Hohndel
cc86d68c86 Planner: don't set cylinder start and end pressure when adding dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-04 11:40:02 -07:00
Dirk Hohndel
5f76185d37 Planner: initialize drop_stone_mode as false
Otherwise it could be used uninitialized when adding dives.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 21:37:47 -07:00
Dirk Hohndel
da911993f1 Small cleanups
Add commented out options to subsurface.pro that enable debuging the planner.
Remove obsolete comment.
Clean up the selection tracking.
Force the re-sort of the divelist inside the reload instead of explicitly
calling it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 21:05:08 -07:00
Dirk Hohndel
bb176e822a UI restructure: add back the missing plan dive notes
This was removed in the big rewrite by mistake.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 16:41:15 -07:00
Robert C. Helling
5db706d291 Planner: Add backgas breaks
If the corresponding checkbox is checked the planner does interrupt
pure O2 deco after 12min for 6min on cylinder 0.

To make this work for air I removed the gasmix_is_null logic.

I guess that makes the planner feature complete for the next release.

[Dirk Hohndel: trivial merge into latest master]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 16:33:19 -07:00
Dirk Hohndel
611bae3441 UI restructure: use displayed_dive for add dive and plan dive
This gets rid of the stagingDive and stops the constant adding and
removing of dives from the divelist (that was an INSANE design,
seriously).

When adding or planning a dive all work is now done in the dedicated
displayed_dive.

Add dive mostly works - when the user clicks save the dive is added to the
dive list and selected.

Plan dive is mostly untested. It passed trivial "start planner, save"
testing so it's not entirely broken, but I'm sure there's more work to be
done there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 14:45:01 -07:00
Dirk Hohndel
6b1b2bc919 UI restructure: get rid of "current" pointer in cylinders and weights
Instead always display the display_dive.

Now the only thing left to slay is the stagingDive...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:55 -07:00
Dirk Hohndel
cd65c8512d UI restructure: add helper function to copy and clear a dive
This way we can safely copy around dives (specifically, copy the dive to
be displayed / edited into the displayed_dive).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-03 09:37:43 -07:00
Tomaz Canabrava
1ac0b00662 Only replot the dive if maxDepth > oldMaxDepth on plan / add mode.
This fixes the "impossible to work with" planner with the mouse
now the dive will only grow and not shrink untill you release
the mouse.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-30 16:06:53 -07:00
Robert C. Helling
b438158693 Make the planner settings respond well to unit system changes.
[Dirk Hohndel: removed printf/qDebug() debug output]

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-30 07:27:17 -07:00
Robert C. Helling
a9b030ed44 Fixed SAC in planner
When I moved the settings for SAC's from the planner to the plannerSettings widget
I forgot to move the corresponding methods from one class to the other.

This fixes the display of the gas consumption in the planner

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-29 08:35:37 -07:00
Dirk Hohndel
06a8002a2d Planner: implement sane way to set the start time of the planned dive
This uses the same widgets we use on the maintab.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-28 08:07:28 -07:00
Dirk Hohndel
259b73335f Remove unused variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27 12:13:27 -07:00
Anton Lundin
b6fac74f6e Care about drop_stone_mode in createSimpleDive
The checkbox is remembered as long as the program is still running, so
if you planned one dive with drop_stone_mode and saved/aborted and then
tried to plan another one we had a first "down" waypoint from
createSimpleDive and drop_stone_mode was also enabled.

This makes sure we don't add the first waypoint in createSimpleDive when
drop_stone_mode is enabled and lets that add a implicit first waypoint.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27 06:54:59 -07:00
Robert Helling
d2a834b0cd Rearrange planner UI elements
This is my first attempt at grouping UI elements of the planner in a
sensible way.

It might still be sensible to combine the two bottom panes into one.

In addition there is a new field "altutude" which is sychronized with the
surface pressure as for planning we often know the altitude of the dive
site rather than the atmospheric pressure.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26 15:40:16 -07:00
Dirk Hohndel
7f3efbdc98 Make gas mod be reasonable for users of imperial units as well
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 21:41:58 +08:00
Robert C. Helling
65c5d6815c Make pO2 settings functional in planner
Spin boxes for pO2 are now hooked up to preference values. Adding new
cylinders (or changing their fo2) computes the MOD accordin to the current
value of decopo2. Note that chaning the limits for deco pO2 does _not_
automatically update the switch depth of all cylinders as those might have
been manually entered.

Furthermore, MOD has now to option of rounding to multiples of a given
depth. That is used for the automatic switch depth which are now always
multiples of 3m (so that EAN50 is switched to at 21m rather than 22m).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 21:07:10 +08:00
Anton Lundin
c7231adde1 Connect prefs.descrate to drop_stone_mode points
This enables so we can change the decent speed for drop like a stone
mode.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 20:53:05 +08:00
Anton Lundin
f2afddf4ad Fix typo in connecting ui.descRate to setDescRate
Qt didn't find the right function without the type there. This also gets
rid of the warning about that.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 20:52:49 +08:00
Robert C. Helling
772727fc7f Hook up UI elements for ascent rates to planner
That provides some UI elements that were recently introduced with function
of allowing the ascent rates of the planner to be configured by the user.

I tried to make it work both with senisble as well as with imperial units.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-25 13:48:44 +08:00
Anton Lundin
ccfdcca6e6 Drop like a stone mode in planner
Most of my dives i plan i know it will just be full speed down a line in
the beginning and thus the planner can figure out that leg of the plan
by it self.

The config box added here isn't connected, because i saw that the other
planner boxes wasn't connected ether, so i left it in the same state as
they where.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-24 17:26:31 +08:00
Anton Lundin
5904be2e06 Fix NO_PRINTING building again
Back in 6699e3ab ("Add print button to planner") unconditional printing
code was added. This puts that same code behind NO_PRINTING macro.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-24 17:18:58 +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
Anton Lundin
bb44908507 planner: Switch to QSpinBox for SAC
QSpinBox is nice to see how different sac rate would affect our dive
plan.
"Hey, What would happen if I would be stressed and my sac goes up by 50%?"

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-20 06:37:44 -07:00
Robert C. Helling
708f19830e Planner: New plannerSettingsWidget
In planner mode, this replaces the globe with the dive plan and introduces
a new plannerSettingsWidget in the diveListPane. All new fields are still
disfunctional. This is WIP.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-12 09:30:46 -07:00
Dirk Hohndel
79c68367c6 Fix uninitialized memory warning
It's kinda bogus, but since we add it to the Vector, we might as well
initialize all of it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 14:07:57 -07:00
Dirk Hohndel
e4a9fa74e8 Planner: don't reset GF when preferences change
The planner has its own view of the gradient factors. So replacing those
with the ones set up for viewing dives in the preferences is wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 09:28:17 -07:00
Dirk Hohndel
6daeb276ad Planner: reset GFlow and GFhigh when we're done
While planning we might change the gradient factors. Make sure they are
back to what's in the preferences when we're done planning.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 09:11:34 -07:00
Dirk Hohndel
c92bb9e021 Planner: don't redo the plan after partial edits of GFlow/high
In most cases this wouldn't really matter, but when planning very deep or
very long dive with corresponding very long deco times, calculating the
deco takes long enough to make this notable.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-04 09:34:08 -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
09403f3724 Planner: reject plan if escape key is pressed
This seems intuitive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 15:30:27 -07:00
Dirk Hohndel
2cfa7fead0 Planner: fix editing the dive planner points table
The edit starts with the current value, but our data() function didn't
return that in the edit role.

Thanks Tomaz for explaining this to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 11:44:05 -07:00
Robert C. Helling
6699e3ab3e Add print button to planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 07:23:43 -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
cc012c1fa6 Fix addStop to work as slot again
In order to call this as slot it needs to have defaults for all arguments.
So we need to change the gasmix into a pointer - which is actually better
as this allows to easily pass a NULL pointer when we want to continue to
use the previous gas.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-02 12:40:36 -07:00
Dirk Hohndel
89f3532145 More conversions to gasmix
addStop, addGas and createSimpleDive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 18:18:57 -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
c539c8f861 Remove the .used member of the cylinder structure
Instead calculate this information on the fly, taking into account all
dive computers on the dive in questions.

There is one wrinkle to this - previously we abused the '.used' member to
make sure that a manually added cylinder didn't disappear the moment it
was added (think of the workflow: you add a cylinder, then you add a gas
change to that cylinder -> right after you add it it is unused and would
not be shown).

I am thinking that we might have to add the "manually_added" property to
the properties that we store in XML / git.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 12:43:40 -07:00
Dirk Hohndel
ac1168f186 Revert "Show the calculated deco stops in the planner table"
This reverts commit 7d42b53bba.

With the addition of the dive plan details widget we no longer want to
show the deco points in the dive planner points table.

Conflicts:
	qt-ui/diveplanner.cpp
2014-05-31 21:36:35 -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
6333f3aa35 Planner: show the plan notes in the new widget
That was easy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 21:14:44 -07:00
Robert C. Helling
eb26823b34 Allow editing segment duration. This shifts all following waypoints.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 06:26:55 -07:00
Dirk Hohndel
6f1e071a54 Planner: don't recreate the dive while cleaning up the widgets
Otherwise the change to the Cylinder widget would trigger a recreation of
the dive in an inconsistent state.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 16:12:35 -07:00
Dirk Hohndel
a0136a3b8c Planner: remove check for empty diveplan
This was introduced in commit fc13361079 ("Don't crash if we try to save
a empty plan") - but it doesn't seem to make any sense. It is perfectly
reasonable for the diveplan to have no datapoints at this spot - we are
just about to call createTemporaryPlan() which will fill those datapoints
from the mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 15:47:42 -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
Dirk Hohndel
b36f8dd738 Planner: after freeing the plan, throw away the pointer
Otherwise we'll happily go back and access the freed data structures
later. Oops.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 11:01:37 -07:00
Tomaz Canabrava
f9166e3c0e Do not offer an editor when double-clicking REMOVE on the planner.
The  planner would offer an text-editor if the user double
clicked it's remove column. forbidding that.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:39:33 -07:00
Tomaz Canabrava
e7f764b090 Do not show 'trash' icon for deco stops.
Besides not deleting them, we shouldn't offer the icon for it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:39:16 -07:00
Tomaz Canabrava
221b1a9e01 Do not remove a Deco Stop by clicking on the trash
This patch forbids deletion of the Deco Stop from the
QTableView that holds the model.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:39:02 -07:00
Robert C. Helling
7d42b53bba Show the calculated deco stops in the planner table
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 15:12:49 -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
03eba8f99d Planner: always recreate staging dive
Instead of even trying to keep one around (which then could cause all
kinds of trouble) we now always delete it at the end of the planner.
So simply always recreate one when starting the planner (and make sure
that the staging dive has always been cleared out, first).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 22:15:44 -07:00
Dirk Hohndel
ff7bff48b8 Planner: make sure stagingDive is reset to NULL
If we first ADD a dive and then PLAN a dive, stagingDive first was an
alias to the current_dive (for ADD) - we need to make sure that when PLAN
is started, a new dive is allocated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 21:34:10 -07:00
Dirk Hohndel
6576790ff6 Add dive: only copy cylinders when necessary
If the stagingDive is just an alias for the current_dive (as it is in dive
ADD mode), there's no need to copy the cylinders; they are already there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 21:30:21 -07:00
Tomaz Canabrava
86d7f6ace0 Move code from the Planner that doesn't belongs there.
Moved the connections between DivePlannerPointsModel and
MainWindow from inside the Planner class to the MainWindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:02:46 -07:00
Dirk Hohndel
412317c91f Planner: set up a cylinder, even if no current dive is selected
If there was no current dive we didn't set up any cylinder at all which
was a bit awkward as we use AIR but have no cylinder corresponding to it,
which breaks assumptions elsewhere.

Instead we use either the default cylinder or make one up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 17:01:18 -07:00
Tomaz Canabrava
1e4f744165 Fixes showing the Empty Profile when Add / Plan dive is cancelled.
for some reason the next selected dive is NULL after cancelling the
plan. I'm investigating.

This patch fixes the show of the empty profile and it also untangles
some parts of the code, keeping the mainwindow where it should belong
: the mainwindow.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 12:25:36 -07:00
Dirk Hohndel
e4a438c96c Dive planner: remove the fake dive earlier on cancel
This way it's already gone from the dive list before it gets reprocessed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-28 10:13:24 -07:00
Dirk Hohndel
c88a90f379 Planner: correctly refresh the display
We were making things way too hard (and were doing things that don't need
doing, like clearing the DivePlanPointModel).

Currently we still crash after manually adding a dive or when canceling
a plan.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:44:47 -07:00
Dirk Hohndel
1f2159dd0c Planner: return Profile widget to profile state
This still crashes when canceling the plan.
And doesn't display the correct dive profile until you switch to a
different dive and back.
And Keyboard focus is wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:27:53 -07:00
Dirk Hohndel
7bed6e9873 Planner: use the gas in the first cylinder for initial plan
As Tomaz suggested, I don't need to pass the information whether we are on
the planner into the function - it's part of the DivePlannerPointsModel
and therefore already knows.

Also, we want to make sure we actually use the gas that's in the first
cylidner of the staging dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:12:41 -07:00
Dirk Hohndel
d1cd1eb933 Planner: better handle the temporary dive used for planning
This still crashes when you abort the plan.
And when you accept the plan, the profile stays stuck in PLAN mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-27 15:12:41 -07:00
Dirk Hohndel
9cc8e39d42 Merge branch 'Planner' 2014-05-26 13:28:18 -07:00
Dirk Hohndel
42c54e7b7e Planner: copy samples and events for plan and add
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:23:52 -07:00
Dirk Hohndel
660235c9b7 Planner: Don't include the ascent in the default dive
Allow to both create the full default dive or ownly the descent and bottom
part (so the planner can deal with the ascent).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:19:35 -07:00
Tomaz Canabrava
feff22c222 Planner: Re-enable using the new profile.
This correctly enables the planner on the new profile,
but it doesn't triggers the correct paint on the canvas.

[Dirk Hohndel: remove other remnants of the disabled planner as well]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-26 13:17:32 -07:00
Dirk Hohndel
a61c04bb58 Merge branch 'atdotde'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Conflicts:
	qt-ui/diveplanner.cpp
2014-05-26 09:59:08 -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
Dirk Hohndel
cfe865dd0c Merge branch 'atdotde'
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>

Conflicts:
	qt-ui/diveplanner.cpp
	qt-ui/models.cpp
2014-05-26 08:23:22 -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