Commit graph

4448 commits

Author SHA1 Message Date
Dirk Hohndel
4e5e87c51d Don't return a stack variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 19:10:35 -08:00
Tomaz Canabrava
31ee4dac65 Make part of the context menu work (gas change event)
The code of the context menu and the gas change event callback is mostly
the same as the old profile, with minimum modifications, as this changes
the order of the code on the callback to make it a bit saner (declare
variables first, call code later).

This also fixes a bug on the model that was not cleaning itself in the
correct way after a call to clear.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 14:50:14 -08:00
Dirk Hohndel
d81223b3f4 Missing initializer
This was causing us to access uninitialized memory at times.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 14:40:10 -08:00
Robert C. Helling
bbb071f1e8 Compute dive computer/camera time offset from sample picture
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 10:59:30 -08:00
Robert C. Helling
fe2a264db3 Store camera time offset in preferences
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 10:56:43 -08:00
Miika Turkia
dd24eaa377 Fix missing air temp on divelogs.de export
Fixes #439

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-17 10:48:16 -08:00
Dirk Hohndel
e80a6822d5 Whitespace cleanup for parse-xml.c and save-xml.c
This is looking really good. Done using our whitespace tool.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 15:58:13 -08:00
Dirk Hohndel
42f32671a8 Continue to improve whitespace cleanup helper
The more I try the cleanup helper, the more corner cases I find...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 15:58:13 -08:00
Dirk Hohndel
6424b162f0 Allow backups for .ssrf files as well
In commit 102bf768944b ("Rename old 'xml' file as 'bak' file when saving")
Linus forgot about our other standard filename extension...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 15:58:13 -08:00
Linus Torvalds
90dddeb4cc Rename old 'xml' file as 'bak' file when saving
If you use the standard naming convention and end your subsurface
filename in ".xml", we will now save away any previous xml file as a
"bak" file before writing a new one.

This can be useful for:

- recovering from mistakes that deleted old dives

- seeing what changed (ie you can do things like "diff -u xyz.bak
  xyz.xml") after doing some operation and saving the result.

However, this does only a single level of backups - if you save twice,
you will obviously have lost the original. I'd strongly encourage some
external backup system in addition to this very simplistic backup.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 15:58:02 -08:00
Dirk Hohndel
16e03ff86e New profile: some more slight rearrangements
This is just an attempt to not have the time markers and dive computer
name printed right on top of each other.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 14:16:39 -08:00
Linus Torvalds
8de62c64dc Fix missed "+0.5" rounding - use rint() instead
In commit 23baf20f56 (Use "rint()" instead of rounding manually with
"+ 0.5") I had missed this one remaining place where we rounded things
by adding "+0.5" and then truncated.

Fix that up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 13:19:16 -08:00
Linus Torvalds
2d0cf4a87a micro-optimisation: avoid division in main strtod() loop
Division is expensive, so replace it with multiplication instead.  But
don't multiply by 0.1 (inexact in floating point), multiply by 10 and
then do one division at the end.

Make sure the final division is at the very end, so that the result
isn't immediately used.  That allow the division to overlap with the
function return overhead, hiding it further.

This is silly, but while thinking about different file formats and doing
profiling of loading big files, it turned out that "strtod_flags()"
actually showed up in profiles. Not very high, but at more than 1%.

This makes the common case (no exponent) use only addition and
multiplication until the very end, and makes the division be the very last
thing it does, which minimizes the data dependencies on the division.

For my stupid test-case, it cut the cost of strtod_flags() in half
according to the profile. The half a percent speedup on loading time isn't
really noticeable or even measurable outside of profiling startup costs,
but rather than carry this along in my tree or just throw it away, I'm
sending it out to see if anybody cares.

Note that we could avoid the final division by instead multiplying
"decimal" with 0.1 rather than multiplying by 10 (and switching the sign
test over), but that's a fundamentally inexact operation in binary floatig
point, so doing the "multiply by tens for decimals" ends up keeping
everything exact as long as possible.

For our use, we probably really don't care, but whatever. End result: this
should not only speed things up immeasurably, it *might* also make things
more precise at a level that we really don't care about :^p

I'm really selling this piece of crap, aren't I?

[Dirk Hohndel: sorry - had to pull the full email into the commit message
               this is so good, you couldn't make it up]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 13:17:57 -08:00
Dirk Hohndel
21ca39ab0a Fine tune positioning of temperature and tank pressure lines
Maybe not yet perfect, but better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 11:17:29 -08:00
Dirk Hohndel
582fb693a0 New profile: improve mean depth line
Show decimal depth and make the line length more appropriate for the dive
profile shown.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 10:57:11 -08:00
Dirk Hohndel
e0f8ec7144 Clean up some warnings
Unused variables, more initialization order complaints.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-16 10:44:23 -08:00
Dirk Hohndel
f3c84ccf75 Math is hard. Let's go shopping.
Alternatively, we could use fabs() to determine the absolute value of
floating point arguments.

The author of commit b6a30dcdd3 ("Improve floating point equality
test") clearly has a rather loose definition of "improve". And the
maintainer who accepted that patch shares the blame...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 18:15:22 -08:00
Dirk Hohndel
cdb69aea09 Remove some unused variables
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:45:22 -08:00
Tomaz Canabrava
4525fbb147 Fix z-value of the PartialPressure gas graph over the timeAxis
Fiz zvalue of the partialPressure Gas Graph over the TimeAxis, and also
corrects the position of the PartialPressure gas graph. It now no longer
appears to 'float' over the TimeAxis, now it's on the very top of it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
44a72b805c Make it possible to hide some of the grid lines.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
4699363a9e Better setup of the defaults for the grid.
This patch creates better defaults for the grid lines, size, position and
z-level.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
883b25cea3 Create the grids.
Create the grids, and the way that they move is fabulous <3

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:25 -08:00
Tomaz Canabrava
38e25458ee Change the axis update method to move the lines.
Change the axis update method to move the lines alongside the texts.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:30:21 -08:00
Tomaz Canabrava
0c5fd7db8e New template-based-function: remove the uneeded items on a QList.
This function is for non-duplication of code for different QLists, since I
now have Texts and Lines, I needed to make the code in a way that it
worked without dupplication.

It's a pretty standard use of templates, I think that even the C guys will
not be offended by it. :)

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:16:15 -08:00
Tomaz Canabrava
fc55b2abfe Remove the class 'CartesianPlane'
This class was pratically a re-do of the axis, I'll do the axis to plot
the lines when it feels like it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:16:02 -08:00
Tomaz Canabrava
87d5289920 Move the events when a partial pressure graph is enabled / disabled
The events were static on the canvas even if the profile changed its size
because of a toggle of the partial pressure gas. This patch makes events
move on the canvas to their correct place.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:15:14 -08:00
Tomaz Canabrava
6c67f90858 If the depth is zero, dont show it.
The first depth label of its axis is always zero, do not show it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:15:03 -08:00
Tomaz Canabrava
021d799ff9 Fix crash opening testdive0.xml
That particular dive didn't have a temperature, and thus we got a crash
while accessing the last temperature text.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 17:14:49 -08:00
Dirk Hohndel
191a3064a7 Removed unused setup function
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 11:17:23 -08:00
Dirk Hohndel
6be62c1d90 Make font label scale a per axis property
This way the partial pressure graph can have smaller pressure labels than
all the other labels on the profile.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 11:15:57 -08:00
Dirk Hohndel
980737221d New Profile: make axis labels smaller
Previously all text in the new profile was deawn in the same font. With
this change the labels on all axes are smaller.
It might be even better to allow per-axis configuration of the label size
as along the time axis the bigger size looked better. But especially for
partial pressures this looks much better.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 07:06:09 -08:00
Miika Turkia
cb5ab4bc8e Add unit support for CSV import
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 06:33:33 -08:00
Dirk Hohndel
31aa93857a Initialize device_data_t data
If the user never clicks on the log and dump checkboxes (and that's what
we expect to be the case by default), then the log / dump flags (and
filenames) were never initialized.

I am reasonably certain this will close the following three bugs, that all
show the same symptom: they behave as if libdivecomputer dump was set,
even if it wasn't.

Fixes: #426
Fixes: #431
Fixes: #435

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-15 06:31:50 -08:00
Miika Turkia
bbda9dd108 Import gas info for Shearwater Desktop
Used gas mixes and gas changes are imported. Also po2, ndl, cns and
ceiling are added to profile samples. As far as I can tell, the Searwater
Desktop shows ceiling in 3 meter (or feet equivalent) steps, but stores in feet
(or probably meters). I just use the value reported, no conversion to 3 meter
steps.

Fixes #432

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 22:47:10 -08:00
Miika Turkia
62e313df35 Import Shearwater Desktop divelog database
Sqlite database from Shearwater Desktop log software is imported. Just
the basic information like location, buddy, notes and dive profile
(depth and temperature).

This is tested with a DB in Imperial units, thus metric input might
contain errors.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 22:46:35 -08:00
Miika Turkia
4b949936c2 Refactoring sqlite import support
Move the opening of DB connection to occur before DC dependent code.
This way we can try to detect log software before calling the DC
dependent import function. This prepares for adding support for
Shearwater sqlite database.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 22:45:07 -08:00
Tomaz Canabrava
e49bd86f5e Align Right side of Cylinder Pressure Text to the Left.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Tomaz Canabrava
822ed20625 Left-Align the last Temperature Text.
The last temperature text used to have the same align flags
as all the other texts: Right. this makes it much more appealing.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Tomaz Canabrava
bd5cc109f0 Show the last temperature on the graph.
The code shamelessy copied from the old profile introduced
a bug where the old temperature was not correctly shown.
I'v added a new member to the class that will store the
last valid temperature, and use that to calculate if there's
a reason or not to display it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Tomaz Canabrava
bf4144a012 Removed the 'Unused Tanks' from the toolbar.
Just removed the unused tanks from the toolbar,
since it's just a removal of something on the ui
related code, it's good to see how much verbose
the xml to generate the UI is.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-14 21:50:05 -08:00
Dirk Hohndel
59f60f39f6 Updated user manual html file
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:41:36 -08:00
Willem Ferguson
6496f4eb61 User manual: grammar and stylistic revision
This commit was jointly authored by Pedro Neves and Willem Ferguson.
Pedro added a FAQ section to the manual. Many long lines of text were
broken into shorter lines.

Signed-off-by: Willem Ferguson <willem@willem-Precision-M4700.(none)>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:38:06 -08:00
Dirk Hohndel
f26896da1b Automated whitespace / coding style correction
First attempt to use the tools on one of our source files.
So far so good. Not perfect, but a HUGE improvement.

Most importantly it effortlessly fixed the Allman style braces introduced
in commit 51220f26ef ("Add recent files to main menu.").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:12:17 -08:00
Dirk Hohndel
ebac81b784 Fine tuning of the whitespace / coding style post processing
The struct / class regex was way too relaxed.
Having the parent class on the same line usually looks better.
clang-format appears to do something odd with continuation strings - even
with UseTab: Always it indents those with four spaces.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:10:21 -08:00
Boris Barbulovski
51220f26ef Add recent files to main menu.
Add(up to four) recent files to File main menu.

Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-13 22:05:05 -08:00
Dirk Hohndel
933d44083e Add a simplistic tool to clean up whitespace
This hasn't been tested enought, but it seems to get really close.

It assumes that clang-format is in your patch.

Run

perl scripys/whitespace.pl FILENAME

and you'll get a diff of what it things is wrong with that file.
If you like what you see, simply pipe the output into patch -p0

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 22:33:01 -08:00
Linus Torvalds
23baf20f56 Use "rint()" instead of rounding manually with "+ 0.5"
rint() is "round to nearest integer", and does a better job than +0.5
(followed by the implicit truncation inherent in integer casting).  We
already used 'rint()' for values that could be negative (where +0.5 is
actively wrong), let's just make it consistent.

Of course, as is usual for the messy C math functions, it depends on the
current rounding mode.  But the default round-to-nearest is what we want
and use, and the functions that explicitly always round to nearest
aren't standard enough to worry about.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:49 -08:00
Linus Torvalds
7ae05b4f71 Fix default value for missing surface pressure from divecomputer
We should *not* default to the incorrect "1 bar".  Instead, we should
leave the resuling pressure at 0 mbar, which leaves visual entries empty
and uses the default surface pressure for calculations.

Reported-by: Pedro Neves <nevesdiver@gmail.com>
Cc: Patrick Valsecchi <patrick@thus.ch>
Cc: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 17:41:46 -08:00
Dirk Hohndel
730e0295c9 Ensure the correct parent is used in the dialog
This way the dialog is centered and the main window gets dimmed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 13:25:23 -08:00
Dirk Hohndel
af5ad2033d Don't redeclare variables of the same name
This isn't broken, but it's confusing.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12 13:24:40 -08:00