summaryrefslogtreecommitdiffstats
path: root/profile.c
AgeCommit message (Collapse)Author
2014-02-10Fix plot_info calculate_max_limits_new() function return valueGravatar Boris Barbulovski
The return value(structure) was not fully initialized, thus random data returned for uninitialized members possibly causing random bahavior. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10Use 'struct membuffer' for profile info string generationGravatar Linus Torvalds
The profile info was generated using nasty string concatenation that the membuffers are much better at anyway. And membuffers don't need those arbitrarily sized fixed buffers (500 bytes? Why 500 bytes?). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10Add support for heartrate and bearing information in samplesGravatar Linus Torvalds
libdivecomputer already supports this, but we didn't save it. Tested-by: Oscar Isoz <jan.oscar.isoz@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-06Adapt the ToolTip to work on the new profileGravatar Tomaz Canabrava
With this patch the tooltip is ready to work on the new profile, we just need to actually use it. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-05Created a method to check if calculations should take place.Gravatar Tomaz Canabrava
Created a method to check if calculations should take place taking into consideration what changed on the model. if the model changes *everything*, them, all calculations should be done, but if just some of the columns of the model are changed, only those columns should trigger an visual update on the items. In theory this patch looks right, but something is wrong ( calculations are not being made. ), so I'll commit this any how, and fix on the next commit. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-29Always calculate deco data, independent of preferencesGravatar Tomaz Canabrava
This is a better way since we can enable / disable the deco by changing the preferences later, and that will not need to recalculate everything just because a polygon was set to invisible. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27Add settings awareness for the PP graphGravatar Tomaz Canabrava
This commit is rather big, and I forgot to cut it in pieces. The first part creates a new 'calculate_gas_information' that will not fill the profile_info->maxpp member ( that should be removed from it as soon as the new dialog is finished ). The reason for that is that all of the profile data will be calculated and the graph needs to update dynamically, so whenever the settings changes, I ask for the model which is the biggest graph and replot only the ones we need. The second part adds a new animation function 'animdelete' to fade-out and delete the item when it's done. the old function 'hide' did just that but a hide shouldn't delete anything. The third part is preferenes awareness for the PP graphs. I created two new functions that receive the settings key for visibility and use the QSettings to show / hide them. This also works quite well for the axis; if no graph is visible, the axis will also hide itself. The fourth part is colors. The pp graphs now have the correct colors. And a bit of code cleanup too. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-17Create a version of create_graph_info that doesn't depend on GC.Gravatar Tomaz Canabrava
This version of the create plot info is the same as before, with the difference that it doesn't depends on the gc. Also fixed a crash. The Pressure Index, Information and interpolated seems wrong, I'm getting only zeroes. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Whitespace and coding style updatesGravatar Dirk Hohndel
Another futile attempt to cleanup the code and make coding style and whitespace consistent. I tried to add a file that describes the key points of our coding style. I have no illusions that this will help the least bit... This commit should ONLY change whitespace Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Reworked the calculate_max_limits and plotted the dive.Gravatar Tomaz Canabrava
Created a new version of calculate_max_limits that doesn't have a graphics_context and returns a plot_info. The code is basically the same as the old calculate_max_limits, so there's not much to talk about. The rest of the code is just boilerplate to plug the Profile code with the axis and model stuff, to be plotted on screen. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Added a Model that should handle the Dive ProfileGravatar Tomaz Canabrava
This model encapsulates the plot_info struct and provides a consistent way to show it using the Qt Model view system in the C++ and QML way. For a QGraphicsItem that should show a Profile, this is the start. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Convert the C code to using stdbool and true/falseGravatar Anton Lundin
Earlier we converted the C++ code to using true/false, and this converts the C code to using the same style. We already depended on stdbool.h in subsurfacestartup.[ch], and we build with -std=gnu99 so nobody could build subsurface without a c99 compiler. [Dirk Hohndel: small change suggested by Thiago Macieira: don't include stdbool.h for C++] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-09Interpolated pressure should always be setGravatar Rodrigo Severo
Interpolated pressure should always be set, even it we didn't calculate a new one. In this case we should just use the last one. Signed-off-by:Rodrigo Severo <rodrigo@fabricadeideias.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08When interpolating tank pressures, don't devide by zeroGravatar Dirk Hohndel
When an interpolated segment is on the surface we get no pressure time - and try to divide by zero. (plus a small whitespace issue that slipped throught the cracks earlier) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08Reinstating SURFACE_THRESHOLD test in pressure_time functionGravatar Rodrigo Severo
The small straight parts at the end of tank pressure lines are more of a aesthetic issue, not causing real harm so it is no reason to remove the SURFACE_THRESHOLD test from pressure_time function only because of this. Also improved interpolate data debuging, rearranged get_pr_interpolate_data and removed an unused variable from get_pr_interpolate_data. No real change here, just trying to make the code clearer. [Dirk Hohndel: clean up whitespace damage from this and the previous commit] Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08Discontinuity and stall on tank pressure interpolated linesGravatar Rodrigo Severo
Interpolated lines for tank pressures were presenting discontinuities (sudden drops) and stalls (horizontal lines) with certain dive profiles. The main reason seems to be that the discrete interpolation of tank pressure was adding small pressure increments that could be rounded down or up repeatedly generating cumulative rounding errors that would mean either a delay on pressure drop that would be drawn as a sudden drop or as a premature pressure drop that would result in a flat line. This patch changes the way the discrete interpolation is done, so that we don't have cumulative rounding errors distorting tank pressure lines. To calculate accumulated pressure_time values the get_pr_interpolate_data function was created. The fact that get_pr_interpolate_data transverses the beginning of the plot_info entry list for each entry that needs interpolated tank pressure isn't optimal at all. There might be a way to properly track the data necessary to interpolate tank pressures from inside the main pi->entry loop in fill_missing_tank_pressures. Unfortunately I didn't manage to do it inside fill_missing_tank_pressures so we have get_pr_interpolate_data. The SURFACE_THRESHOLD test from pressure_time function was also removed as no matter how shallow the diver is, if he is using the cylinder to breathe the cylinders tank pressure should be affected. Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-01Typos on commentsGravatar Rodrigo Severo
Fixing 2 typos on comments. Signed-off-by: Rodrigo Severo <rodrigo@fabricadeideias.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20Add preprocessor directives around debug functionsGravatar Anton Lundin
These adds some ifdef's around some debug functions to disable them when not using them. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11Remove some dead codeGravatar Anton Lundin
last_pressure is updated a couple of lines later, so no need to do it here. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11Plug memory leaks in compare_samplesGravatar Anton Lundin
Free temporary buffer before returning. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-03Disable calc_ndl_tts for printGravatar Anton Lundin
NDL and TTS doesn't show up in the printed profiles, and it takes significant time to calculate, so just don't do it. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30Ruler: display maximum descent and ascent speedGravatar Alexandre Belloni
While playing with the ruler, I figured that it happened only once that my minimum speed was not 0 for a segment long enough to get any display. And it was a "dive" in an hyperbaric chamber... This patch replaces the minimum speed with the maximum descent speed and the maximum speed with the maximum ascent speed. Signed-off-by: Alexandre Belloni <alexandre.belloni@piout.net> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30compare_samples: Remove unnecessary space before unitsGravatar Alexandre Belloni
Signed-off-by: Alexandre Belloni <alexandre.belloni@piout.net> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-20Don't interpolate gas consumption when at surfaceGravatar Anton Lundin
Don't calculate pressure-track for depth above SURFACE_THRESHOLD, because then we would guess that were actually at surface breathing. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-20Use get_cylinder_index in per_cylinder_mean_depthGravatar Anton Lundin
Use get_cylinder_index that handles SAMPLE_EVENT_GASCHANGE and SAMPLE_EVENT_GASCHANGE2. This also removes the need for a special case where get_gasidx returns -1, because get_cylinder_index always returns the "closest" gas that it finds. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-15Make the info box look as it did in 3.1Gravatar Anton Lundin
In the Gtk version there were no option to disable the showing of time in the mouse over, so this removes that option to limit the amount of clutter in the settings panel. This also renames the time and temperature to match the names they used to have. T -> @, Temp -> T Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14Remove duplicated SAC data from information overlayGravatar Anton Lundin
When reordering the info overlay content to make it jump around less, somehow the SAC data got printed twice. [Dirk Hohndel: rewrote incorrect commit message] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14Break calculated deco info to separate varsGravatar Anton Lundin
Store the calculated values in separate variables in the plot_data struct, and display them separate. This makes sure we don't confuse the calculated values with the ones from a dc, and now we can compare the two. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13Break up calculate_deco_informationGravatar Anton Lundin
Break the huge calculate_deco_information into three different functions. One for the current deco calculations, one for the ndl/tts/deco stop and one for the gas calculations. This makes it easier to disable/enable different functionality. This also gets rid if the ccrdive state variable, and keeps that state in the plot_data struct. Now we calculate the deco before we calculate the gas properties, so if we have a po2, we're in ccr-mode, and if we don't, we're in oc mode. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13Reorder info in information windowGravatar Anton Lundin
When moving along the plot, it's hard to look at a certain value when its place in the info box moves due to values being added or removed above it. This commit moves the "stable" values up top in the info box and the values that come and go further down, so that the box expands downwards. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13Remove the special handling of ndl < 3mGravatar Anton Lundin
This changes the special handling of ndl calculations when we deem that we are too shallow for doing them. Previously we just set ndl to -1 and printed a "-", now we return and print max_ndl, just as how most divecomputers work. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13Introduce an on/off switch for calculating ndl/ttsGravatar Anton Lundin
Let the user choose if the calculation of ndl and tts is worth the time it takes. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13Fill up plot_data with temperature all the wayGravatar Anton Lundin
This will fill out the gaps of temperature data between all the points so we always have a temperature to show in the info box. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-20Use configured vertical speed units in rulerGravatar Anton Lundin
Ruler was hard-coded to use seconds as speed unit. This makes it use get_vertical_speed_units to switch between seconds and minutes. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17Show SAC in the mouseover.Gravatar Anton Lundin
This is really nice to have when looking at specific parts of a dive. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17Move sac-calculation to profile.cGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17Rename T: to Temp: in Information boxGravatar Anton Lundin
D as in depth, T as in time and not another T as in temp. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-14Only calculate decompression if the user turned the preference onGravatar Dirk Hohndel
There's no point in wasting the cycles otherwise. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11Remove some arguments, that we find in plot_dataGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09Next step towards working translationsGravatar Dirk Hohndel
This may seem like a really odd change - but with this change the Qt tools can correctly parse the C files (and qt-gui.cpp) and get the context for the translatable strings right. It's not super-pretty (I'll admit that _("string literal") is much easier on the eye than translate("gettextFromC", "string literal") ) but I think this will be the price of success. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-09Disable unused functionGravatar Dirk Hohndel
I am not removing this but leaving it around as this is useful for a feature that we still need to enable - the ability to filter out which events to display. This existed in 3.1 but is missing in the Qt version. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-07Remove even more code and declarationsGravatar Dirk Hohndel
There's lots more stuff that can go. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Make Windows cross compile againGravatar Dirk Hohndel
But this is broken as the utf8/utf16 conversions in windows.c are gone without glib. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Remove lots of ifdef'ed out code from GTK/glib versionGravatar Dirk Hohndel
There's still a ton more left, but this is a start. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06Trying to switch to Qt translationGravatar Dirk Hohndel
This compiles and looks about right, but it doesn't appear to work, yet. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06First steps towards removing glib dependenciesGravatar Dirk Hohndel
- remove the build flags and libraries from the Makefile / Configure.mk - remove the glib types (gboolean, gchar, gint64, gint) - comment out / hack around gettext - replace the glib file helper functions - replace g_ascii_strtod - replace g_build_filename - use environment variables instead of g_get_home_dir() & g_get_user_name() - comment out GPS string parsing (uses glib utf8 macros) This needs massive cleanup, but it's a snapshot of what I have right now, in case people want to look at it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-04Added configuration options for vertical speed units.Gravatar Patrick Valsecchi
Some people (free divers) are loving ft/s or m/s units for vertical speeds. Now they can choose between /min or /s in the configuration (only Qt UI). Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03Fix unitialized variable useGravatar Patrick Valsecchi
I ran subsurface with valgrind and it found a few errors. [Dirk Hohndel: split this out from a much bigger patch that is still under review] Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-01Ascending/descending speeds are usually expressed in x/minGravatar Patrick Valsecchi
There is debate on this one, as free divers WANT the xx/sec values. This needs to become flexible depending on whether you are in freedive mode or not. Fixes #202 Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-27Added a ruler which can be dragged along the profileGravatar Maximilian Güntner
This patch adds a ruler QGraphicsItem which can be dragged along the profile. The ruler displays minimum, maximum and average for depth and speed (ascent/descent rate). Also, all used gas will be displayed. This also adds a new attribute to struct plot_data to store the speed (not just as velocity_t). Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>