aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/diveplanner.cpp
AgeCommit message (Collapse)Author
2014-05-26Use get_o2() and get_he() instead of accessing permilles directlyGravatar Robert C. Helling
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-08When starting the planner, copy cylinders from currently selected dive.Gravatar Robert C. Helling
This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: show gas for the NEXT segmentGravatar Robert C. Helling
For deco stops show the gas of the next segment in the table. In recalculation remove old deco stops earlier. In struct diveplan, the items are "segments" with a beginning, a duration, and a gas. In contrast, the UI of the planner uses "waypoints" which are the boundaries between segments. It is conventional at least for deco stops to display the gas of the _next_ segment in the runtime table (i.e. the gas possibly to be switched to). Furthermore, in addStop, the old deco stops have to be removed earlier as otherwise a new waypoint later than a previous generated gas switch inherits the gas of the old switch. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Change when we recalculate decoGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18Remove unused variables and fix signed/unsigned mismatchGravatar Dirk Hohndel
The depth types are unsigned for dive plan datapoints. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18Fix crash when manually adding a diveGravatar Dirk Hohndel
When a manually added dive is saved we cancel the plan. In that process we throw away the cylinders which triggers a redraw of the profile. Which tries to access the diveplan and its data points that have already been freed. BOOM. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-18Comments added to plannerGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17Fixed mismatched connectionsGravatar Lakshman
Fixed connections to call drawProfile() in diveplanner whenever cylinder table widget is edited. Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17Mark a lot of TODO's where I think it should be moved to C code.Gravatar Tomaz Canabrava
This marks a lot of todo's where I think there's core stuff being mangled on the interface - we should remove this from the interface to make testing and maintenability easier. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17Quick whitespace cleanupGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-17Improvement for various bits of the plannerGravatar Robert Helling
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-02Add missing REMOVE slotGravatar Lakshman
Model derived from tableview is expected to have remove slot, which is missing in DivePlannerDisplay currently. This patch fixes the annoying warning message while starting Subsurface because of not including remove slot. Currently there is lot of work to do, that either requires modifying the model to skip 'remove' slot or find a way to make them inactive. Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-02Make compute waypoints content uneditableGravatar Lakshman
Currently user can edit content in compute waypoints table (in PLAN mode), ofcourse this does not trigger any calculations in the code, but user cannot see the content he needs to see after edit. This patch makes the content uneditable. Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31Merge branch 'planner-mods'Gravatar Dirk Hohndel
Nothing exciting here, just a few independent changes close to each other. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31Diveplan with entered and computed waypoints to UIGravatar Lakshman Anumolu
Recently Robert Helling provided a patch "Distinguish between entered and calculated waypoints" in an attempt to distinguish between entered and calculated stops. This patch is an independent (content wise) extension of the above patch and is built relative to it which adds new table to display computed waypoints in plan mode. Currently table includes only two columns "Comp. Depth" and "Comp. Duration", which can extended to show further information. This is only a start to the UI interaction in PLAN mode. In addition to this there are many TODO things that diveplan feature demands TODO: 1. Show more details through "Computed Waypoints" table. 2. Remove tooltip from "Computed Waypoints" table widget. 3. Make contents in "Computed Waypoints" table widget non-editable. 4. Fix error when trying to save dive plan without using cylinder data. 5. Make dive plan editable after saving it. 6. Improvise dive planner graphics window. Signed-off-by: Lakshman Anumolu <acrlakshman@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-31Distinguish between entered and calculated waypointsGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23Don't crash if we try to save a empty planGravatar Anton Lundin
Just treat it as a cancel instead. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-23Enable parts of planner based on defineGravatar Anton Lundin
In bf205726 DEPTH/Switch at was disabled by commenting out that code. This puts it back behind ifdefs Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-20Removed Duplicate IncludesGravatar Hugle
Signed-off-by: Hugle <wulong@comp.nus.edu.sg> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-17Be more careful about dive computer selectionGravatar Linus Torvalds
The selection logic was a bit random: some places would return NULL if the dive computer index was out of range, others would return the primary dive computer, and actually moving between dive computers would just blindly increment and decrement the number. This always selects the primary computer if the index is out of bounds, and makes sure we stay in bound when switching beteen dive computers (but switching between dives can then turn an in-bound number into an out-of-bounds one) Fixes #464 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14Convert other users of showError() to the new world orderGravatar Linus Torvalds
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-07Fix colors on the new profile.Gravatar Tomaz Canabrava
This patch fixes the colors on the new profile, the init of the colors map was not being done. This fixes it. A few problems were spotted on the new profile dealing with the ruler graph and a newly added dive, when using the dive add dialog. I'll be on it later. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07Remove the old profile from the main screen of SubsurfaceGravatar Tomaz Canabrava
This patch partially removes the code for the old profile from Subsurface. It removes the use of the old profile on the mainwindow, but keeping the code in the tree for now. A bit of code-cleanup also entered this commit because I had to change every instance of the code that used the old profile. Now to the real code-cleanup Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06Fix real memory leakGravatar Dirk Hohndel
We can't keep the cache around (even though it's tempting) as the next iteration might change the start time of the planned dive or other parameters which would make the cached data invalid. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03Depth widget minor UX improvementGravatar Andrey Zhdanov
Decrease depth by tapping left part of widget. Icon is showing "up" (i.e. closer to surface). Increase depth by tapping right part of widget. Icon is showing "down" (i.e. deeper). Fixes #354 Signed-off-by: Andrey Zhdanov <andrjufka@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
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-12Replace mainWindow() with MainWindow::instance()Gravatar Boris Barbulovski
C++ style of accessing single instance class object. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Don't reuse a variable name with a different type inside the same functionGravatar Dirk Hohndel
Since the variable was inside of an inner scope this was technically legal, but it's just too annoying for words. (The diff in the commit doesn't make this obvious, but outside the for loop in the same function there is a divedatapoint *dp, so we had a pointer to divedatapoint and a divedatapoint with the same name...) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Don't use current_dive instead of the argument to the functionGravatar Dirk Hohndel
I could have gone either way - the other alternative would have been to remove the argument to the function. But since current_dive is a macro and since the semantic of the function make sense with the argument being passed in, it seemed better to just not use current_dive in the function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11Update #include statement for QStringListModelGravatar Boris Barbulovski
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-11Use our macro for FP comparisonsGravatar Dirk Hohndel
I think that catches all the ones we missed (thanks clang -Wfloat-equal). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09more diveplanner.cpp improvementsGravatar Boris Barbulovski
* Move variable members construction to the initializer lists. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09diveplanner.cpp improvementsGravatar Boris Barbulovski
* Add missing variable members to the initializer lists. * Add *lazy* structure initializations. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09diveplanner.cpp cleanupGravatar Boris Barbulovski
* Add missing DivePlannerPointsModel::tempDive to the constructor initialize list. * ExpanderGraphics class: Construct pointer-variable members into initialize list, Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-26Disable the switching depth column for cylindersGravatar Dirk Hohndel
Since the planner is disabled this column isn't needed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-26Don't dereference NULL pointer when adding tanks to a dive planGravatar Dirk Hohndel
The code was obviously bogus before. Fixes #429 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-18Fix potential crash in getColor functionsGravatar Dirk Hohndel
If the index is out of range, just return black. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Fix some memory leaks.Gravatar Boris Barbulovski
Memory leaks were caused by broken parent/child relations. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Whitespace and coding style updatesGravatar Dirk Hohndel
Another futile attempt to cleanup the code and make coding style and whitespace consistent. I tried to add a file that describes the key points of our coding style. I have no illusions that this will help the least bit... This commit should ONLY change whitespace Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15Convert to TRUE/FALSE to stdbools true/falseGravatar Anton Lundin
I had problems with this one on Qt5. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24use qMakePair helper instead of QPair<int,int> and such.Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24Don't use QList if sizeof(item) > void*.Gravatar Tomaz Canabrava
QList is optimized for storing pointer-sized items, thus a QVector is the better choice for everything else. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20Use M_OR_FT macro instead of switch statementGravatar Dirk Hohndel
This is easier to read and also avoids an incorrect gcc warning. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20Planner: don't abort when saving a diveGravatar Anton Lundin
The fix for dereferencing a null pointer from me was a bad fix that broke the possibility of saving a planned dive as a dive. This is a better fix to not dereference a null pointer and be able to save the plan again. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Keep track of the minimum Depth / time on the planner.Gravatar Tomaz Canabrava
This patch makes sure that the minimum time / depth is correctly set on the profile planner. Fixes: #358 Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11Fix potential null pointer dereferenceGravatar Anton Lundin
If createTemporaryPlan was called on a empty diveplan. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-10Planner: fix potential assert in clear()Gravatar Lubomir I. Ivanov
If rowCount() is 0 we get an assert: ASSERT: "last >= first" in file kernel/qabstractitemmodel.cpp... To solve that we wrap the beginRemoveRows() call in a bnrach: if (rowCount() > 0) { ... Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09Fix another potential crashGravatar Anton Lundin
Initialize diveplan.dp to NULL, so we know that we will bail in drawProfile, when the initial settingsChanged is fired. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09Fix potential crashGravatar Anton Lundin
Initialize stagingDive to NULL, so we know that we will bail in createTemporaryPlan, when the initial settingsChanged is fired. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09Implement a settingsChanged in DivePlannerWidgetGravatar Anton Lundin
This is so we can default to the GF's from the preferences. We need the bail handler in createTemporaryPlan, because its triggered when we change GF's, and if we don't have a stagingDive there, we will access a NULL-pointer. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>