This does two independent things:
It sets the planner state early enough so the appropriate
default profile for the planner is created (without
safety stop).
Upon cancelling the planner, it resets the profile widget
to profile more (rather than planner) as otherwise upon
the next change into the planner the planner model is
not properly initialized.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
When events are hidden in the profile, only hide events with the same
name and the same severity (flags).
From discussion in https://github.com/subsurface/libdc/pull/54.
Signed-off-by: Michael Keller <github@ike.ch>
Add a button that allows the user to hide the infobox with statistics
about the point in the dive under the mouse cursor in order to be able
to see the full dive profile unobstructed.
Signed-off-by: Michael Keller <github@ike.ch>
Remove `renderSVGIcon()` and `renderSVGIconWidth()`, as QPixmaps can be
loaded directly from SVG, and support scaling.
Signed-off-by: Michael Keller <github@ike.ch>
This tries to encapsulate the management of the current dive and
divecomputer in the selection code. The current dive is alreay
set by setSelection(). Add a new parameter to also set the
current divecomputer. If -1 is passed, then the current
computer number is remained. This will allow us to audit the code.
Because for now, the whole "current dive computer" thing seems
to be ill-defined.
This fixes a bug: the dive-computer number wasn't validated
when making a new dive the current dive. The new code has some
drawbacks though: when selecting a whole trip, the validation
will be called for all dives in the trip and thus the dive computer
number will depend on the dive with the lowest amount of dive
computers in the trip. This will need to be fixed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
With Qt-containers, this might be a small pessimization, because
it might lead to a deep copy. This can be "fixed" by
for (const Type &item: qAsConst(container))
But frankly, I don't care. Ultimately it is probably best to
replace the Qt containers by standard containers.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The eventname handling code was splattered all over the place.
Collect it in a single source file and use C++ idioms to avoid
nasty memory management. Provide a C-only interface, however.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Small refactoring to use `get_gasmix_at_time` from `core` in `TankItem`
to find the first gasmix used during a dive.
Signed-off-by: Michael Keller <github@ike.ch>
When the profile was to small, it would switch into empty state
and clear the plot info.
On resize events, the plot info is not recalculated.
This means that when making the profile extremely small and
then bigger, nothing is shown.
This may also happen on startup. The profile is rendered into
a 0x0 widget and then gets a resize event.
Therefore, remember when the profile is empty and force a
recalculation of the plot info.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The moveInVector() function was defined in qthelper.h, even
though it has nothing to do with Qt. Therefore, move it into
its own header.
Morover, since it is a very low-level function, use snake_case.
And rename it to move_in_range(), because it does not only
work on vectors, but any range with random-access iterators.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The profile replots if the mode of the currently displayed
dive changed. To do so, it compares the changed dive to
the displayed_dive. However, that is only used for planned
dives since quite some time.
Fix the check and make the replotting work again.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
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>