Commit graph

404 commits

Author SHA1 Message Date
Joakim Bygdell
20a82e2b21 Improve gas accounting in the panner
When using gasmixes where the difference is less than 2% the planner can't
caclulate casconsumptions correctly. This sets the minimum gasdifference
to 1%.

Fixes #795

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-09 10:39:50 -07:00
Robert C. Helling
ea143e9668 Use unused cylinders in planner if they are displayed
This makes prefs.display_unused_tanks also relevant for the planner.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15 06:00:06 -08:00
Tomaz Canabrava
6b038c2a9a Remove the ProfileWidget from mainwindow.ui
It is now in mainwindo.cpp

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:45 -08:00
Tomaz Canabrava
cf4d55c470 Remove the DiveList from the mainwindow.ui
It's now set up from the mainwindow.cpp file.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:45 -08:00
Tomaz Canabrava
486226be18 Add the PlannerDetails class
This is the last of the current dialogs to be ported to the
new widgets system. now we need to clean the mainwindow of the
old code.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10 10:45:45 -08:00
Miika Turkia
4f9705f3f5 Fix crash when removing an out-of-profile divepoints
We can end up having a divepoint that is outside the dive profile. In
this case, we used to crash, but this hack prevents the index out of
range issue.

Fixes #784

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-03 11:27:41 -08:00
Miika Turkia
6f795a0059 Fix crash when moving divepoints rigorously
I have no idea how the index ends up outside the range, but at least
this prevents a crash in this case.

See #784

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-03 11:27:35 -08:00
Tomaz Canabrava
5a1be7620b Only update the "add dive profile / plan dive" 20x/s
We were updating the dive quite a lot of times, we really didn't need to.
This will help, but not fix, the issues with plan / add dive.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-19 16:22:08 +12:00
Dirk Hohndel
f9ceff009b Clean up the header files
Lots and lots and lots of header files were being included without being
needed. This attempts to clean some of that crud up.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-18 21:25:59 +12:00
Robert C. Helling
0d619d569b Planner rebreather mode
Do the switching based on the index rather than the string (which is
translatable!).

Update set-points when turning on/off CCR mode (remeber: the rebreather
mode is stored in two places: the divemode and implicitly in the setpoitns.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:18:48 +13:00
Robert C. Helling
f2939dd991 Minor PSCR fixes
Update O2 metabolsim rate and adopt default gas switch depths to
pSCR oxygen drop.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17 08:17:29 +13:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Robert C. Helling
d01c6c824b Rebreather type selector UI
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:24 -08:00
Anton Lundin
8b371cf8c6 Copy all cylinders when (re)planning a dive
This changes the code so we include all the cylinders from a previous
dive when we re-plain a dive.

Otherwise we would have a hole in the cylinders table when we plan a
dive based on a dive where we have unused cylinders, and it makes more
sense to copy all of them rather than not.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-04 16:27:46 -06:00
Robert C. Helling
d5d7fdc9af For CCR dives, show plot for diluent and O2 cylinder pressures
Also fixes a bug in the diluent pressure interpolation

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17 18:02:42 +00:00
Anton Lundin
a06befc007 Support different salinity in planner
Depth is often mentioned in a length unit, but what we care about is
pressure. When diving in fresh water the pressure is lower than the same
depth in salt water. This adds support for using different salinities in
planning.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12 14:42:15 -08:00
Tim Wootton
01441ccb45 Text consistency changes
ppO2 represented with 2 as subscript.
Special l symbol for litres.
Capitalisation to bring in line with existing style.

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-10 14:45:11 -08:00
Robert C. Helling
20a9db779d Offer to save to a copy in replan mode
When replannig a dive, offer another button that creates a new
dive rather than overwriting the old. This should help in creating
several versions of a planned dive (longer/shorter, deeper/shallower
etc). Note that this makes dives that start at the same time not
influcence each other's deco.

Also, only the first of a row of simultaneous dives contributes to
the tissue loadings of later dives.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-04 07:21:34 -08:00
Robert C. Helling
5fa2851bdf Start with 0 when computing maxdepth when fixing up
This is needed to get the correct maxdepth when replanning
leads to a shallower dive.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-03 14:32:17 -08:00
Dirk Hohndel
7b4bf88313 Correctly save a re-planned dive
In commit a85a219df3 ("Add ability to replan a dive that we planned
before") I completely mishandled the saving of the replanned data.
How embarrassing.

Fixes #747
See #527

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27 12:37:27 -07:00
Giuseppe Bilotta
dfec501e7a Resolution-independent trash icon
Also, generate the corresponding pixmap only once, and distribute it to
all models that need it.

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:23:36 -07:00
Robert C. Helling
5f44fdd9cf Make planner work again for CCR dives
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:07:07 -07:00
Dirk Hohndel
6195c139dc Fix planner gas consumption
We need to start out with valid SAC rates in the diveplan.

Thanks to Gaetan for finding this and suggesting a different fix - this
seems cleaner to me.

Reported-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-26 11:34:02 -07:00
Robert C. Helling
b8823acef9 Planner: Control-Click removes divedatapoint and all following ones
In order to offer a simple way to remove a calculated deco, if Control is pressed
while clicking on the trash can in the dive plan, that point and all following are
removed. This way the user can Ctrl-click on the first calculated waypoint.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-21 16:16:38 -05:00
Dirk Hohndel
dd1dc11cb6 Planner: don't show CC Set Point when planning dives
So far we only plan OC dives, so let's not confuse things by showing the
set point for the tank.

Fixes #261

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 22:15:59 -05:00
Dirk Hohndel
1620f7ec0c Planner: make sure start time is reflected in diveplan and displayed_dive
Fixes #709

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 22:10:27 -05:00
Dirk Hohndel
5b0f4e79c4 Mark manually entered waypoints as such
With this information, when we re-plan a dive we can bring the user right
back to the point where they ended - they have the waypoints in the dive
pointes table and handles are shown on the right points in the profile -
and the rest of the dive is once again calculated by the planning
algorithm.

For now this state is lost when saving the dive file as we don't add this
flag in the sample to our saved files. So if we don't find any samples
marked as manually added we add ALL of the samples as way points on the
diveplan and the user has to manually remove the ones that were
calculated.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:18:26 -05:00
Dirk Hohndel
a85a219df3 Add ability to replan a dive that we planned before
When doing this, all waypoints of the calculated ascent are now waypoints
in the plan - so the user has to remove the ascent part of the dive in
order to really replan the dive. That's a pain, but we don't keep the data
around that would tell us which waypoints are user input and which ones
were calculated.

Fixes #527

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 21:17:52 -05:00
Dirk Hohndel
76f3c0f028 Planner: don't calculate ascent while adding waypoints
It's silly to carefully calculate our ascent for each new waypoint that we
add to the plan. Let's get them all in and THEN calculate an ascent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 15:06:48 -05:00
Dirk Hohndel
77f9bf06fd Planner: correctly free divedatapoints
Simply setting the pointer to NULL leaks memory.
And that C++ recursive two function implementation... oh boy.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 15:06:39 -05:00
Dirk Hohndel
6ed189f32c Planner: bring sanity to the SAC rate handling
The old implementation was... let's call it creative.
This tries to actually get things right instead of using magic.
Don't pretend that double values are ints.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19 11:36:54 -05:00
Robert C. Helling
ecf0408aae Make SAC values in planner settings respect unit settings
So far, the fields for the two SAC rates did not show a unit and were implictly l/min.
Now they respect the settings for volume units. This was harder than I thought for two reasons:

1) Imperial units for SAC are cuft/min but a typical value would be .70. So I made the point
the field prefix and what is entered is actually hundreth of cuft per minute.

2) I had to get the rounding right in order not to get effects like 20l/min become .70 cuft/min (19800 ml/min
internally) which would then become 19l/min when switching back.

While being at it, I gave the gradient factors '%'-signs as units.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-13 21:11:07 -06:00
Dirk Hohndel
3e00bac552 Don't recalculate plan automatically with low GFHigh
While it's nice to have immediate response to gradient factor changes,
there is an oddity that very low GFHigh values can cause infinite
decompression if the last stop is at 6m.

Robert fixed this and now errors out of deco after 48 hours, but if the
user simply wants to edit their GFHigh from (for example) 75 to 70 and
deletes the '5', we really don't want to trigger a recalculation for
GFHigh of 7...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05 08:06:17 -07:00
Robert C. Helling
a3fe1c560f Update altitude properly when changing unit systems
We need to change the displayed numeric value of the altitutde and not just the
unit suffix when changing unit systems.

Fixes #681

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-03 13:44:39 -07:00
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