summaryrefslogtreecommitdiffstats
path: root/dive.h
AgeCommit message (Collapse)Author
2015-06-24Rewrite GPS fix matching code for imports from our webserviceGravatar Dirk Hohndel
The longer I stared at the existing code the less it made sense. So instead I rewrote it in a way that seems logical to me. And added a boatload of debugging output (which needs to be removed, of course). I tested this against more than a hundred dives and it seemed to always pick the right fix. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-17Store the user's unit preferences in git storageGravatar Dirk Hohndel
Save and load a usually unused copy of the preferences with the units that were active the last time the dive list was saved to git storage (this isn't used in XML files); storing the unit preferences in the data file is usually pointless (that's a setting of the software, not a property of the data), but it's a great hint of what the user might expect to see when creating a backend service that visualizes the dive list without Subsurface running - so this is basically a functionality for the core library that Subsurface itself doesn't use but that another consumer of the library (like an HTML exporter) will need. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16Remove all the no longer necessary code that aborts read of first V2 fileGravatar Dirk Hohndel
This was a poorly implemented hack when we executed the reverse geo lookup in the main thread and opening a V2 file could take a very long time. We need to do the "Welcome" message quite differently. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Move git related declarations into their own header fileGravatar Dirk Hohndel
Also change the name of the enum and make sure all the inner functions get passed the remote transport information. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Cloud storage: sync the remote after saveGravatar Dirk Hohndel
This change once again tests if the remote can be reached. Even with a fairly big data file and a medium speed internet connection the remote sync is fast enough to call it nearly instantaneous. Maybe a couple of seconds. We may need more checks / different heuristics / warnings if the sync didn't happen, etc. But for now this should allow more reasonable testing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-07Temporary dive + temporary site = crashGravatar Tomaz Canabrava
We always thought that a dive had a dive site and that a dive really exists. but if we go to add dive and then go to add dive site, none of those exist yet and then we got a crash. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-11Only add disclaimer and runtime table if we added deco to replanne diveGravatar Robert C. Helling
As a side effect this changes the signature of plan(): Before it returned an int that was supposed to be possibly an error but we never bothered to check it. So now it's bool indicating if the planner did add stops. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-02Tag list handling: add two new helpersGravatar Dirk Hohndel
taglist_added() simply figures out the tags that are in the new list but not in the original list. taglist_dump() makes debugging things easier. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-28Rename helper function and make it globalGravatar Dirk Hohndel
save_one_dive_to_mb() is very useful (but there was a namespace collision with another helper in save_git.c) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24Allow images to be added via the webGravatar Robert C. Helling
This adds a new divelist context menu entry which asks for a URL. The file is retrieved and if it is an image it is added to the cache and the url is associated to dives as with local files. NB this currently only works with URLs pointing directly to images. But it should not be too hard to add the possibility to add a direction via an html file and its image tags. To test: open dives/test43.xml and delete the image and then add the URL http://euve10195.vserver.de/~robert/wreck.jpg Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24Don't load images too oftenGravatar Robert C. Helling
Factor out image load to find timestamp from loop over dives. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24Cleaning up variable names in image loadingGravatar Robert C. Helling
Use more explicit variabel names and make the get timestamp function actually return the timestamp rather than getting a pointer argument Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24Add suit field for CSV importGravatar Miika Turkia
Fixes #853 [Dirk Hohndel: fixed test compile] Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-23When deleting a cylinder, adapt gas changesGravatar Dirk Hohndel
When we delete a cylinder the gas changes in that dive may have to be adjusted. We didn't do this at all in the past. With this commit we should be doing this right for a single dive that is being edited. This does NOT handle multiple dives being edited at the same time (or more specifically - if you have multiple dives selected and delete a cylinder, the dives that had the same set of cylinders (other than the displayed dive) will get that particular cylinder deleted, but won't have their gas change events (and sensor data in the samples) adapted. Possibly we should simply prohibit deleting cylinders when more than one dive are selected. See #834 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-22Handle XSLT based imports correctlyGravatar Dirk Hohndel
XSLT conversions create V2 XML files, but we shouldn't abort when we parse those without having the user informed about the potential slowness - all XSLT based imports are slow, anyway. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-02Only do safety stop of dive has at least max depth of 10mGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-23Import support for new Seabear formatGravatar Miika Turkia
This add support for Seabear's new import format that is used by H3 and T1. In the future also the Hudc should switch to the new format. The main difference to the old one is that time stamps are no longer recorded in the samples, but intervali is specified in the header. The header contains other useful information as well that we should build support for. E.g. surface pressure, gas mixes, GF, and mode might be useful additions later on. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-15Refactored image timestamp checking.Gravatar Jan Darowski
Seperated getting image timestamp from picture_load_exif_data() and ShiftImageTimesDialog::syncCameraClicked() into picture_get_timestamp() and seperated checking timestamp from dive_create_picture() to dive_check_picture_time(). Signed-off-by: Jan Darowski <jan.darowski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-11Event name should be a const char *Gravatar Dirk Hohndel
This avoids a possible warning when calling this function with a string literal as second argument. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-27Add hashes to imagesGravatar Robert C. Helling
Upon successfull reading an image file, this computes a SHA1 hash of the image and saves it with the picture tag in the log file. When a file is not successfully loaded (for example because the log was created on a different computer) we look up the hash in a dictionary that maps hashes to local file names. That dictionary (actually two for both directions), is loaded on startup and saved upon destruction of the main window. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-25Display slowness warning before opening a V2 fileGravatar Dirk Hohndel
This is somewhat invasive as aborting the XML file read requires us to report things up the recursive parsing chain. What we really need to do here is to ask the user how they want to use the data from reverse geo lookup. But for now we only warn about the fact that this can take a while. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Allow editing of dive sitesGravatar Dirk Hohndel
And hook things up when double clicking the globe. The user experience isn't consistent with what we do on the main tab (i.e., no coloring of fields that are changed), but it seems to work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Finally remove location, latitude and longitude from struct diveGravatar Dirk Hohndel
With this all references to these members should be gone and all the code should be switched over to the dive site infrastructure. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-13Adapt GPS coordinate download from our companion app to dive sitesGravatar Dirk Hohndel
This is a bit awkward now. We are downloading what looks like fake dives in the v2 format. So we create a dive site for every single fix. After we merge those new dive sites into the existing dives we need to throw away all the dive sites that weren't used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Make special backup when switching XML versionsGravatar Dirk Hohndel
Since the last few dozen commits change the format in irreversible ways and could therefore be destructive and lose data for testers of the development version, let's try to be extra careful and create "special" backup files that aren't overwritten by subsequent backups. At least this way people can go back to the previous state. Of course people using the git backend don't have to worry about this as they always can go back to any earlier save. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Switch components for cut/paste dive to dive site logicGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Get trip location from dive's dive siteGravatar Dirk Hohndel
This adds another useful helper function as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Show dive coordinates on map based on dive siteGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Save and parse dive site structures to XMLGravatar Dirk Hohndel
Read and write divesite sections in the XML file. Read divelogs of version 2 and create dive site structures on the fly. Read version 3 files that have divesiteid instead of location / gps. Saves version 3 files where dives no longer have location and gps but instead refer to a divesiteid The commit contains quite a few fprintf(stderr,...) in order to allow better monitoring of the parsing / transforming of locations and gps to dive sites. This will need to be removed later. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Add dive site data structureGravatar Dirk Hohndel
This leaves location and gps coordinates in the struct dive to allow a step by step migration. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-11Remove redundant functionGravatar Dirk Hohndel
We had two functions doing exactly the same thing. Let's drop the one with the highly confusing name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-10Only update tags in the selected dives if they were changedGravatar Dirk Hohndel
If current_dive and displayed_dive still have the same tags then we shouldn't touch the tags of other selected dives. Fixes #826 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-20Use SAC from preferences for PSCR oxygen dropGravatar Robert C. Helling
The ratio between SAC and oxygen metabolism rate can be assumed constant but not the metabolism rate. So we better base our calculation on the ratio that uses the SAC from the preferences as that pairs well with the O2 consumption from the preferences. Hence we ran remove the sac parameter from fill_pressures(). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-17Save predefined SACGravatar Robert C. Helling
When planning a dive, the gas consumption is based on a user configured SAC. Thus we should use that SAC and not try to recompute it from samples. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10Refactor dctype -> divemodeGravatar Robert C. Helling
... and repair a failed rebase (sorry). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10Maintab combobox to set dive typeGravatar Robert C. Helling
still needs some work Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09Add more infrastructure for a separate dive tableGravatar Dirk Hohndel
This will allow us to download the dives from the dive computer into a separate table just for that purpose and not into the main dive_table. I really dislike the code that's in place that dates back to the very earliest code written for Subsurface. Dumping the dives straight into the main dive_table seems really stupid to me. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-06Add missing divemaster field to the manual importGravatar Dirk Hohndel
No idea why I didn't notice earlier that this was missing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31Use unit selection for XSL transformation on CSV exportGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-31Add duration format to XSLT callGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28Switch to using unsigned char in DLF importGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-28Initial support for Divesoft FreedomGravatar Miika Turkia
This parses the dive profile from Divesoft Freedom log file. Only the depth profile is currently supported. There is also something wrong as the log file cannot be given as parameter but must be opened or imported once Subsurface is running. Note that so far no metadata is parsed. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20Glue between GUI and XSLT for additions in CSV importGravatar Miika Turkia
This code sets the parameters properly to support the new fields in manual CSV import. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-20Bare implementation of Cobalt Divelog ProgramGravatar Miika Turkia
This implements importing of dive profile and temperature graph along with some meta data from a Cobalt Divelog database. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-08Don't ignore when we can't parse a fileGravatar Dirk Hohndel
We are quite inconsistent when it comes to reporting back errors. One case where this caused somewhat unexpected behavior was when the user would try to open a .csv file by passing it as command line argument. The file was silently ignored, but treated as if it had been opened successfully. Now we issue a somewhat reasonable error message. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25Allow user to select date format on manual CSV importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-24In our floating point comparison 0.0 should be equal to 0.0Gravatar Robert C. Helling
We when comparing floating points we do a relative comparison of the difference. This fails when both numbers are (exactly) 0.0 which happens to occur when plotting an O2 graph without o2 data resulting in both min and max for the y-axis to be 0. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17Add helper function to translate cylinder use text to matching idxGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17For CCR dives, the diluent cylinder is the current cylinderGravatar Robert C. Helling
Change the meaning that _the_ cylinder (as we treat it in OC dives) is the diluent cylinder (rather than the O2 cylinder). This eliminates special cases. Now, for CCR, we have to handle the O2 cylinder in addition (rather than the diluent in addition). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-17Fix per_cylinder_mean_depth calculation for CCRGravatar Dirk Hohndel
This patch is bigger than necessary because I also renamed the get_cylinder_use() function to the much more accurate get_cylinder_idx_by_use(). If we have no gas changes (except for a possible explicit first gas), (which in the CCR case also means no bailout), this code will give you correct per cylinder depth and duration for oxygen and diluent and therefore create more reasonable gas consumption data for CCR dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>