Render a warning sign in front of the event string
in the infobox. This is done in rich text.
Note: This shows the warning sign for all events,
not just warnings.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
When zoomed in, the profile position was moved by hovering with
the mouse. What a horrible user experience. This is especially
useless if we want to implement an interactive profile on mobile.
Instead, let the user start the panning with a mouse click. The
code is somewhat nasty, because the position is given as a
real in the [0,1] range, which represents all possible positions
from completely to the left to completely to the right.
This commit also removes the restriction that the planner handles
can only be moved when fully zoomed out. It is not completely
clear what the implications are. Let's see.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
No reason to keep this as a macro - a function is easier to
read, type safe and easier to debug. Moreover, give it the
more appropriate name "nearly_equal()". After all, it precisely
does NOT check floating points for equality.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This allows having 3m depth grid for metric users.
* All original properties ( named diferently ) were renamed to three_m_based_grid everywhere to be consistent.
* Plus other small changes requested during review.
Signed-off-by: Vlad A. <elf128@gmail.com>
Signed-off-by: Vlad A <elf128@gmail.com>
dc_number is a global variable indicating the currently displayed
dive on desktop. It makes no sense on mobile, since multiple
profiles can be active at the same time. Therefore, the profile
code should not access this global, but use the dc number that
is passed in.
This removes the last access.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Now this one was strange:
The ruler items keep a copy of the plot_info struct. However,
only a shallow copy is made (the actual plot data is not copied).
This means that the data is only valid as long as the source
plot_info is valid. But if that is guaranteed, we simply can
keep a pointer instead of the full object.
I wonder if it wouldn't be better still to keep a pointer to
the profile and query that for the plot info?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The only things in display.h were profile related, so the
split between these two files is not comprehensible.
In fact profile.h includes display.h, because it needs the
struct defined therein. Let's just merge these two files.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The profile knows which divecomputer it is plotting. No point
in accessing a global variable (which isn't even defined on
mobile).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
With all the recent changes, some of the previous assumptions about the scale
of items seem to be no longer appropriate. Now that we are showing the icons in
the profile again on device it's quite obvious that they were way too big -
clearly we don't need the special scaling anymore.
Also implement a suggestion from Berthold to get slightly smaller fonts and
finer structures in the profile on mobile devices. This scaling of the DPR
seems to work well in my tests.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a column to the equipment table that shows if a sensor is attached to a
tank, or which sensors would be available to attach to a tank that currently
doesn't have a pressure sensor associated with it.
Changing the sensor assignement can be undone.
This column is hidden by default as this is a somewhat unusual activity.
Signed-off-by: Michael Andreen <michael@andreen.dev>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
From a user's perspective, the edit mode is not a different
application mode anymore. Therefore, don't change the background
of the profile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In ProfileScene::draw(), the divecomputer was calculated
thrice. Remove the two redundant calls.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The edit mode was hidden in a context-menu. With fine-grained
undo there seems to be no need to explicitly exit edit mode.
Therefore, always switch to edit mode when displaying a
manually added dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Place undo commands for every change of the profile, not
only on "saving". Move the edit-mode from the mainwindow
and the maintab to the profile widget.
This is still very rough. For example, the only way to exit
the edit mode is changing the current dive.
The undo-commands are placed by the desktop-profile widget.
We might think about moving that down to the profile-view so
that this will be useable on mobile.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
We do want the -Wfloat-conversion warnings where they point out
potential bugs. But they are very distracting when they are triggered by
floating point literals (which the standard defines as double) passed to
a function expecting float arguments.
The fact that Qt6 changes the arguments to all these functions from
double to float is... hard to explain, but it is what it is. With these
changes, for the majority of cases we create inlined helpers that
conditionally compile to do the right thing. And in a handful of other
cases we simply cast to float (and accept that on Qt5 this then gets
cast back to double... for none of these cases the potential loss in
precision makes any difference, anyway - which likely is why the Qt
community made the decision to change the type of the arguments in the
first place).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For reasons I don't understand, the device pixel ratio was taken into account
twice. And as a result the transformation applied to the profile made us show
only the top left part of it - but enlarged (depending on the DPR).
This code fixes that problem by simply forcing the transformation used by the
painter to be the identity matrix. I worry that this could be wrong in some
situations, but for now it seems to fix the problem.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When in the planner, ESC should cancel the plan.
However, when the user manipulates the dive-handles in the
profile and presses ESC, first nothing happens, then an obscure
message appears.
The reason is that ESC "shortcuts" are introduced in two places.
To fix this, remove the ESC shortcut in the profile (the planner
widget cancels the plan anyway) and replace all the shortcuts in
the profile with a simple override of the keyPressEvent().
The latter is not strictly necessary, but hopefully avoids further
complications with multiple shortcuts. And the code is easier
to follow too.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The signature of draw() was changed to include "keepPlotData"
as an optimization.
The caller in draw() was not changed and now the plot data
is not recalculated, which means no plot data at all in
prints and exports.
The various boolean parameters should be replaced by flags.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The logic has just been completely broken when implementing
zooming.
Fixes#3376
Reported-by: Anton Lundin glance@acc.umu.se
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Pure bike-shedding:
The DiveTextItems of the DiveProfileItems were stored as raw
pointers. Instead, store them as unique_ptrs, so that they
don't have to be explicitly deleted.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The temperature graph connected directly to whatever was below.
Thus, the lowest temperature often was not clearly seen.
Add a general "bottom border" space to the main chart features
and set it to two pixels for the temperature and zero pixels
for the rest. Might need some fine-tuning.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The timestamp labels may change their format on zoom from
"mm" to "mm:ss", depending on the zoom level. Since the
animation kept old labels, this meant that one can end up
with a mix of labels.
Therefore, always reformat the labels. Of course, this
means that the labels switch instantaneously from one format
to the other. This is in conflict with the whole idea of
"smooth" animation. Such a smooth animation could be realized
by adding a "format" flag to the Label structure and keeping
thus fading in/out labels if the format changes. Do we want
that?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This prevented calculation of the pressure data when dragging
planner handles. However, this lead to weird artifacts.
As an alternative, if this turns out to be too slow, we might
disable the plotting of the pressure curves instead.
That said, even on my super-slow fanless laptop, this performs
reasonably.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In planner and edit mode, the cursor position is indicated using
crosshairs. They broke when changing to absolute scaling.
To fix them, remember the plot-area in the profile scene and
draw the crosshairs only inside this area (not on top of axes).
However, limit the position of the horizontal line to the
actual profile (dont paint inside the partial pressure, etc
graphs). The vertical line is painted above those graphs, so
that a timestamp can be related to partial pressure, tissue
loading, etc.
Also, set the z-value of the crosshairs. It was painted
inconsistently above some and below other chart features.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The axes are implemented by a line, which determines the
position. For axes without labels/grids this looks ominous.
For now, make the line invisible. But really, this should
be changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old profile code didn't show the 0m label, because that
was cut off. This was lost when redoing the axis code.
Reimplement this. The code is very ugly: it recognizes the
depth axis by the fact that is the only "inverted" axis.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This is a shouldn't happen situation, because we always
fake a profile. Let's handle it gracefully anyway.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When hovering over the chart after the chart was cleared,
there were artifacts owing to the stale profile data.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
All data access is now directly via the plot_info structure
owned by the ProfileScene itself.
Also removes DivePercentageItem::hColumn, which was an
artifact from the DivePlotDataModel.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There were two plot_infos of the same dive: one owned by
ProfileScene and one owned by DivePlotDataModel. The latter
was (or at least should have been) a copy of the former.
Simply always access the plot-info which is owned by
ProfileScene anyway. That seems much less brittle. Why
risk some desyncing?
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The profile was using a Qt-model to access its data. This means
routing everything through Qt's QVariants and lead to verbose
code such as
double prev_y = dataModel.index(i-1, vDataColumn).data().toReal();
Instead of storing a data-column and do access via a template,
simply store accessor functions. The code from above now reads as
double prev_y = accessor(data[i-1]);
This should also be distinctly faster for the ns-optimizers among
us.
Only one case was somewhat nasty to convert: The accessors for
the 16 tissues are now generated via a recursive template. Thanks
to C++17's constexpr if, such a template is pleasantly easy
to follow, though.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The intention was to use QObject slots for animations.
However, these animations never materialized. Should we
ever want to animate them, we might use the animation
object that is already used for cartesian axes.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This indicated the data of the horizontal axis. It was (obviously)
always the time axis. Remove.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There is only one user of this - let's remove complex
interdependencies.
Note: there seem to be two independent plot_infos: in the
ProfileScene and in the DivePlotDataModel. To avoid behavioral
change, this keeps using the DivePlotDataModel's version.
In any case, this has to be unified.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
There was logic to disable animation when switching from "no dive"
to "show dive". However, that has bit-rotted away: the plotted
dive was set before plotting the dive and therefore the check
for "change from empty" did not work. Introduce an explicit
empty flag instead.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The old animation was weird: it would reuse the labels
based on the index, not on the value. Thus, with the
new scaling code, sometimes there was no animation at all,
if the value, but not the position changed.
Consider the values instead and let labels appear/disappear.
This makes things slightly more complex.
While changing this code, create our own animation-class.
Thus, we can avoid having the dive axes being QObjects.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function was just needlessly complicated. For one, it
considered the position of the line, but that is never changed
since redoing the positioning code. Moreover, it does in
lots of lines what is a very idiomatic operation: a
one-dimensional affine transformation. Let's shorten the
actual calculation to two lines.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This label is put to the right of the corresponding curve,
so it should arguably be centered vertically. At least to
me this looks more natural.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The time axis might need some space and the average depth item
puts a formatted depth at to right of the profile. Consider
these when calculating the right border.
Since I found no way to turn of the average depth, this creates
a permanent border, which might or might not be a good thing.
Contains some refactoring of the label-size functions provided
by DiveTextItem.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The usual increments (leading 1, 2, 4 or 5) don't look
natural for the time axis. Therefore special case the
time axis and to increments in 1, 2, 3, 4, 5, 6 or 12
parts of a minute or second.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This function was used to check wether a screen-point
is located on the profile. Bizzarely, this was done by
transforming into local coordinates and checking
min/max value. Simply check the screen coordinates
directly. Moreover, make the function return whether
the point is inside the region, not outside the region,
to make logic more straight forward.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Hide thumbnails, which are out of the shown range. This became
necessary when converting to absolute scaling.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
When changing from relative to absolute scaling of the char
elements, positioning of the picture thumbnails was broken.
To emulate the old behavior, add a function to DiveCartesianAxis,
that allows positioning with respect to the axis on the screen.
To simplify tuning of the poctuire positions, name a few
constants explicitly.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>