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.
Merge freediving tweaks (zoom in on short dives etc) from Maximilian
Güntner.
Trivial conflicts in display.h due to unrelated printing stuff just
happening to be added nearby.
* 'freediving-tweaks' of git://github.com/mguentner/subsurface:
moved zoomed_plot to display.h
plot the time with a fixed padding (leading zero)
updated/corrected comment
added "Zoom" button and improved scaling
fixed indentation
use increments that make sense for 600 seconds
Plot shorter (apnea) dives with a reasonable scale
The previous commit was a patch from Lubomir, which also had some
whitespace fixes (to go with some new whitespace bugs to replace them)
in it.
I removed the whitespace changes from that patch (don't mix whitespace
fixes with other fixes, unless they are on the same lines!) but decided
to look for other whitespace issues, and this is the result.
I left the non-C files alone, some of the spec and script files also
have whitespace at the end of lines etc.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This completely changes how we keep track of selected dives: instead of
having an array listing the selection ("selectiontracker") or trusting
the gtk selection information, just save the information about whether a
dive is selected in the dive itself.
That makes it trivial to keep track of the state of selection across
group collapse/expand events, or when changing the tree view model. It
also ends up simplifying the code and logic in other ways.
HOWEVER, it does currently (re-)introduce an annoying oddity with gtk:
if you collapse a dive trip that has individual selections, gtk will
forget those selections ("out of sight, out of mind"), and when you do
*new* selections, the old hidden ones remain.
So there's some games required to make gtk do sane things. We may need
to either explicitly drop selections when collapsing trips, or make sure
the group entry gets selected when collapsing a group that has
selections in it. Or something.
There may be other issues introduced by this too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The code iterates over a list that can be NULL, but happily dereferenced
it anyway. Oops.
This function really should be split up and commented more.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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
This fixes the bug that triggered the SIGSEGV that Linus worked around
earlier. I had forgotten to update this call path to the
edit_multi_dive_info function.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
It should be possible to have a certain limit where we
stop zooming so that short dives are visible as such
at first glance. Therefore a "Zoom" button has been
added to the "Log" menu along with a shortcut (Ctrl + "0").
The user can now zoom/unzoom the plot and is still able to
quickly distinguish short dives from normal ones when
browsing the log.
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
The time marker increments have also been changed to better values.
Also, display more time information for short dives.
Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
Fix ugly printout, give colors proper names, make grid lines and alert
marker easier to see, and specify printer colors independently.
Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
The profile colors were defined all over the place, so I put them all in one spot. I'm unsure if this is the best solution to that problem, but I guess it's a step in the right direction.
Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
The profile colors aren't very pretty, and the grid lines are too thick.
This commit tries to improve that.
Signed-Off-By: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
We do all the pressures in mbar, which has plenty of precision for
interpolated pressures - even when we then do our discrete integration
over many samples.
However, when we calculate those interpolated pressure points, we should
make sure that we round the result correctly, otherwise the consistent
rounding errors (from truncating the FP value into our integer mbar
values) will result in a final pressure that is noticeably off in ugly
ways (ie "end pressure set by hand to 750 mbar, but shown as 748").
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This reverts commit abdee5b1b8.
There's no point in doing random hacks. Instead, do the intermediate
pressure calculations with proper rounding instead of always truncating
to mbar. With the math done correctly we have enough precision that the
end result of the pressure interpolation doesn't have the kind of errors
that caused Dirk to try to fix things up later.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
While printing the last pressure in the calculated sequence may seem more
logical, given that the discrete series will create some amount of error
this simply looks wrong. Instead we pick the end pressure that was
manually set.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some parts of the existing code used the depth at the time of the sample
to calculate the sac rate - it makes much more sense to use the average
depth. But that requires us to loop over the entries and average the
individual sac rates per segment instead of just using the beginning and
end depth of the multi-segment interval we use for smoothing purposes.
This may seem like a subtle detail, but it does in fact matter when we
plot the synthetic tank pressure values that we create when we have no
tank pressure data in the samples.
Another detail we change here is to not artificially start with a forward
looking segment of the full SAC_WINDOW but instead just start with the
first two data points and then simply let the time window grow until it
hits SAC_WINDOW - at which point it becomes a sliding window.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This changes the algorithm that picks the sac color to consider
+/- 1 l/min to be the same color (before the color changed every
time you crossed above or below the average which looked silly with
our synthetic "constant sac" values as those are discrete and oscilate
around the average.
This also changes the order in which things are drawn so so that the
pressure plot goes over the depth profile plot (so the red shading of the
dive no longer changes the color of the tank pressure plot).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use rgb_t for the sac colors, create a new set_source_rgb_struct function
and use that for the velocity values (in the depth plot) as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Linus suggested that instead of using absolute SAC values to base the
color on (which forced us to pre-define which SAC rates are green and
which are red) we should color the tank pressure plot relative to the avg
SAC rate of that dive - which I think makes the coloring much more useful
to spot when on your dive you were doing well and when you were not.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Similar to color indicating vertical speed in the profile plot we now use
color in the tank pressure plot to indicate current SAC rate.
We use a 45 sec sliding window to make sure we cover at least two breaths
for each current SAC sample to avoid artificial oscillation based on
breathing rhythm for corputers with high sample resolution.
Not sure about the color coding that I'm using right now - it's green-ish
for SAC rates under 15l/min ~= .55cuft/min and turns yellow and red as you
go higher. That seems to work well for me, but for other divers this may
be way off (or at least not as useful). Maybe this should be configurable?
This is a lot more diver specific than the vertical velocity where there
are clear recommendations based on safety considerations on what is good
and bad.
As a side effect, this removes the color coding that showed you whether
you were looking at pressure data from samples (green) vs. interpolated
pressure data (yellow). Not sure if people really want to see that. We
might be able to indicate this differently (I am thinking different line
width or transparency or something along those line)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some dive computers randomly drop samples. That was no problem unless it
was the LAST sample. We work around that now
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
.. and fix the maxpressure to actually look at *all* the cylinders, so
that if you don't have sample data, but rely onmanually set cylinder
pressures, it now really is the max of all the cylinders.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We no longer look at the start and end pressure for a tank, if the tank
has valid pressure data in its samples (which makes sense). Sadly that
breaks the current pressure interpolation code. With this patch most of
those problems should be fixed.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- make the text a lighter color so it stands out more
- change the heuristic when we print text to include both relative change
in temperature and time since the last text was printed
- print the first temperature we encounter
- allow an ending temperature to be printed if the last printed
temperature was before the 75% mark of the dive
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I thought we had fixed this before - but I guess it got broken again
somewhere. We now make sure that the plot_info ends on an entry with
depth 0.
Added test14 to verify the fix.
Also fixed cut'n'paste errors in a few test dive files.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In some situations we could end up with no sample pressure and no
interpolated pressure at time = 0. This is now fixed.
Fix notes in test dive the exposed the issue.
Also change the code in create_plot_info to keep the number of samples and
the number of corresponding pi entries in separate variables. This avoids
future changes from breaking if they assume they can access
dive->sample[nr_samples - 1] (which is a reasonable assumption to make).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was exposed by the test dives, but it shows up in small ways with
real dives from some dive computers like the Suunto Vyper Air.
We now insert synthetic plot_info entries that match the gas change event;
to make this look smoother we insert either two events (one for the old
tank, one a second later for the new tank) if there is no sample at the
time of the event, or one additional event (and move the real sample back
by one second) if there is a sample at the time of the event.
This does expose another issue with some dives from Linus' computer where
the pressure in the samples dips below the end pressure noted for the tank
- which creates an odd "yellow up-tick" at the end of using the first tank
in the plot. Maybe we should not insert a synthetic "last of old tank"
event if we have a sample with valid pressure in the last NN seconds
before the gas change?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we have more than four identical depth readings, the old code would see
those as local maxima and minima and print spurious depth values in the
profile plot.
Yes, in real sample data identical readings won't happen - but in
synthetic data they can and there this looks really bogus.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
We used to have the dive plot have two "filler" entries at the beginning
and the end, and indeed that is how they are allocated. However, we fix
up "pi->nr" later to be "lastindex+1", where "lastindex" is the index of
the time we surface.
So when we loop over the plot entries, we actually need to loop all the
way to the end: use "i < pi->nr" instead of "i < pi->nr-2".
We still do have the two extra filler entries at the beginning, though.
So depending on the loop, we might want to start at entry 2.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Right now it just plots something ridiculous, the code is really just
meant to be an example. We migth be able to plot a traditional
staircase plot and make it look somewhat saner by taking mean depth into
account (if it exists).
Right now it just plots a (skewed) rectangular dive profile using the
max depth and total time. Which is obviously insane.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
When creating the plot_info, the 'entry' variable pointing to the last
plot_info data was not initialized (because there was no data to fill
in), and was then incorrectly used to fill in the last tank pressure.
We also used to look at 'dive->sample[0].cylinderindex' even if no
sample[0] necessarily existed.
Reported-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Right now they are displayed in one hbox which doesn't work if you have
many events - but the code itself works and correctly toggles the events
on and off.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We don't have a way to actually configure this in the app, yet, but
toggling the bits in the debugger shows that this works, so commit this
code now.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
* 'ui' of git://github.com/dirkhh/subsurface:
Disable sorting by dive number
Fix oversight in preference implementation
Make columns for temperature, cylinder, and nitrox optional
Show dive number in dive list
Improve time marker handling and add printing of some time labels
We now draw time markers at most every 5 min, but no more than 12 markers.
For convenience we do 5, 10, 15 or 30 min intervals.
This allows for 6h dives - enough (I hope) for even the craziest divers -
but just in case, for those 8h depth-record-breaking dives, we double the
interval if this still doesn't get us to 12 or fewer time markers.
We label the first and then every other time marker with the minute text.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dirk wrote the multi-cylinder support assuming that the dive computer
always gives the selected cylinder index in the sample data - that's
what his Uemis does, and it makes sense for any dive computer that
supports multiple pressure transmitters.
However, the other case is a dive computer where the pressure samples
are all from cylinder 0, and any other cylinder will have the starting
and ending pressure set by hand. And the gas change events show when
the cylinder change happened.
So this creates a "turn gas change events into pressure sample fixups"
phase just before we actually analyze the pressures. That way the
pressure analysis can alway sdo the right thing, regardless of how the
data was originally stores in the dive.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
For the dive computers that give cylinder change events, we want to
re-write the cylinder index and pressure information with the event
information before we start analyzing the pressures. So instead of
filling the plot info and analyzing in one loop, split it up into two
phases. We'll do the "fix up cylinder pressure info based on events" in
between those phases.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The code keeps track of the segments of time when a specific tank was used
and interpolates the pressure values for that tank based on a simulated
average SAC rate for the times in which no pressure readings are
available.
This changes the way we used to plot the pressure when only beginning and
end pressure of a tank are known; it used to be a straight line, now it is
a sloped line where the steepness of the slope is proportional to the
depth at that point - which is much more realistic.
We also plot the pressures in two colors now. The old green for pressure
data that came from the input file (that is not the same thing as saying
it came from the computer - divelog for example appear to create pressure
readings in the samples even if it only has beginning and end pressure).
Interpolated values are plotted in yellow. If you have a sub-standard dive
computer which has a frequently failing pressure sensor, you can now tell
the parts of the plot where data was missing and we are filling in.
The function that prints the pressure text labels had to be completely
redone as it previously assumed one tank for the whole dive and
simplisticly printed that tank's start and end pressure at the beginning
and end of the profile plot with the y-values being the maximum and
minimum pressure...
This commit introduces a custom simplistic single linked list data
structure to keep track of the pressure information per segment - Linus
hated the idea of using GList for this purpose, and I have to admit that
in the end this was very straight forward to implement and made the code
easier to read and debug.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This isn't right if you switch back to the same cylinder multiple times,
but for the first time it kind of works - just take the beginning
cylinder pressure if we have one.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Too much cut-and-paste, as Dirk points out. With multiple cylinders,
we're not necessarily going to start at time zero.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It doesn't actually do multiple cylinders correctly yet, but it should
be a nice framework for it. And accidentally (not) it also ends up
drawing the final line for the end pressure of a single-cylinder dive
that has been fixed up by hand too.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.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>
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>
This is *really* ugly. We really should just create some kind of widget
that when moused over will show the event. Or something. Rather than
putting text on top of other text: the events - when they happen - are
usually bunched together (PO2 warnings, max depth, fast ascent leading
to mandatory safety stop, you name it).
But at least this way we see that the data is there, even if we see it
in ugly ways.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The plot_info was never freed, so every time you'd plot something, we'd
leak memory.
I'm running valgrind to see if there's anything bad going on. So far it
all looks fairly benign.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Use the actual degree sign for temperatures (°F and °C), and make sure
everything uses the proper "set_source_rgb[a]()" wrappers to set the
colors.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Dirk wrote this before we have the 'plot_info' structure with the
cleaned-up dive info. No need to maintain that separate array of depths
and seconds.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
If the velocity is slower than FAST then we look back up to 30 seconds and
calculate the velocity for the past 30 seconds instead.
For the first version I'm not doing the average of the changes but simply
the change from beginning to end.
The alternative would be to do another triangle smoothing or something
like that - but as we don't know how many samples we have in the 30 second
window, it's a little harder here.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This annoyed me from the first moment Linus added the tank pressure graph.
As the pressure goes down, the graph needs to go down. Seriously.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
So far Linus has hated all of my attempts to visualize vertical velocity
through color. This time I'm trying something dramatically new: there is
no PURPLE involved. Maybe that will convince him of the value.
We simply calculate the vertical velocity for the current plot segment
(last sample point to this sample point - in this version even without
divisions by zero) and assign a label based on the rate of change. These
labels are translated through a predefined table into colors:
Dark green is +/- 5ft/min (stable)
Light green is descents up to 30ft/min and ascents up to 15ft/min
Yellow is descents up to 60ft/min and ascents up to 30ft/min
Orange is descents up to 100ft/min and ascents up to 60ft/min
Red is outside of those ranges - you are most likely in danger
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Even though we go down to an 8pt font the info_frame changes size when the
air info is added. I don't like this but want to see how Linus would like
this resolved before going overboard.
Minor tweaks to the formating (we don't need two decimals when printing
the liters of air consumed).
This patch does NOT remove the plot of the air information in the profile
graph. I think we want to remove that once we like the text where it is,
but I wanted to do one thing at a time.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the temperature is in a very narrow range the existing code visually
exaggerated the fluctuations. This tries to dampen that effect a bit.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Change the duration max rounding as noted by Dirk, and move the air
consumption down further towards the bottom right corner. In
particular, I make the text positions not scale with the window size,
purely by the size of the text.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
- the time stamp where we printed the last temp was wrong
- we really shouldn't check mK for being identical - especially on dive
computers that store a lot of samples
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Ok, this is pretty much it now. Instead of having various random checks
for "is the time of the sample past the end of the dive" hacks, we not
plot all graphs from the cleaned-up plot_info structure instead of the
raw samples.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Further movement to using the sanitized and cleaned-up plot info rather
than the raw data.
The raw dive data contains samples from the end of the dive that we
don't want to drop, but that we also don't want to actually use for
plotting the dive. So the eventual end goal here is to not ever use the
raw dive samples directly for plotting, but use the diveplot data that
we have analyzed for min/max (properly ignoring final entries) etc.
There's still some data that we take from the samples when plotting, but
it's getting rarer.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Do the min/max calculations only *after* we have removed the extra
surface events at the end.
The Uemis data in particular has a lot of surface events after the dive,
and we don't really want to take them into account since we won't be
plotting them anyway.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
.. I'll want to move pressure limit calculations into the 'plot_info',
so that we can do several passes of analysis and change dive limits etc
without having to actually modify the dive data itself (or add new
fields to 'struct dive' just for plotting).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Currently we print the temperature every five minutes. Especially with
dive computers that keep rather frequent temperature samples that means
that we have one more interesting data point that we don't label: the
surface temperature at the end of the dive.
This patch adds some logic to try to print the last temperature sample
that was recorded before the dive ended - unless that same value has
already been printed (to avoid silly duplications on dive computers with
less frequent sampling)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Just like we end depth and tank pressure plots once we are on the surface
(this is relevant for dive computers like the uemis Zurich that keep
recording samples after the end of the dive)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I'll get there. Shrink it down a bit, start adding notes and location,
and maybe put three per page. That might work.
.. or maybe I should just take a look at how others have done this.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Ok, this is the ugliest f*&$ing printout I have ever seen in my life,
but think of it as a "the concept of printing works" commit, and you'll
be able to hold your lunch down and not gouge out your eyeballs with a
spoon. Maybe.
I'm just doing the cairo display as-is for the printout, which is a
seriously bad idea. I need to not try to do colors etc, and instead of
having white lines on a black background I just need to make thelines be
black on white paper.
But that would involve actually changing the current "plot()" routine,
which is against the point of the exercise right now. This really is
just a demonstration of how to add printing capabilities.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
It doesn't really make much of a difference, but it can be visible
especially with lots of tight samples. Miter joins really look horrible
for acute angles.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Oooh, pretty.
Or not. The temperature graph is usually ugly as hell, but Dirk has the
cool dive computer with lots and lots of temperature readings. Which
makes the graph a pretty graph, rather than a butt-ugly staircase like
mine.
Next time: get a dive computer with an OLED screen, and that can draw
pretty temperature graphs.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
.. 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>
I'm trying to make sure that we can shrink the main window and still get
a useful experience. Sometimes you have small bad netbooks when diving..
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Instead of relying on our ad-hoc minmax finder, just use the local
minima/maxima information directly.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This way we can always find the actual min/max entry that generated the
local minima/maxima. Which is useful for visualization.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Dirk likes purple. I mean - Dirk REALLY likes purple.
And what's better than "purple"? You got it: "funky purple".
So this shows the one- two- and three-minute min/max information in some
seriously funky purple fringing. It's not really necessarily meant to
be serious, but it's a quick hack to visualize the data until we figure
out what to *really* do with it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This turns the depth profile into a generic "plot_info" and calculates
minima, maxima and averages over 1-, 2- and 3-minute intervals for each
point. It also creates a smoothed version.
We currently don't actually show the results, but that's the next step..
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
.. unless they are so shallow that they are basically at the surface.
These show up automatically in out min/max logic, so just go ahead and
show them.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
No change in semantics, I'm just contemplating doing some text renderign
from within the "minmax" function itself.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Ok, so it's really a 'double', but for now we're only using integer font
sizes, so let's see if we ever want to do anything but that.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Add new valign enum to text_render_options_t and update all callers to
plot_text
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
[ Fixed spelling, updated to newer base - Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
I still think there should be some way to partition the space
automatically, but the algorithm that worked best was the simple
tail-recursive one.
Which might as well be expressed as a loop.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
We don't actually use the 'dive' structure any more, since we now always
have the sample pointers directly.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The way cairo does scaling is really really inconvenient, and one of the
things in cairo that is fundamentally mis-designed.
Cairo scaling always affects both coordinates and object sizes, and the
two can apparently never be split apart. Which is very much not what we
want: we want just coordinate scaling.
So we cannot use 'cairo_scale()' to scale our canvas, because that
screws up lines and text size too. And no, you cannot "fix" that by
de-scaling the line size etc - because line size is one-dimensional, so
you can't undo the (different) scaling in X/Y.
Sad. I realize that often you do want to scale object size with
coordinate transformation, but quite often you *don't* want to.
Yeah, we could do random context save/restore in odd places etc, but
that's just a sign of the bad design of cairo scaling.
Work around it by introducing our own graphics context with scaling,
which does it right. I don't like this, but it seems to be better than
the alternatives.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This is a bit more natural, and makes it much easier to do scale
independence. In particular, I want to make it possible to grow and
shrink the graph, and this should make it particularly simple to react
by giving more or fewer minmax points.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Use start/end sample pointers to make a recursive algorithm possible.
Also, clean up the end condition - we don't want to return an
uninteresting minmax result just because we ran out of samples.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This shows the depth properly in meter or feet depending on unit
selection.
It also changes the horizontal depth rulers to be at 10m/30ft intervals
rather than the previous 15ft. With the textual depth markers, the
horizontal lines aren't as important any more.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Ok, it's an odd place to start, but this now shows the pressure curve
details and the air usage in the proper units.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Soon we'll show things in psi or bar depending on user choice. Let's
not get confused about units before we do.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The UEMIS Zurich SDA keeps recording samples for quite a while after the
dive ended. These provide no additional information, but confuse our
drawing algorithm as they can cause us to draw both the depth and tank
pressure plots beyond the right edge of our canvas.
Stop drawing if sample->time.seconds is larger than dive->duration.seconds.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* dirk:
Print starting and ending pressures
Fix up conflicts in profile.c due to different ways to set the text
formatting. Dirk's 'text_format_options' thing is prettier than mine.
Use it.
This is very simplistic as far as placement of the text goes.
It makes the plot_text function somewhat more generic.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Show "absolute volume" used, and SAC/m (surface-equivalent per minute).
I'm not going to guarantee the calculations. And I show the result in
cubic feet. Sue me.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Text notes need to be last, so that they don't get stepped on by the
other graph elements.
Also, separate the depth text plot out into a function of its own.
Tidier that way.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Use a 10-minute window *or* when the depth has reversed sufficiently to
make the max we've found interesting.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Add some actual numbers to the depth plot too. Do it by finding the
deepest points (within a five-minute rolling window), and show the
depths of those points.
Sure, we could have just labeled the depth markers, but this seems
nicer. But what do I know - I'm not exactly famous for my GUI design.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Only draw the pressure line to the final data point
(duration / end.mbar) if we haven't already drawn samples
past that point (as the UEMIS records pressure data for a
number of additional samples after the actual dive has ended)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
[ Changed to use 'last actual drawn sample time that had pressure
data' instead of 'last sample time' - Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
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>
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>
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>
The time minimum was in seconds, not minutes, and we really do want to
show at least to 90ft to make shallow dives look shallow rather than
scaled to some full depth.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
.. and repaint the profile when the selection changes.
Now, if it just wasn't so ugly, it might even be useful. Except it
obviously needs to also show all the other dive information. And allow
the user to fill in details. And save the end results.
So no, it's not useful.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>