summaryrefslogtreecommitdiffstats
path: root/profile-widget/diveeventitem.cpp
AgeCommit message (Collapse)Author
2021-01-10profile: pass dive to EventItemGravatar Berthold Stoeger
Don't access the global displayed_dive variable in an effort to make the profile reentrant. Note that this still accesses the global dc_number variable, which will likely have to be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25cleanup: split out divecomputer functions from dive.cGravatar Berthold Stoeger
Since dive.c is so huge, split out divecomputer-related functions into divecomputer.[c|h], sample.[c|h] and extradata.[c|h]. This does not give huge compile time improvements, since struct dive contains a struct divecomputer and therefore dive.h has to include divecomputer.h. However, it make things distinctly more clear. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-10-25cleanup: break out event-related code into event.[c|h]Gravatar Berthold Stoeger
In an effort to reduce the size of dive.h and dive.c, break out the event related functions. Moreover event-names were handled by the profile-code, collect that also in the new source files. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-05-01profile: properly update lastgasmix when populating eventsGravatar Berthold Stoeger
When populating the events of a profile, a pointer to the current gasmix was passed around to properly calculate isobaric_counterdiffusion. The DiveEventItem::setupToolTipString() function updated this gasmix when processing gas change events. I inadvertently broke the code when replacing gasmix-pointers by values. We could of course simply revert this part of the commit. However, the data flow was horrible anyway: for example is supposed that the setup functions were called in the correct order (i.e. DiveEventItem::setupToolTipString() is called after all other functions using the gasmix). Not exactly easy to follow. Therefore, keep passing around the gasmix as value to make it clear that the functions don't modify it. Keep the gasmix up-to-date at the caller's site in ProfileWidget2::plotDive(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-04-30cleanup: replace Q_ASSERT by qWarningGravatar Berthold Stoeger
These two Q_ASSERTs made no sense - their expression (a string literal) always evaluated to true. A qWarning() was intended here. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-12Profile: add speed parameter to Animation::* functionsGravatar Berthold Stoeger
For now always use the preferences value, so that this is a no-op. This is a preparation for storing the speed in the profile widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-07-12Profile: take int instead of bool in DiveEventItem::recalculatePosGravatar Berthold Stoeger
The goal here is to slowly make animation speed a variable of the profile widget, not of the global preferences. Currently the code does some trickeries with setting / unsetting the global animation speed. Start by not taking a bool "instant" but a speed in DiveEventItem::recalculatePos(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-03-29Show a bit of surface degassing in the plannerGravatar Robert C. Helling
to display the deco parameters at the surface, in particular tissue saturation and heat map. Suggeted-by: Matthias Heinrichs <info@heinrichsweikamp.com> Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-08-23Cleanup: pass gasmix by valueGravatar Berthold Stoeger
In a previous commit, the get_gasmix_* functions were changed to return by value. For consistency, also pass gasmix by value. Note that on common 64-bit platforms struct gasmix is the size of a pointer [2 * 32 bit vs. 64 bit] and therefore uses the same space on the stack. On 32-bit platforms, the stack use is probably doubled, but in return a dereference is avoided. Supporting arbitrary gas-mixes (H2, Ar, ...) will be such an invasive change that going back to pointers is probably the least of our worries. This commit is a step in const-ifying input parameters (passing by value is the ultimate way of signaling that the input parameter will not be changed [unless there are references to said parameter]). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-08-23Cleanup: return gasmix by valueGravatar Berthold Stoeger
Currently, get_gasmix_from_event() and get_gasmix() return pointers to either static or to (possibly changing) dive data. This seems like a dangerous practice and the returned data should be used immediately. Instead, return the gasmix by value. This is in preparation of const-ifying input parameters of a number of core functions, which will ultimately let the merge() function take const-arguments in preparation of undo of dive-merging. On common 64-bit systems gasmix (two "int"s) is the size of a pointer and can be returned in a register. On 32-bit systems a pointer to the struct to be filled out will be passed. Since get_gasmix() now returns a value, the first invocation is tested by a NULL-initialized "struct event *". Document this in a comment. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-18Change from gettextFromC::instance()->tr() to gettextFromC::tr();Gravatar Stefan Fuchs
Code cleanup. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18Use correct "tr" call for translating dive mode namesGravatar Stefan Fuchs
Correctly use gettextFromC::instance()->tr(); instead of a simple tr(); to translate the dive mode names. This goes on top of 0bc9edf855caf95e2d58ccaf704ceeda079e06f1 and finally makes the whole thing work. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Fix an error around translation of dive modes in the UIGravatar Stefan Fuchs
This fixes an mistake introduced in 3d1072f8862e4c329dc2678df52a24137b8d4704 Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17Remove a useless translation in diveeventitem.cppGravatar Stefan Fuchs
Giving the string ": %1" to translation makes no sense. And it's also not consistent with code a few lines below this line. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-05-28Distinguish between user and internal divemode namesGravatar Robert C. Helling
The former should be translated but not those that go to xml/git. ... and fix capitalization of pSCR. Suggested-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-05-21profile-widget: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-14Read and write divemode changes (xml and git)Gravatar Willem Ferguson
This provides for reading of divemode change events from dive logs and for writing them to dive logs. This applies to xml and git divelogs. Divemode change events have the following structure: event->name = "modechange" event->value = integer corresponding to enum dive_comp_type (dive.c), reflecting the type of divemode change (OC, CCR, PSCR, etc). In the dive log file, the event value is written as a string that corresponds to each of the enum values, e.g. <event name='modechange' divemode='OC' /> This xml is also read from the dive log file and translated to an appropriate value of event->value. The file diveeventitem.cpp was udated to reflect this new way of dealing with divemode change events. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Provide icons for bailout events on the dive profile.Gravatar Willem Ferguson
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-13Dive pictures: remove close-button optimizationGravatar Berthold Stoeger
One close-button object was used for all dive pictures. This seems like a brittle premature optimization and the pixmap is shared anyway. Make the button a subobject of the dive picture object. Change the object-hierarchy to be based on QGraphicsItem instead of QObject. The QObject here is only used as a kludge to support signals and properties (the latter are necessary for animations). Remove a comment, which does not seem to be relevant after this change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-14Cleanup: consistently use qPrintable()Gravatar Berthold Stoeger
Replace constructs of the kind s.toUtf8().data(), s.toUtf8().constData(), s.toLocal8Bit().data(), s.toLocal8Bit.constData() or qUtf8Printable(s) by qPrintable(s). This is concise, consistent and - in principle - more performant than the .data() versions. Sadly, owing to a suboptimal implementation, qPrintable(s) currently is a pessimization compared to s.toUtf8().data(). A fix is scheduled for new Qt versions: https://codereview.qt-project.org/#/c/221331/ Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-02Free various struct membuffer in different functionsGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-24Planner: print icd information at 0.1 resolutionGravatar Willem Ferguson
The gas fractions (in %) are now printed at a resolution of 0.1% and not at 0.01% as previously. The string in the info box that provides icd data is reformatted so that the info-box is as narrow as possible. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-01-21Profile info box ICD: Change format of ICD stringGravatar Stefan Fuchs
Change the format from (example!) ICD: ΔHe=-34% ΔN₂=3%<3% to ICD: ΔHe=-34% ΔN₂=+3%<+2.8% Change strings given to translation to less complex ones. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-01-21Only give ICD warning if pN2 increasesGravatar Robert C. Helling
as otherwise there are warning on the descent. The ICD line in the info box is generated for all gas switches with decreasing He content. Also change the presentation in the info box to align it with the notes. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-21Show ICD in gaschange iconsGravatar Robert C. Helling
Add an exclamation mark in the gas change icons if the change violates our isobaric counter diffusion criterium. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-21Show ICD events data in infoboxGravatar Robert C. Helling
If a gas switch violates our ICD criteria, show this in the info box. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2018-01-11Introduce helper function empty_string()Gravatar Berthold Stoeger
There are ca. 50 constructs of the kind same_string(s, "") to test for empty or null strings. Replace them by the new helper function empty_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-30Use better aliases for icons.Gravatar Martin Měřinský
Icon aliases were complete mess. Some icons had alias some didn't. Named with underscores vs. hyphens vs. camelCase. Lower vs. upper case. "ICON" prefix vs. suffix vs. nothing. With vs. without filename suffix. Some didn't make sence. Eg. mapwidget-marker-gray (I can see, it's grey, but what does it represent?) Some were duplicated, eg warning vs. warning-icon. Some were name after widget, which is wrong. Do not reinvent wheel. Use widely used naming scheme close to Freedesktop Icon Naming Specification. This will enable usage of common icons from current set in the future. Thus Subsurface will fit nicely to GUI. This changes icon aliases to one, easy grep-able style. Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29Revert "Use consistent aliases for all icons."Gravatar Dirk Hohndel
This reverts commit 92e9c6606f6ef3ad16d2e31f9f9a8f5fa14f2c1a.
2017-11-29Use consistent aliases for all icons.Gravatar Martin Měřinský
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase. With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs. prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some icons didn't have alias at all. This changes all icon aliases to one, easy grep-able style which complies to Freedesktop Icon Naming Specification (Guidelines). Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-13mobile: icon size in profileGravatar Jan Mulder
Size the event item icons in the profile a little bigger. Obviously, how big is big enhough is upto personal taste, but on Github a screendump is added to show the new size. Fixes: #310 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-19When selecting icons for events don't misinterpret a gaschangeGravatar Stefan Fuchs
Don't misinterpret a gaschange as "useless internal of the dive computer" when it has a higher flag value. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18Add a icon for gaschange to Oxy with all green tank shoulder colorGravatar Stefan Fuchs
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-04-29Add SPDX header to profile widgetsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-03-11We use 'setpoint' in UI. Use it also for documentation and comments. No ↵Gravatar Martin Měřinský
semantic change.
2017-02-21Add units and nicer formating for items in profile info boxGravatar Stefan Fuchs
"SP change" info format in info box: Added/changed formating and add "bar" unit. "waypoint above ceiling" event in info box: Added formating, depth conversation to ft/m and depth unit. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-02-21Translate names of additional dive events and nicer format info box textGravatar Stefan Fuchs
Enable translation for a few additional internal dive events. Ensure that all event names in datatrak.c are collected for translation. Ensure that for gaschange in profile info box the "cyl." string is also translated. Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2016-07-24Event name heuristics to show better event iconsGravatar Dirk Hohndel
This matches the strings for a couple of generic events from libdivecomputer that should obviously info or violation events, and matches quite a few more from the Uemis downloader (as those are much more specific). Everything else is still shown as a yellow warning triangle. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-24Avoid compile time warningGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-24Show different icons based on event severityGravatar Dirk Hohndel
So far this is only supported in the Suunto EON Steel backend, but we should try to add this to others where we have such a distinction (and maybe assign different values to the predefined libdivecomputer events). This also adds three new icons for info, warning, and violation. The warning icon we had already, but I drew a new one from scratch to have it match the violation icon. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23Event flags should be checked as bits, not valuesGravatar Linus Torvalds
This becomes obvious with the new severity bits introduced in the Suunto EON Steel parser. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-22Undefine both macrosGravatar Dirk Hohndel
There really is not need to do this, but at least do it symmetrically. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-01Don't show surface events at the beginning or end of the diveGravatar Linus Torvalds
That's just annoying and pointless. So we arbitrarily say that surface events within the first and last 30s of the dive are suppressed. But we now do show them in the middle, in case the sampling rate is too low, and the profile itself doesn't show that we got to the surface. These heuristics still needs tweaking - if the profile already shows that we're at the surface, then we should probably suppress the event triangle. But in the meantime this at least gets rid of the truly pointless cases. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Start using the actual cylinder data for gas switch eventsGravatar Linus Torvalds
Now that gas switch events always have indices into the cylinder table, start using that to look up the gas mix from the cylinders rather than from the gas switch event itself. In other words, the cylinder index is now the primary data for gas switch events. This means that now as you change the cylinder information, the gas switch events will automatically update to reflect those changes. Note that on loading data from the outside (either from a xml file, from a git/cloud account, or from a dive computer), we may or may not initially have an index for the gas change event. The external data may be from an older version of subsurface, or it may be from a libdivecomputer download that just doesn't give index data at all. In that case, we will do: - if there is no index, but there is explicit gas mix information, we will look up the index based on that gas mix, picking the cylinder that has the closest mix. - if there isn't even explicit gas mix data, so we only have the event value from libdivecomputer, we will turn that value into a gasmix, and use that to look up the cylinder index as above. - if no valid cylinder information is available at all, gas switch events will just be dropped. When saving the data, we now always save the cylinder index, and the gas mix associated with that cylinder (that gas mix will be ignored on load, since the index is the primary, but it makes the event much easier to read). It is worth noting we do not modify the libdivecomputer value, even if the gasmix has changed, so that remains as a record of the original download. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-28QML UI: take device pixel ratio into account when scaling pixmaps on iOSGravatar Dirk Hohndel
This way warning icons and tank change icons and other event markers are no longer ridiculously tiny on retina screens. Oddly this doesn't appear to be needed on Android, only on iOS. Fixes #1033 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08Silence warnings in DiveEventItemGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-05profile-widget: use smaller event icons on Subsurface-mobileGravatar Rick Walsh
Smaller event icons fit the mobile display much nicer Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-03Prevent gaschange tank icons from using garbage coords.Gravatar K. \"pestophagous\" Heller
Tank icons were shown at incorrect spots on the profile when the DiveEventItem object held a pointer to a struct event even after the struct event at that address had been freed. When internalEvent is a pointer to freed memory, internalEvent->time.seconds could have all kinds of crazy values, which get used in member function DiveEventItem::recalculatePos to place the tank at bad x coordinates. The DiveEventItem(s) no longer store a pointer to memory that they do not own. This way, no matter how the path of execution arrives into slot recalculatePos, we never need fear that the DiveEventItem will dereference a garbage pointer to a struct event. Fixes #968 Signed-off-by: K. Heller <pestophagous@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>