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>
* 'otu-tracking-v2' of git://github.com/dirkhh/subsurface:
Make OTU column invisible by default
Add OTU to divelist
Calculate OTUs for every dive
Fix up trivial conflicts in dive.h (due to dive event handling also
adding a field to the dive structure)
I've been wondering how to make 'subsurface' work better on a small
screen (I used to travel with a crappy netbook - I may have upgraded my
laptop since, but it is still a design goal of mine to make sure it all
works fine in that kind of environment).
And ever since the dive list was made much wider and moved below the
notebook, it's annoyed me how much room it all takes if I want to have
both a reasonable plot window and several dives visible at the same
time.
The solution seems to be to just make the dive list be a notebook page.
That makes the default layout very dense.
At the same time, when you have the pixels, it's horrible, because you
would want to see the dive list and move between dives while at the same
time also seeing the dive profile change. But that is solvable by
simply making the dive list notebook page be detachable, so if you have
a nice big screen, just detach the dive list page and now you have
independent windows for the dive list and the dive info.
NOTE! I don't have any way to re-attach the dang thing. I think I'd
need to learn about drag-and-drop targets etc. So once you've detached
the dive list, it stays detached.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The libdivecomputer interfaces are pure crap. There are no generic
"open the dive computer" or "create a parser for the dive computer"
interfaces, instead each dive computer you support has its own open and
parser generator interface.
And they change. Happily fairly seldom, but they change. And two days
ago, Jef changed the interface for the Mares Icon HD computer in order
to support the newer HD Net Ready variant.
I've asked Jef to make a sane interface for "open the dive computer" and
"just create the parser" for libdivecomputer, but he claims that he
cannot just track the device model details internally. Which is
obviously a completely bogus claim, since the way *we* track the model
details is to just feed it back from the silly event.
libdivecomputer should just do that internally and not bother us with
its crazy internal model numbers. But whatever.
In the meantime, work around this braindamage, and hope that
libdivecomputer comes to its senses some day.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I don't know about other dive computers, but the Suunto Vyper Air is
slow as hell to import all the dives from. And libdivecomputer seems to
be importing dives "most recent first", so this just makes it stop
importing dives when it finds a dive that we've already seen.
Caveat: libdivecomputer has this fancy notion of "dive fingerprints",
and claims that's the way to do things. That seems to be overly
complicated, and not worth the bother.
If you worry about the import finishing early due to already having some
dives with the same date in your dive list, just import starting from an
empty state, and thus get a pure "dive computer only" state with no
early out. Then you can just load the old dives afterwards, and depend
on subsurface merging any duplicates.
But for normal operation, when you just want to import a couple of new
dives from your dive computer, the "exit import early when you see a
duplicate" is the right thing to do.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Not quite the same format as for the kernel, but I want to do the normal
"edit the makefile before making a release" model that I'm used to.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Yay. It's not like we're all done, but the hardcoded dive computer
location was one of those "I don't want to release 1.0 with this".
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>