Commit graph

5135 commits

Author SHA1 Message Date
Dirk Hohndel
5bead467d7 Rename two C++ methods to the more typical CamelCase
Silly little change. Whatever.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 21:02:42 -07:00
Dirk Hohndel
d740ad1317 Convert plot_gas_value to gasmix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 21:00:09 -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
Tim Wootton
d825d689dd Override the MinMaxAvgWidget tool tips for the depth instance.
Add new methods to the MinMaxAvgWidget class to allow us to override the
default tooltips of its min and max icons, and then uses these methods to
make the tooltips for the Stats tab Depth instance more descriptive.

See #521

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 20:20:17 -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
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
Tomaz Canabrava
f1d67cfbac Add threaded processing of image pixmaps
This code adds threaded processing of a batch of images. It uses the
QtConcurrent implementations to call a function repeteadly using
MAX_THREADS (Qt gets that for us) and returns a list of it.

This call is blocking, so while the pixmaps are being scaled in threads,
it will wait for all scalling to be done.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:54:29 -07:00
Tomaz Canabrava
e140703d34 Add a method to update the dive pictures on the model.
Call that method from the mainWindow when the dive changes.
The updateDivePictures walks around the events of the first dc (since all
pictures are distributed allong all dive computers) to get the events of
type '123' (I wonder if there's not a better way to save pictures on the
dive, like an linked list of char* named pictures.)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:54:29 -07:00
Tomaz Canabrava
4b520a8fbc Add a new widget on the main tab: Pictures.
Currently this does nothing, but since "dive photos" can also mean
photos that were taken during the trip to the dive, some of them
will not be visible on the profile. this currently shows nothing,
because I didn't work out the Model bits yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:54:29 -07:00
Tomaz Canabrava
1c34c831a4 Add stub for a widget to show the dive pictures.
This has a few classes: the model is the list of pictures for the current
dive, the delegate is how this pictures will be displayed on screen, the
widget is the collection of delegates, and the DivePictureThumbnailThread
is a worker-thread to generate the thumbnails so the UI will not freeze.

[Dirk Hohndel: added the new files to subsurface.pro]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:54:07 -07:00
Tomaz Canabrava
1556b723a2 Do not replot for each picture added to dive.
Instead wait until all pictures have been set and plot that.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:44:12 -07:00
Tomaz Canabrava
52ccb57832 Fix layout on the Shift-Image-Time import dialog
The dialogs where hard-coded and some variations of themes
could broke the placement of the text on it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:43:43 -07:00
Tomaz Canabrava
57d3baa410 Simplify ruler update code.
This should fix the infinite recursion on OSX and also clean a lot of
code, which is also very nice. <3

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:42:32 -07:00
Dirk Hohndel
59785345f8 Remove some unused variables
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-01 15:41:12 -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
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
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
Dirk Hohndel
e93bf1e559 Planner: add dive plan output area that replaces dive list
When switching to / from plan mode, we switch to show either the dive plan
detail widget, or the dive list widget.

So far this widget does nothing. This just makes sure it's there.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 21:08:57 -07:00
Dirk Hohndel
e74914fdd0 Planner: wild guess attempt to fix a crash on Mac
Staring at the stack trace it seems that it gets into an infinite
recursion when trying to recalculate after being alerted to a change on
the ruler. I cannot recreate this here (not on Linux, not on Mac), but
here's a random attempt to prevent the issue: simply refuse to recalculate
the ruler while in Add or Plan mode.

Crude, but might show us if this really is the issue. Otherwise it's easy
enough to revert this change. The qDebug() in there should tell us if
people on a Mac do indeed see this even without moving the ruler around in
Add or Plan mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-31 14:57:57 -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
738c472daf Merge branch 'latest' 2014-05-31 06:46:30 -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
b791b41db9 Remove unused structure member
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 15:17:15 -07:00
Dirk Hohndel
8cbf207169 Planner: remove pointless code
This never made any sense. If we have NO datapoints then go and cancel the
plan? And anyway, we already check this higher up in the call stack.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 11:02:17 -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
Dirk Hohndel
4dfe12e508 Planner: make sure all cylinders have a sane depth
When copying cylinders from an existing dive, the mod of the cylinder
might not be set. Assume a conservative 1.4 pO2 and fill in those data.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-30 09:10:35 -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
Gehad elrobey
9f12e7086d HTML: Quote the '<' and '>' operators before inserting break tags
The smaller than and greater than operators should be quoted before
inserting the <br> tags in HTML. Otherwise breaks will be quoted which
corrupts the format.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:57:34 -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
Tomaz Canabrava
2744714970 Hide the DiveHandlers that are not entered by mouse.
We need to create them, even if we don't display ( only because it
was a pain to correctly track them from the model ) - so, hide them
if it's not entered by mouse, but a deco one.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:38:24 -07:00
Tomaz Canabrava
490c7a0645 Hide DiveHandlers and GasTexts when on profile mode too.
When switching from PLAN or ADD mode to PROFILE, we
kept the dive handlers visible, not anymore.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:37:59 -07:00
Tomaz Canabrava
0c6b0334c0 Fix CMake
save-html was not there yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 20:37:43 -07:00
Dirk Hohndel
3d90bd34b2 Planner: only update the plan after the cylinder data has been updated
This way we avoid trying to create a dive from the plan while the plan
references the cylinder that has just been changed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-29 17:46:26 -07:00