Thus, we can keep the scale factor constant during existence
of the view. For now, this is simpler than adapting existing
text elements. We might want to make this more flexible later.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The current way of handling the "print scale factor" is
complex: The text fields are added and later resized via
signals. Things could be simplified by just redoing the
chart when changing the scale factor.
Moreover, in the future we will want to adapt the size of the
axes depending on the size of the texts.
As a first step, factor out the creation of the profile-widget.
This can then be used to recreate the profile when changing
the scale factor.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The alternative spelling "visibile" made searching for this
function very annoying. That makes removing it even more
satisfying.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Very annoyingly, to render the profile for printing / export,
the profile still had to be show()n, thus requiring a parent
window.
Analysis of qmlprofile.c showed that this was due to the
transformation matrix not being properly set up on non-show()n
scenes.
Instead, we can simply render via the QGraphicsScene
(circumventing the QGraphicsView).
The code was factored out into the ProfileWidget2::draw()
function. This will hopefully make it easier to change
the size-code of the profile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Create a new class that encapsulates the profile-widget UI.
This is called ProfileWidget, which might be confusing since
the actual display is called ProfileWidget2. However, the
plan is to rename the latter to ProfileView. After all, it
is also used to print and to show the profile on mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The MainWindow::configureToolBar() function is called every
time plotCurrentDive() is called. Moreover, this is the only
time that it is called. We might just fold the former into
the latter.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Just as for printing, use an independent profile widget, so
that the UI widget doesn't have to be set/reset.
Also, make the size of the exported image independent from
the current window size.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When multiple profiles were exported, for every exported image
the profile-widget was switched to/from print mode.
Move this out of the loop, i.e. initialize and reset the profile
only once. This should slightly speed up export, but not by a lot,
since most of the time is spent by compressing the PNGs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The exportProfile function uses the UI and therefore was
supposed to be declared in backend-shared/* but defined
separately for desktop and mobile. Currently, only the
desktop version exists.
The goal however should be that there is no need of the
UI for this function. In a first step, move the function
to the common backend-shared/* code and conditionally
compile for desktop. In upcoming commits, the function
will be made independent of the UI.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In analogy to normal printing, don't misuse the mainwindow's
profile widget to do the printing.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When printing the dives were rendered into the visible profile.
This meant setting a number of flags and reverting after printing.
That's obviously quite brittle.
Instead, use a separate profile instance, since we can have
different profiles showing different dives now.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This was just a stub to make the setVisible() function a "slot".
Since there are no more signals using it, remove it.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The visibility of the gas lines is updated on every profile-redraw,
which is performed when the preferences changes. No need to have
these signals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The visibility is set on every redraw, which is called when
the preferences change. No need for these signals.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This one is rich: when changing to profile-mode, the calculated
tissues are set according to the prefs.calcalltissues flag.
The DiveCalculatedTissue::setVisible() function ignores the
parameter and insteads sets the visibility according to the
expression "prefs.calcalltissues && prefs.calcceiling".
This is because the function is also called by signals,
which provide the wrong parameter.
Pass the correct parameter in the first place. Remove the
crazy signals and the overridden setVisible() function,
which ignores its parameter, later.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Currently, setting the visibility of chart features is a mess. It
is done when switching to the profile state and then via signals,
when the preferences are changed.
However, when the preferences are changed the chart is replot anyway.
So let us simply set the visibility on chart replot. Then in
a follow-up commit, the signals can be removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The plan is to simplify the visibility-control of non-interactive
chart features. As a first step identify those features that
depend on preferences-flags and factor out the setting of their
visibility into a new function updateVisibility().
This commit effectively only reorders the setting of the
visibility and therefore should have not user-visible effect.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We have a dive-site variable, therefore we probably should also
have a dive-trip variable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
To enable grouping by trip in the statistics module, split
the get_trip_title() function in a version that appends
a "(n dive(s)" string an one that doesn't. The statistics
module doesn't want that added string, since it displays
the number of dives in a different way.
Also, move the functions to string-format.h, where these
are collected. And rename them to camelCase. Yes, it's
ugly, but consistent with most other C++ code in the code
base.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
'constexpr' implies 'const' since it is a stronger guarantee,
so let's remove the redundant 'const'.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Let the compiler figure out the correct type...
Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When adding a cylinder, it was added at the end of the list.
This would make hidden cylinders visible as the new rule is
to only hide unused cylinders at the end of the list.
Therefore, add the cylinder after the last used cylinder,
i.e. before the first hidden cylinder.
This means that the position where the cylinder is added has
to be hidden in the undo command.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
On the equipment tab, unused cylinders (automatically added,
no pressure data) could be hidden. This was implemented using
a QSortFilterProxyModel.
Apparently, it causes confusion if cylinders in the middle of
the list are hidden. Therefore, only hide cylinders at the end
of the list.
QSortFilterProxyModel seems the wrong tool for that job, so
remove it and add a flag "hideUnused" to the base model. Calculate
the number of cylinders when changing the dive.
This is rather complex, because the same model is used for
the planner (which doesn't hide cylinders) and the equipment
tab (which does). Of course, syncing core and model now becomes
harder. For instance, the caching of the number of rows was removed
in a37939889b and now has to be
readded.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is a warning when the code tries to access a non-existing
cylinder, since that indicates that something went out of sync.
However, this warning can never trigger because the bounds are
checked before. Remove the first of the two redundant checks.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In cb80ff746b internal columns
were added to the cylinder model. These were not hidden in
the planner. Nobody complained?
Remove this clutter from the UI by hiding the columns.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The logic did not consider the WORKINGPRESS_INT and SIZE_INT
columns added in cb80ff746b.
By some unknown magic this worked by routing everything
through the CylindersModelFiltered model.
Let's fix it and explicitly ignore these columns. Put
the test whether a column should be ignored in a function
to avoid inconsistencies should new columns be added.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The D in MOD, EAD, END, and EADD stands for "depth" and
as such these should be mm in int rather than double.
The intermediate fn2 and fhe2, however, as intermediate
value should not be rounded to an integer.
The upshot of this is a litle more numerical stability.
It should lead to more stable values in TestProfile
when run on architectures with different floating
point precision.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
The undo commands for depth and duration editing cleared
the samples of the dive computer. They relied on the profile
automatically creating a fake profile. However, at some point
that code got removed. Therefore, do it explicitly in the undo
command.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
CCRs are different. It does not make sense to compute
a depth dependent SAC. You could compute the rate of O2
consumption but even that is likely wrong (as O2 in the
diluent would enter that as well), so simply don't attempt
it.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
And while doing that, have all the cases where we already include
qthelper.h simply use a define in that header file - but keep the two
other instances of the define where the C++ source don't need qthelper.h
otherwise.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As of November 20201 the Google Play store now requires that new apps
target API level 30. The minimum API level remains 21 so we should
continue to support devices all the way back to Android 5.0 (Lollipop).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Very similar structure to the XML format. Raw data is again saved as a
hex string (which implicitly provides us with its length). The rest of
components are in a more human readable format.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We always use the global fingerprint table - maybe this should just not
be a parameter of the accessor functions?
The syntax is very simple - the raw data is encoded as a hex string, the
rest of the components are hex numbers.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to not break existing behavior, we still store fingerprints on disk, but
we first check the data in the in-memory table, and we remember the fingerprint data
in the fingerprint table as well (which is then saved as part of the dive log data).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This just adds the basic structures and the accessor functions needed to
manage a table of fingerprint data. The table is indexed by the hash of
the model name and binary serial number as created by libdivcecomputer.
This way the data is accessible when libdivecomputer fist accesses a
dive computer (which is the point in time when we need to use the
fingerprint.
The table also contains the corresponding device id and dive id so we
can verify that the current dive table still contains that dive.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>