Open (or adding a file name on the command line) means that this is just
one of the files that you consider part of your dive history. So dives
don't get automagically numbered and the dive_list is not considered
"changed" just because another file was opened.
Import (or adding a file on the command line after --import) means that
you are importing the content of this file to your dive history. So if the
imported file has un-numbered dives that are newer than everything else,
those get correctly renumbered. And importing marks the dive_list as
changed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This option indicates that all files that come AFTER it on the command
line are being added to our divelist. The dives in these files should
receive numbers (assuming they are un-numbered and are all newer then the
dives in the files before the --import option, and assuming those dives
are numbered).
This also marks the dive_list changed after the new dives are added.
Using this option gives us a reasonable user experience in the case where
a user has one file with all their dives and wants to add newer dives
after this (after extracting them from a dive computer - as in the case of
a uemis owner where there is no direct import from the dive computer,
yet). Something like
subsurface MyDives.xml --import NewDives.SDA
It also doesn't break Linus' vision where the user has many files on the
command line which don't imply a changed dive_list.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The behavior is not yet consistent when calling with multiple file names
on the command line (as we don't add number to the later ones in this
case), but at least it catches the case if you manually renumber the dives
or if you import new dives that get added at the end - which are the two
most typical cases.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If renumbering a list of dives, default the start number to the existing
first dive number. That way, if you do need to renumber (overlapping
import or whatever), but your at least had your really old dives already
numbered, we start off with a sane default.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
When importing (or reading xml from files) new dives, we now renumber
them based on preexisting dive data, *if* such re-numbering is obvious.
NOTE! In order to be "obvious", there can be no overlap between old and
new dives: all the new dives have to come at the end. That's what
happens with a normal libdivecomputer import, since we cut the import
short when we find a preexisting dive.
But if any of the new dives overlap the old dives in any way, or already
have been numbered separately, the automatic renumbering is not done,
and you need to do a manual renumber.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
All the callers were always calling report_dives first, followed by
dive_list_update_dives(). And there really was no reason to have the
callers call two separate functions for the "I've added new dives" case.
So just call dive_list_update_dives() directly from report_dives(), and
remove it from the callers.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
We draw a little red triangle (of hardcoded size - not sure if this SHOULD
scale with the size of the plot... I like it better if it doesn't) to the
left of an event.
We then maintain an array of rectangles that each circumscribe one of
those event triangles and if the mouse pointer enters one of these
rectangles then we display (after a short delay) a tooltip with the event
text.
Manually creating these rectangles, maintaining the coordinate offset,
checking if we are inside one of these rectangles and then showing a
tooltip... this all seems like there should be gtk functions to do this by
default... but if there are then I failed to find them. So instead I
manually implemented the necessary logic.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Previously we passed in width and height and the routine itself decided to
keep 5% margin around each edge - oddly doing this with double precision,
even though this is all integer coordinates.
Instead we are now passing in a drawing_area. We are kind of abusing the
cairo_rectangle_int_t data type here - but it seemed silly to redefine a
new data type for this.
Width and height give the size of the TOTAL drawing area (as before).
x and y give the offset from the edges - so the EFFECTIVE drawing area is
width-2x and height-2y
This is in preparation for adding tooltips - those need to know the
coordinate offsets from the edges - so having this hard coded inside the
plot function didn't make sense anymore.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'uemis-integration' of git://github.com/dirkhh/subsurface:
Much nicer implementation of uemis sample parsing - and add events, too
Add working pressure to uemis tank data
This is something I wanted to do for a while. Every uemis sample is simply
a packed structure with no padding. Instead of grabbing random bytes from
the middle of an unstructured data blob let's just define the structure
and access its members.
And while we do that, add support for the more useful uemis events as
well.
A couple of the warnings are disabled by default (compile time flag) as
they are just crazy - any normal dive will give you dozens and dozens of
speed warnings. Same goes for the PO2 green warning (I haven't looked but
this seems to trigger on a PO2 over 1.0 or something). Completely useless
and just hides actually useful info.
I still want to redo the way we visualize events in general - just
printing the text ontop of the profile really is suboptimal. Especially as
the uemis really seems to love to repeat several of the warnings quite
frequently.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'uemis-integration' of git://github.com/dirkhh/subsurface:
Remove the ability to 'Import' .SDA files
Integrate loading of uemis SDA files into the regular xml parsing
First steps towards integrating SDA files into the default XML loading
Turns out they use 202.6bar as default working pressure. WTF?
Also I had misunderstood the way I should record the pressure internally
(which happened to work since I didn't set the working pressure). This is
now fixed as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Turns out they use 202.6bar as default working pressure. WTF?
Also I had misunderstood the way I should record the pressure internally
(which happened to work since I didn't set the working pressure). This is
now fixed as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We can instead 'Open' these files as they are just bastardized XML files.
This gets us back to a more consistent point where 'Import' gets data
directly from the dive computer (and hopefully soon we will add the
ability to load a dive directly from a uemis SDA to libdivecomputer),
and 'Open' loads a file from the filesystem of the computer we are
running on (this last sentence phrased so awkwardly as the uemis Zurich
SDA is a computer and presents a file system when connected via USB - it
just doesn't have the dive data in an accessible format in that file
system).
As a bonus we get to throw away quite a bit of code (the uemis specific
file handling, mini-XML parser with helper functions, the file open dialog
in the importer). Yay!
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There are a few interesting issues with this:
- this requires a change to the SDA file format; thankfully I control that
format, too (the default files are not valid XML files)
- once again, the fact that adding samples can change the dive pointer
messes with me - I decided to change the interface of ALL of the
XXX_dive_match functions to take a struct dive**
I know this is not ideal as all the other functions don't need that -
but I would have hated the inconsistency
- there is the issue that we now overload two _different_ uemis formats in
the same function - that's certainly a potential point of confusion
- a minor detail is the problem that the SDA format is kinda odd to parse
and that we trigger on the duration field by it being the only float.
Yeah, that's not ideal - but again, I control the format, so I _know_
this is true.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of having to keep the index up-to-date as we edit entries
around, just figure out the entry index from the model itself. Gtk
seems to make it unnecessarily hard, but what else is new?
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
You can still just select them and click the "Edit" button too, but now
you can double-click them (or select them and press "enter") for editing
too.
It seems to be the natural interface.
Also, remove the index column (that was there for debugging), and add
grid lines.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Instead of passing it the model and iterator (which requires that we
create the new entry for an 'add' event even if we then cancel the
operation), just make the caller do the final cylinder list update.
This way we can make 'add' work more sanely: if you cancel the add, we
now do not create an empty cylinder entry at the end.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It used to just update the cylinder list widget data, not the actual
dive information.
It still needs an "accept or cancel" dialog, I suspect.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This currently only does the same old things we used to do (so still no
start/end pressure or trimix support), but despite that this is already
more flexible than the old model:
- we can now add new cylinders, rather than just edit the information of
the first two cylinders of the dive
- because the cylinder editing is being done in a edit dialog, it is
now much more reasonable to use multiple lines and expand all the
things we can edit.
But to actually make this fully fledged, we'll need to add all the other
info to the cylinder edit dialog, and probably add a confirmation dialog
for the "delete cylinder" case too.
Oh, and right now deleting a cylinder doesn't mark the dive info changed.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We don't actually fill the widget info correctly yet, nor do we take the
actual size from the changes, but this starts to hook things up.
Soon.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This is totally useless since you cannot actually *edit* the resulting
new dive yet, but we'll get there. And this already conceptually shows
a capability that we didn't use to have with the old interface.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This leaves the actual editing code unconnected, so now you can only see
the cylinder information, not actually edit it. However, with the big
re-organization I really do want to have this as a half-way point where
I have created the new cylinder tree-view.
I now need to connect the "add/edit" buttons to dialogs that then use
the editing widgets - so I've left that widget code around, because I'll
be able to reuse a lot of it. Not all, but the cylinder type model code
in particular will be re-used pretty much as-is.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We used to do this just for the dive list, but the new cylinder view
will want to do a lot of the same boilerplate gtk stuff, so make it a
bit more generic and move it to gtk-gui.c.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Thanks Valgrind
This diff looks pointless at first until you see that I reference dive
again earlier in the loop and then after the end of the loop.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Just missed that one entirely in the xml parser for some reason.
Probably because the fields don't have much semantic meaning, so I
didn't even realize that I had missed one of the random integer values
in an event.
On my suunto, the 'value' field seems to contain things like the new
Oxygen percentage of a gas change event etc.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
And don't artificially end dives on min pressure
This may be a problem for dive computers like Linus' Suunto Vyper Air
where the failure mode seems to be _high_ pressure readings (that's scary,
btw). If the transmitter fails at the end of the dive the pressure plot
ends with incorrect high pressure. But that's simply a bug with the dive
computer and not something that subsurface should hack around. Maybe we
should offer a way to edit the incorrect data points instead.
Always ending on the minimum pressure is definitely wrong as it causes
bogus plots when you do a valve shutdown during the dive (which means that
valid data gets plotted incorrectly).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We were missing the last sample (which is usually a fast ascent).
Also, reduced the velocity smoothing to 15 seconds as the 30 seconds were
hiding too much valid information
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Admittedly the cuft ratings are stupid, but still, it's not that hard.
In order to correctly describe a tank based on the cuft system you need to
know the cuft AND the working pressure. But the uemis Zurich always
assumes that the working pressure is 200bar. That's pretty close to
3000psi and therefore works "good enough" for Aluminum tanks - but in
general this will of course fail (e.g. for HP or LP tanks).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
We don't handle doubles any different than single tanks - so while
200 cuft was a sane maximum size for a tank, once you dive with
doubles this logic fails.
We may or may not decide to implement special handling for doubles at some
point, but for now simply allow for tanks all the way up to double-150.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
* 'ui' of git://github.com/dirkhh/subsurface:
The notebook pages can only be dropped back into the main notebook
Linus would like to be less on the bleeding edge of Gtk+
Use the correct signal to avoid Gtk-CRITICAL error message
Clean up the drag and drop code and allow ripping off the Dive Profile
Disable the secondary notebooks that are created when ripping off a page
(dive_list or dive_profile) as drop targets for other pages.
Also fix the incorrect arguments for the drag callback function.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So we go back to the old interfaces to identify the notebook as part of
one group - the one that was just recently deprecated
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We used the wrong signal - "data-drag-received" is intended to check
whether the target will accept the drop. What we want is the "drag-drop"
signal which tells the widget that something was dropped on it.
Also fix an embarrassing lack of NULL pointer checks in my string
comparisons...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Linus had used some deprecated interfcase and didn't correctly untangle
the new window that he created (hiding it the window... very nifty).
I think I'm closer to the real solution with a data structure that keeps
track of the components of the new top level window that I need to be able
to untangle (and eventually, destroy) at the end.
The one error I also can't seem to get rid of is the
Clean up the drag and drop code and allow ripping of the Dive Profile
Gtk-CRITICAL **: IA__gtk_selection_data_set: assertion `length <= 0' failed
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Lots of dive computers are just variations on a theme, or sometimes even
just rebadged copies of each others with different manufacturer and
model names. The import dialog may not mention your exact dive computer
by name, but that doesn't necessarily mean that you cannot import data
from it.
Make that clearer in the README, and list the rough list of dive
computers supported by libdivecomputer.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This is somewhat hacky, and there is clearly something I still don't
understand about gtk selections and drag-n-drop. Dropping it back
works, but I get a nasty error when I do it:
(subsurface:8512): Gtk-CRITICAL **: IA__gtk_selection_data_set: assertion `length <= 0' failed
even though I actually never set any selection at all directly. So
there must be some internal gtk rule that I am violating, but I can't
see what it is.
I probably shouldn't commit it with a known ugly wart like that, but I
really have no clue. Maybe somebody else can figure out what is up.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
That also makes it always stay in front of the other window, which is
just annoying. I only did it because I wanted to make sure it dies when
the main window does, but since we just kill the main loop when closing
either window, that just isn't an issue.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* 'otu-tracking-v2' of git://github.com/dirkhh/subsurface:
Store options in gconf
Add preference option to chose if SAC and/or OTU should be in divelist
Fix up trivial conflicts in gtk-gui.c (cleanup in gtk dialog wrt
gtk_dialog_get_content_area() having introduced a new 'vbox' widget)
While it's not the most elegant way to do this I opted to store the
options with "inverted polarity" - i.e., the options that are supposed to
default to "True" are stored inverted since gconf reports an unset option
(first time the user runs the program) as "False".
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>