aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
AgeCommit message (Collapse)Author
2014-12-04Copy all cylinders when (re)planning a diveGravatar Anton Lundin
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-11-17For CCR dives, show plot for diluent and O2 cylinder pressuresGravatar Robert C. Helling
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-12Support different salinity in plannerGravatar Anton Lundin
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-10Text consistency changesGravatar Tim Wootton
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-04Offer to save to a copy in replan modeGravatar Robert C. Helling
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-03Start with 0 when computing maxdepth when fixing upGravatar Robert C. Helling
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-10-27Correctly save a re-planned diveGravatar Dirk Hohndel
In commit a85a219df325 ("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-19Resolution-independent trash iconGravatar Giuseppe Bilotta
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-19Make planner work again for CCR divesGravatar Robert C. Helling
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-08-26Fix planner gas consumptionGravatar Dirk Hohndel
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-21Planner: Control-Click removes divedatapoint and all following onesGravatar Robert C. Helling
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-19Planner: don't show CC Set Point when planning divesGravatar Dirk Hohndel
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-19Planner: make sure start time is reflected in diveplan and displayed_diveGravatar Dirk Hohndel
Fixes #709 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-19Mark manually entered waypoints as suchGravatar Dirk Hohndel
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-19Add ability to replan a dive that we planned beforeGravatar Dirk Hohndel
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-19Planner: don't calculate ascent while adding waypointsGravatar Dirk Hohndel
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-19Planner: correctly free divedatapointsGravatar Dirk Hohndel
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-19Planner: bring sanity to the SAC rate handlingGravatar Dirk Hohndel
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-13Make SAC values in planner settings respect unit settingsGravatar Robert C. Helling
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-05Don't recalculate plan automatically with low GFHighGravatar Dirk Hohndel
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-03Update altitude properly when changing unit systemsGravatar Robert C. Helling
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-07-29Retain the start time when creating plan from diveGravatar Dirk Hohndel
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-26Add dive: initialize start time of diveGravatar Dirk Hohndel
commit f29f41ae9ea8 ("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-24Planner: fix start time handlingGravatar Dirk Hohndel
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-23Planner: fix an enduring assert on startupGravatar Lubomir I. Ivanov
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-19De-duplicate planner default settingsGravatar Anton Lundin
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-18get_gas_at_time needs to always give us a valid gasv4.1.91Gravatar Dirk Hohndel
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-18Convert get_gas_from_events to get_gas_at_timeGravatar Anton Lundin
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-18Use more of our propper types in the plannerGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-18Use "6m" and "20ft" instead of "6m/20ft".Gravatar Henrik Brautaset Aronsen
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-17Planner: correctly deal with units in Ascent/descent ratesGravatar Dirk Hohndel
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-17Planner: Ascent/descent rates are stored in mm/s not in m/minGravatar Robert C. Helling
So should be defaults. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Store drop_stone_mode, bottomsac, decosac in prefsGravatar Gaetan Bisson
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-16Translate velocity units in planner settingsGravatar Sergey Starosek
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-16Date picker l10n for profile and plannerGravatar Sergey Starosek
- 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-15Save and restore Dive Planner SettingsGravatar Tomaz Canabrava
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-15Planner: don't allow the user to remove the last pointGravatar Dirk Hohndel
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-15Planner: when adding new waypoint at the end, use previous gasGravatar Dirk Hohndel
In commit b0da8c270736 ("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-12Lower CCR setpoint min value in planner to 0Gravatar Anton Lundin
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-12Add step size in our SpinBox delegatesGravatar Anton Lundin
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-11Fixed input in the DivePlanner tableGravatar Tomaz Canabrava
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-10diverplanner capitalisation consitencyGravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-10Use gasmix getters in diveplanner.cpp as wellGravatar Henrik Brautaset Aronsen
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-09Move drop_stone_mode setting to prefsGravatar Anton Lundin
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-09Refresh display after toggling backgas breaks.Gravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-07Planner: don't allow negative depthsGravatar Robert C. Helling
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-06UI restructure: remove the backupDive we no longer needGravatar Dirk Hohndel
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-06UI restructure: cleanup the code when canceling an editGravatar Dirk Hohndel
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-05When adding a waypoint, use the gasmix of the _next_ waypoint.Gravatar Robert C. Helling
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-04Planner: don't set cylinder start and end pressure when adding diveGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>