summaryrefslogtreecommitdiffstats
path: root/dive.c
AgeCommit message (Collapse)Author
2012-10-02fixup_dive(): move the add_* calls before a possible returnGravatar Lubomir I. Ivanov
In dive.c:fixup_dive() it would be better to call functions like add_people() and add_location() before the possible return in the "if (end < 0)" branch. This prevents a partial auto-complete list in "Dive Info" combo boxes. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-29Correctly handle merging dives that are part of a tripGravatar Dirk Hohndel
If we have already created a dive_trip structure we need to also copy the link. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-19Partial rewrite of the dive trip codeGravatar Dirk Hohndel
This introduces a new data structure for dive trips - reuseing the struct dive just got way too messy. The dive_trip_t datastructure now allows the code to remember if the trip was auto generated or if its time stamp changed when dives where added to the trip during auto generation. The algorithm also distinguishes between dives that were intentionally added to a trip (either in an XML file or by adding them to trip in the UI) and dives that were added to trips via autogen. Saving dives that were added to trips via autogen makes that assignment "intentional". With this partial rewrite several of the oddities of the old code should be resolved - especially turning autogen on and off again should get the divelist back to the previous stage. Also, when dives are merged during file open or import we now try to pick the correct tripflag (instead of just ignoring the tripflag completely and resetting it to TF_NONE by mistake). Finally, the dive trip debugging code got more verbose and is trying harder to detect issues at the earliest time possible. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-18Fix some of the problems reported by cppcheckGravatar Dirk Hohndel
Thanks to Christian for running the static code analysis tool against subsurface... There were some false positives, a few style issues that I'll ignore for now, and two actual potential bugs. First: Don't check unsigned variables for < 0 This has been around for a while and we are lucky that while technically a bug it still works as expected. Passing a negative idx simply turns it into a very large unsigned integer which then fails the > dive_table.nr test. So it still gets a NULL returned. A bug? Yes. Critical? No. Mismatched allocation and free This is an actual bug that potentially could cause issues. We allocate memory with malloc and free it with g_free. Not good. Reported-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-29Fix profile and average depth for freedivesGravatar Mikko Rasa
Freedives can easily exceed the assumed ascent/descent rate, which results in wacky dive profiles. Add a check to make the ascent and descent fit within the duration of the dive.
2012-08-18Make fixup_divep robust against insane dive timesGravatar Linus Torvalds
This fixes the case of the dive duration being zero, or being shorter than the assumed ascent/descent time. Reported-by: Lutz Vieweg <lvml@5t9.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-08-17Merge branch 'misc-fixes' of git://github.com/DataBeaver/subsurfaceGravatar Linus Torvalds
Pull miscellaneous fixes, mostly UI stuff from Mikko Rasa. Both this and the pull from Pierre-Yves Chibon created a "Save As" menu entry and logic. As a result, there were a fair number of conflicts, but I tried to make the end result somewhat reasonable. I might have missed some semantic conflict, though. Series-acked-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> * 'misc-fixes' of git://github.com/DataBeaver/subsurface: Add a separate "Save as" entry to the menu Changes to menu icons Improved depth info for dives without samples Divide the panes evenly in view_three
2012-08-14Add exposure protection trackingGravatar Dirk Hohndel
For simplicity and shortness, throughout subsurface exposure protection is simply referred to as "suit". Add the fields to the data structures, add the column to the dive_list and the preferences dialog (once again with it being turned invisible by default). Support loading and saving of the suit information. Display the suit information in the Dive Info pane (this may be a bit controversial as people could argue this should be in the Equipment pane) and allow editing of the suit info, with our usual support for completion and drop down lists to pick from. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-07Add total weight column to divelistGravatar Dirk Hohndel
This adds the total weight carried on the dive in different weight systems to the divelist. The column is by default not shown, which can be changed in the preferences. The column is sortable. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-08-06Fill the list of weightsystems from data in existing divesGravatar Dirk Hohndel
This was simply an omission in the current implementation. All the plumbing was there but never got hooked up with the fixup_dive function as intended. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-07-31Improved depth info for dives without samplesGravatar Mikko Rasa
This calculates a mean depth for the dive with a fixed ascent/descent rate and an assumption that all of the bottom time is at the maximum depth. It's not much, but it allows some derived values such as SAC to make more sense. The depth profile for such dives is now also generated with the same assumptions instead of putting the samples at fixed percentages of the dive duration. Signed-off-by: Mikko Rasa <tdb@tdb.fi>
2012-01-05Oddly, finishing a sample doesn't require a sampleGravatar Dirk Hohndel
So let's not pass it around Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-30Move the gasmix cleanups from XML parsing to the generic dive fixup stageGravatar Linus Torvalds
Right now we do certain cylinder info operations only when importing from an XML file, which is wrong. In particular, we do the "is the gasmix air" or "what is the standard cylinder name" only at XML read time, which means that if you import a dive directly from the dive computer, it won't have the air sanitization or the proper default cylinder names. Of course, most dive computers don't actually save enough cylinder information for us to do the cylinder name lookup anyway, but some do. And all Nitrox-capable dive computers do have that O2 percentage that needs cleanup too. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-12-07Add typical 0 to 5 star rating for divesGravatar Dirk Hohndel
This works ok-ish, but doesn't allow us to click on the stars and edit them in the divelist, which a user might expect to be able to do - in most "star rating UIs" you simply click on the n-th star to set that rating. Here you need to edit the dive and pick the rating from a drop down menu. Minor oddity: you can actually (if you force it) write anything you want into the star rating. But anything that isn't one of the predefined strings simply results in a zero star rating. Overall the UI feels a bit... forced. But I think this is quite useful anyway. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-19Remove redundant linear sample tank pressure dataGravatar Dirk Hohndel
I've seen at least DivingLog do this. If you manually enter beginning and end pressure for a tank it will either linearize the samples in between or offer to simulate a dive (with constant SAC rate). At least the first case is reasonably easy to detect. We throw out those samples and ensure that we still have valid beginning and end pressure for that dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-17Remove redundant duplicate pressure samplesGravatar Linus Torvalds
At least the Suunto pressure transmitter seems to be pretty "quantisized", and it will send identical samples for a while until the pressure changes enough. Then subsurface gives this silly flat line with a sudden jump downwards, which *could* be you suddenly taking a deep breath after holding it for a while, but almost certainly it's a sensor issue. So just remove successive identical pressure readings. They aren't interesting, and subsurface will actually do a good job of interpolating it according to SAC rate instead. And they just make the XML look worse. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-10Make the sample-vs-cylinder pressure check more liberalGravatar Linus Torvalds
This makes it consider them to be identical if they are within half a bar of each other. If you edit the pressures by hand and set them to the same bar pressure as the samples, they may not be identical to the last milli-bar, but clearly the manually entered cylinder pressure isn't significantly different from the sample data, so consider it redundant. We do want manual overrides of cylinder pressures to take precedence over sample data (as Dirk so eloquently puts it, some dive computers really don't have very reliable sample data), but at the same time the sample data is the one we are expecting to be fairly accurate. The starting and ending pressure overrides are for when there is no sample data, or when the sample data is totally wrong for some reason. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-09Don't save cylinder start/end pressures unless set by handGravatar Linus Torvalds
Keep the sample pressure start/end data separate from the overall cylinder start/end data - and clean the overall cylinder start/end data if it matches the samples exactly to avoid the redundancy. This breaks all the SAC calculations etc, which expect the cylinder pressures to always be in the cylinder data. I'll fix that up separately. The reason for this is that we really want to keep the manually entered data separate: the pressure plotting doesn't need the confusion, and considers end-point data (with interpolation) very different from sample data. Also, we do not want to pollute the xml save-file with data that is computed. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-11-01Use unit functions to get column headers, add unit function for pressureGravatar Dirk Hohndel
Finally getting more consistent overall in how we convert between the different units and how we decide which units to display. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01More consistency improvementsGravatar Dirk Hohndel
Treat SAC and OTU consistently: - SAC is now a member of struct dive - it's calculated / populated at the same time with a helper function with consistent API Create get_volume_units function that returns volumes (e.g. used in SAC rates) based on preferred units - make sure we have these conversions just once in the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01Add new helper function to get temperature and unitGravatar Dirk Hohndel
Designed along the lines of get_depth_units - except we don't define a specific number of digits to show. Use this in the one spot we need it right now in profile.c Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-25Remember the event names as we encounter themGravatar Dirk Hohndel
First step to being able to filter the events that we display in the profile. We could (in theory) walk all the dives in the divelist when we need this data, but it seems much more convenient to have them in an array in one place. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-23Add completions to the dive location, buddy and divemaster entriesGravatar Linus Torvalds
This way you can just type the first few characters of a location you've been to before, and it will show you a list of possible completions. Same for buddies and divemasters (which take the completions from a list of people you've used before). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-22Add cylinder data to cylinder model as we record each diveGravatar Linus Torvalds
This way the cylinder model list will contain all the different cylinders that we have ever seen, rather than only containing the models that we have *edited*. That makes it much more practical to add new dives with the same cylinders that we've used before, because now those cylinders will show up as cylinder models even if we haven't looked and edited the old dives first. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-19Don't overwrite the end pressure with sample data if one already existsGravatar Linus Torvalds
If we have en explicit end pressure in the dive information, we should not change it just because we also have some samples. The sample data may not be complete (read: "Linus wireless connection dropped during the dive again, and he fixed up the end pressure manually afterwards"). The beginning pressure already works correctly, because it will only use the sample data for the first sample if no pressure existed before. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-10-04Make the dive merging code more tolerantGravatar Dirk Hohndel
Depending on the tool used to import a dive from the uemis Zurich we end up with different time stamps for the dive - just by a few seconds, but the existing code insisted on an exact match. We now allow for up to 60 seconds in difference and still consider two dives as the same. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-29Yes Linus, gas pressure can indeed go up during a diveGravatar Dirk Hohndel
At first glance it seems logical to make the ending pressure be the lowest pressure observed during a dive. But if you do valve shut down drills with a tech setup (where you have a fully redundant double tank setup with two valves, two regulators and a manifold in between), then you continue to breath from what is indeed the same "tank", but still the valve on which your air pressure transmitter sits does get shut down and de-pressurized. So your pressure goes down by quite a bit, and then comes back up when the valve is turned back on. And the ending pressure of the dive (which is used for things like the SAC calculation) is indeed potentially higher than the lowest pressure observed during a dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-22Merge latitude and longitude data properlyGravatar Linus Torvalds
When merging two identical dives and one of them has lat/long data, pick it up correctly for the merged dive. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22Merge dive events correctly tooGravatar Linus Torvalds
It's very similar to the sample merging. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22Start handling dive eventsGravatar Linus Torvalds
Parse them, save them, take them from libdivecomputer. This doesn't merge them or show them in the profile yet, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22Properly merge dive buddies and divemaster informationGravatar Linus Torvalds
When we merge dives, we didn't merge these fields properly. Do it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-21Add helper function for doing depth unit calculationsGravatar Linus Torvalds
.. and use it for printing too. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20Separate out the UI from the program logicGravatar Dirk Hohndel
The following are UI toolkit specific: gtk-gui.c - overall layout, main window of the UI divelist.c - list of dives subsurface maintains equipment.c - equipment / tank information for each dive info.c - detailed dive info print.c - printing The rest is independent of the UI: main.c i - program frame dive.c i - creates and maintaines the internal dive list structure libdivecomputer.c uemis.c parse-xml.c save-xml.c - interface with dive computers and the XML files profile.c - creates the data for the profile and draws it using cairo This commit should contain NO functional changes, just moving code around and a couple of minor abstractions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-12Plot a sick kind of temperature curveGravatar Linus Torvalds
.. without the actual text, because I'm a "random plots that cannot actually be interpreted" kind of guy. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12Abstract out dive/sample allocation a bitGravatar Linus Torvalds
We're going to start to want to allocate dives and samples for the libdivecomputer import too, so let's clean things up a bit for that. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12Avoid using type 'gasmix_t': use 'struct gasmix' insteadGravatar Linus Torvalds
libdivecomputer already uses 'gasmix_t' for its own gasmix thing. I don't like th eway we step on each others name spaces, but hey, might as well just use 'struct gasmix' and avoid the typedef. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-05Report errors when opening filesGravatar Nathan Samson
Signed-off-by: Nathan Samson <nathansamson@gmail.com>
2011-09-05Sanitize and fix cylinder pressure overviewGravatar Linus Torvalds
Doing per-dive cylinder start/end pressures is insane, when we can have up to eight cylinders. The cylinder start/end pressure cannot be per dive, it needs to be per cylinder. This makes the save format cleaner too, we have all the cylinder data in just one place. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Clean up 'fixup_dive()' a bitGravatar Linus Torvalds
We don't want to override potentially more exact values for water temperature etc either. The sample save interval may be longer than some internally kept state of key per-dive values like that. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Generate date string for the dive list dynamicallyGravatar Linus Torvalds
.. and sort based on the 'time_t' value itself. This allows us to use a more compact date format that doesn't need to sort alphabetically, because sorting by date is always based on the date value. So we can use just a two-digit year, and skip the seconds, to keep the column narrow, while still sorting correctly. Also, "Depth" is a nice header string, but it is wider than the column itself, which makes the whole column wider than necessary. So put the units in the header instead of in the string, keeping things narrow. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Merge branch 'compiler-warning' of https://github.com/nathansamson/diveclogGravatar Linus Torvalds
* 'compiler-warning' of https://github.com/nathansamson/diveclog: Removed the unused startemp and enttemp calculations. This fixes a compiler warning too. Fix up trivial conflict in dive.c due to the temperature simplification (commit 9961c7f89ce6: "Remove redundant temperature readings").
2011-09-04Remove redundant temperature readingsGravatar Linus Torvalds
I'm aiming to really differentiate in dive log software by making my XML export files be *clean*, dammit. That means that we don't have random names, we don't have crazy random units, and we don't have redundant information. So when the temperature doesn't change, just don't report it. That's already what "no sample" means, just clean things up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-04Removed the unused startemp and enttemp calculations. This fixes a compiler ↵Gravatar Nathan Samson
warning too. Signed-off-by: Nathan Samson <nathansamson@gmail.com>
2011-09-03Merge https://github.com/mrjbq7/diveclogGravatar Linus Torvalds
* https://github.com/mrjbq7/diveclog: dive.c: Fix spelling.
2011-09-03Do better cylinder information managementGravatar Linus Torvalds
Instead of just tracking gasmix, track the size and workng pressure of the cylinder too. And use "cylinder" instead of "tank" throughout. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-03dive.c: Fix spelling.Gravatar John Benediktsson
2011-09-03Only update mean/max depths with computed ones if they are way offGravatar Linus Torvalds
The computer may track "real" max depth more closely than it tracks samples. So we trust the non-computed mean/max depths more than the computed ones. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-03Add various dive fixups, and show pressure (if any) in the plotGravatar Linus Torvalds
Now the dive profile plot *really* needs some units. The pressure is just a random line otherwise. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>