Commit graph

59 commits

Author SHA1 Message Date
Berthold Stoeger
f713858ba4 profile: rename printFontScale to dpr (device pixel ratio)
The printFontScale is used to scale up fonts (and icons) when
rendering to high-DPI devices. With absolute scaling, this
will also be used to scale the size of different chart
regions, line thickness, etc. Therefore, give it an more
appropriate name. "Device pixel ratio", which is a well
established term, seems to appropriately describe the
concept.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-12-17 11:54:23 -08:00
Berthold Stoeger
69914964f6 cleanup: replace membuffer by qasprintf_loc()
There is a function to format QString with C-format strings. Let's
use it instead of doing a detour via membuffer.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-23 11:22:43 -07:00
Dirk Hohndel
235ee4803f printing: remote incorrect scaling of event icons
It appears that this well intended change in commit 52aa7d83b6 ("Increase event
icon size in print mode") actually causes the scaling of the event icons to be
generally wrong. This removes the hard 4* scaling and also adds some debugging
output in verbose mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-11 13:02:43 -07:00
Berthold Stoeger
65580fceda profile: scale dive event items according to font print scale
When printing with low DPI, the dive event items become comically
large, because they are not resized like the fonts. Therefore,
scale using the fontPrintScale.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-07-04 11:51:17 -07:00
Berthold Stoeger
0b190243dd profile: remove internal event-copy (fix deleting/renaming events)
The DiveEventItem had an internal copy of the event. It passed
that copy to the undo-machinery, which of course didn't work.

Simply keep a pointer to the event. All changes to a dive no
pass via the undo-machinery, which causes a reload of the profile,
so this should be safe.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Berthold Stoeger
fd2862042b profile: pass axes and model to DiveEventItem on construction
Firstly, there is no point in supporting DiveEventItems without
model and axis. Secondly, this avoid pointless position-
recalculations.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Berthold Stoeger
c93fb83edf profile: pass event at construction time to DiveEventItem
There is no point in having a dive event without an event.
Let's pass the event at construction time to avoid having
to handle "invalid" events.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-06-05 11:29:00 -07:00
Berthold Stoeger
3fcac9022c profile: initialize DiveEventItem::dive to null
To simplify debugging, this should be initialized. Found by coverity.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2021-03-05 08:30:23 +01:00
Berthold Stoeger
be9f9efb0e profile: pass dive to EventItem
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>
2021-01-10 15:57:39 -08:00
Berthold Stoeger
0e196310f9 cleanup: split out divecomputer functions from dive.c
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-25 13:59:52 -07:00
Berthold Stoeger
8212acc992 cleanup: break out event-related code into event.[c|h]
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-10-25 13:59:52 -07:00
Berthold Stoeger
f4b948e80d profile: properly update lastgasmix when populating events
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-05-01 21:44:50 +02:00
Berthold Stoeger
0c28821d28 cleanup: replace Q_ASSERT by qWarning
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>
2020-04-30 16:55:19 -07:00
Berthold Stoeger
2d9dc40171 Profile: add speed parameter to Animation::* functions
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-12 09:59:28 +02:00
Berthold Stoeger
74244b3cfe Profile: take int instead of bool in DiveEventItem::recalculatePos
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-07-12 09:59:28 +02:00
Robert C. Helling
5e494ce761 Show a bit of surface degassing in the planner
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>
2019-03-29 06:51:12 -07:00
Berthold Stoeger
360f07e453 Cleanup: pass gasmix by value
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-23 05:16:38 -07:00
Berthold Stoeger
f5b11daffd Cleanup: return gasmix by value
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-08-23 05:16:38 -07:00
Stefan Fuchs
c953aadcf8 Change from gettextFromC::instance()->tr() to gettextFromC::tr();
Code cleanup.

Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18 07:42:39 +02:00
Stefan Fuchs
88e6ba2f61 Use correct "tr" call for translating dive mode names
Correctly use gettextFromC::instance()->tr(); instead of a simple
tr(); to translate the dive mode names.
This goes on top of 0bc9edf855
and finally makes the whole thing work.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-18 07:42:39 +02:00
Stefan Fuchs
0bc9edf855 Fix an error around translation of dive modes in the UI
This fixes an mistake introduced in
3d1072f886

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-06-17 06:36:20 +09:00
Stefan Fuchs
632e6bb7c7 Remove a useless translation in diveeventitem.cpp
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-06-17 06:36:20 +09:00
Robert C. Helling
7c6e5ed5db Distinguish between user and internal divemode names
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-28 09:57:00 +02:00
jan Iversen
065af62f59 profile-widget: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -07:00
Willem Ferguson
b9174332d5 Read and write divemode changes (xml and git)
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-14 23:47:00 +03:00
Willem Ferguson
5f95c226ef Provide icons for bailout events on the dive profile.
Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
2018-05-14 23:47:00 +03:00
Dirk Hohndel
d577467f97 Core: introduce new subsurface-string header
First small step to shrinking dive.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Berthold Stoeger
630862971f Dive pictures: remove close-button optimization
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-05-13 13:52:35 -07:00
Berthold Stoeger
b72cc1f317 Cleanup: consistently use qPrintable()
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-03-14 13:55:36 +02:00
Stefan Fuchs
b5ce06c8b9 Free various struct membuffer in different functions
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-02-02 11:29:55 -08:00
Willem Ferguson
b9ac89574e Planner: print icd information at 0.1 resolution
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-24 22:03:42 +01:00
Stefan Fuchs
d5cb30efac Profile info box ICD: Change format of ICD string
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-21 18:01:56 +01:00
Robert C. Helling
c89cfcccbe Only give ICD warning if pN2 increases
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-21 15:24:46 +01:00
Robert C. Helling
d029feb2d5 Show ICD in gaschange icons
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-21 15:24:46 +01:00
Robert C. Helling
7b508e41cd Show ICD events data in infobox
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-21 15:24:46 +01:00
Berthold Stoeger
e85ecdd925 Introduce helper function empty_string()
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>
2018-01-11 06:07:13 +01:00
Martin Měřinský
8ef87e618a Use better aliases for icons.
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-30 23:14:46 -08:00
Dirk Hohndel
2747056889 Revert "Use consistent aliases for all icons."
This reverts commit 92e9c6606f.
2017-11-29 14:05:07 -08:00
Martin Měřinský
92e9c6606f Use consistent aliases for all icons.
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-29 11:46:35 +01:00
Jan Mulder
0d023068b3 mobile: icon size in profile
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-11-13 20:46:00 -08:00
Stefan Fuchs
c3274b0b9f When selecting icons for events don't misinterpret a gaschange
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-19 19:00:55 -04:00
Stefan Fuchs
fcc4be6ea0 Add a icon for gaschange to Oxy with all green tank shoulder color
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-18 06:47:44 -04:00
Dirk Hohndel
49d0bb8406 Add SPDX header to profile widgets
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Martin Měřinský
95d5771513 We use 'setpoint' in UI. Use it also for documentation and comments. No semantic change. 2017-03-11 08:09:07 -08:00
Stefan Fuchs
508387b1e1 Add units and nicer formating for items in profile info box
"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-21 13:11:19 -08:00
Stefan Fuchs
b39b641a05 Translate names of additional dive events and nicer format info box text
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>
2017-02-21 13:11:19 -08:00
Dirk Hohndel
8c2668a6b1 Event name heuristics to show better event icons
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-24 09:53:24 +09:00
Dirk Hohndel
70e1938aa7 Avoid compile time warning
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-24 09:53:24 +09:00
Dirk Hohndel
c1f9cfe9a8 Show different icons based on event severity
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-24 09:53:24 +09:00
Linus Torvalds
f718fdab80 Event flags should be checked as bits, not values
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-23 16:01:26 +09:00