is_cylinder_used uses get_cylinder_index as underlaying function that
does the right thing with with respect on how to find the closest
matching cylinder, and handles both types of gaschange events correctly.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It seems the translation tools don't like the ?: in the argument - can't
blame them. So use an explicit if clause instead.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I don't like that the event structure includes the variable length array.
That really makes it a pain to change the name of an event (on the flip
side, freeing events is easier I guess).
Anyway, to correctly rename an event we need to actually remove the event
from the correct dc and then add a new event with the new name. The
previous code was insane (it only worked if the new name was of smaller or
equal length, otherwise it had a beautiful buffer overflow).
And of course we need to do this both for the current_dive and the
displayed_dive.
Fixes#616
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This used to work because we actually displayed the current_dive. Now with
displayed_dive the pointers are of course different! So we need to compare
the actual events instead.
See #616
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed vs unsigned comparisons are such a pain. Since we want offsets to
be +/- 30 minutes around the dive we need to allow negative offsets - but
duration_t was defined as uint32_t.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We carefully copied the dive computers and their samples and events, but
only for the second and later DCs. For the first DC we simply copied the
pointers but not what they were pointing at. So when the copied dive was
freed, those pointers in the original went to freed memory.
Not good.
Fixes#599
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is kind of the inverse to copy_dive(). Instead of duplicating all the
data that the dive points to, it moves it to a new struct dive and zeroes
out the old one so there are no two sets of pointers to these data.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
There is massive confusion about what we display when and where and which
dive structure (or pointer to a dive structure) contains which information
at which stage. This is the first step towards restructuring all of this.
This creates a global variable displayed_dive which at any point in time
should be what is displayed on screen (both in the profile and in the
maintab). It removes the editedDive concept from MainTab.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the picture has a timestamp that was within 30 minutes of the start and
finish of the dive, we take it. Otherwise we don't.
If the timestamps of the images are off, the time shift dialog allows the
user to fix this.
And with this patch the user can select all the dives of a trip and all
the pictures they took on the trip and the "right thing" will happen.
Fixes#578
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This can't be the only dive computer, of course. Goes nicely with the
ability to reprder them.
Fixes#551
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also change the on file XML to be even easier to read by making it a
duration as well (which gets us '32:34 min' instead of un-typed seconds).
This is backwards compatible, it will happily read what was written with
the previous commit).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use script ell instead of 'l' for liters to avoid confusion with digit 1.
Let's hope that this glyph is available in the common fonts, otherwise
we'll have to revert it.
[Dirk Hohndel: split commit into two]
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It makes no sense to store a 64bit time stamp with every picture. Even the
32bit offset (in seconds) from the dive start is WAY overkill. But
switching to that makes the code much more simple in a number of spots.
And makes what is saved to the XML file easier to read, too.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It confuses us elsewhere (the model suddenly doesn't match the list of
pictures as the model doesn't reflect the duplicate pictures).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
o2pressure_t
bearing_t
3) The following variables were added:
diluentpressure
o2setpoint
o2sensor[3]
4) Changes to a number of files were made to chanf
sample->po2 to sample->po2.mbar
bearing to bearring.degrees
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The picture list is a single linked list where the pictures have a node to
their next element. When adding the same picture to two dives, things got
way way wrong and crashes were appearing.
This will replicate the information (filename, latitude and longitude) for
each dive that has the picture, BUT it still tries to save as much as
possible on the actual pixmap.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit breaks the loading of images that were done in the divelist
into smaller bits. A bit of code refactor was done in order to correct the
placement of a few methods.
ShiftTimesDialog::EpochFromExiv got moved to Exif::epoch dive_add_picture
is now used instead of add_event picture_load_exif_data got implemented
using the old listview code. dive_set_geodata_from_picture got
implemented using the old listview code.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add the FOR_EACH_PICTURE macro and the code for picture count.
This uses C99 - but I will keep it like this and wait for dirk
to scream at me.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
When planning a dive, the dive could use more gas than is in the cylinder.
So getting a negative end pressure is a useful indication to the user that
there plan might not be a good one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The logic of removing the event was in the UI, and this makes
the code harder to test because we need to take into account
also the events that the interface is receiving, instead of
only relying on the algorithm to test.
so, now it lives in dive.h/.c and a unittest is easyer to make.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When we merge two dives into the same dive because a divecomputer had
incorrectly considered it two separate dives (due to surface time within
the dive) we should pick the dive ID from the later dive to be the
diveid of the resulting merged dive. Otherwise we might re-download the
(now merged) partial dive.
This is a rather unusual special case, but it actually hit me with the
Uemis on my last dive in Palau: Chandelier Cave has multiple surface
points where you can spend time admiring the cave above water, and the
Uemis (but not my Suunto's) decided that the dive was actually four
short dives back-to-back.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
[Dirk Hohndel: this overlapped with my commit 09e7c61fee ("Consistently
use for_each_dive (and use it correctly)") so I took the
pieces that I had missed]
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If a dive has multiple dive computers we enable a special context menu
when the user right-clicks on the dive computer name AND is not already
showing the first dive computer. In that case we offer to make the
currently shown dive computer the first one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously we only did this when we did fixup_dive(), but that way we
can't reference dives "early" in their life cycle (e.g., right after they
got downloaded).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When merging dives, if we know for sure that the dive computers are
different, don't merge them into one (by interleaving the data), but
instead keep both as separate dive computers in the same dive.
This fixes a bug when due to a faulty download the same dive from two dive
computers looks quite different. They don't get merged automatically
(which is fine - they are quite different), but when manually merging
them, we of course want one dive with two dive computers, not one dive
with one merged dive computer.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
C specs says that we can safelly free a NULL pointer, so there's no reason
to check if it's null before freeing it.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I'll probably add prefixes to functions to make it easier to find method
via autocomplete from the grep or interface helpers, do you wanna know all
the functions that works with a dive? ask for the completion for dive_,
do you wanna know all the functions that works with a divelist? ask for
the completions on divelist_ or run grep -rIs divelist_ on the header
files.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a preferences setting, it should belong to the preferences
structure.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch adds the current dive time and the adjusted time to the time
shift window. I added a function to dive.c to get the timestamp of the
first selected dive.
This will view the time of the first selected dive only even when multi
dives are selected but it does change the times for multiple dives
properly.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>