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>
In a40b40a the cylinder-hiding functionality was changed,
which made it necessary to keep track of the number of
cylinders. Ironically, that code was removed previously,
as it was redundant. The count was not readded to the
functions called by the planner, making editing of cylinders
in the planner impossible.
I wonder more and more if the models for planner and the
equipment tab should be changed. They are too different.
Fixes#3375
Reported-by: Anton Lundin <glance@acc.umu.se>
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>
- Restore the original standard gravity factor for Uwatec/Scubapro dive computers
- Garmin: Fix gas change event parsing
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This GitHub Action started failing. Groovy was EOL'ed six months ago and
downloads from the Ubuntu servers of Groovy components are no longer
supported.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Builds were failing because gradle tried to download libraries from
bintray. JCenter is shutting down in a few weeks.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This was a user request: Sort bar charts by height of the bars.
Obviously, this can only work for categorical charts, not for
histograms.
The UI is a break from the old concept: the sorting is chosen
based on the chart, whereas for the rest of the features, the
viable charts are presented based on the binning, etc.
I found it confusing to have the possible charts be selected
based on sorting. I.e. if a non-bin sort mode is selected,
the histogram charts disappear. On the flip side, this would
be more consistent. We can change it later.
For value-based bar charts, there are three sort modes: by
bin, by count (i.e. number of dives in that bar) and by
value (i.e. length of the bar). This hopefully satisfies all
needs.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In TestUnitConversion we used casts instead of the more common suffix
designations to indicate the type of those integer constants.
Worse, in commit efab955d85 ("cleanup: make feet_to_mm signed") the
return type of feet_to_mm() changed, but the value it is compared to
wasn't adjusted in the test which caused some builds with more
aggressive compiler flags to fail.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Depths are pretty much universally stored using signed integers
(e.g. depth_t is signed int). For consistency, make feet_to_mm()
likewise return a signed value.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
The prev_time variable was defined as unsigned and mixed
with signed variables. gcc rightfully complains with -Wextra.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Since these are std::strings anyway, there seems to be no point
in using the C-lib functions. YMMV, but to me that code is
distinctly more easy to parse.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
With -Wextra, gcc/g++ complains that compound initialization
of weightsystem_t misses the auto_filled parameter. Add it.
For C++ code we might think about writing a constructor. However,
we use two versions: with and without copied string.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
In pscr_o2() the result of a double calculation was implicitly
converted to int, which resulted in a gcc warning.
Part of the expression was explicitly converted to int, but then
subtracted from a double.
Instead, do all the calculations in double and cast the final
expression to int. This is probably the prudent thing to do.
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>
The old get_maxdepth() function in profile.c was accounting for
two things:
- the partial pressure graphs
- rounding to sane value
Both are now taken care of by the profile itself. This leads to
excessive max-depths. Remove the code from profile.c.
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>
free_plot_info_data() frees the sample and pressure arrays
and accordingly sets the corresponding pointers to NULL.
However, it doesn't clear the element-count and thus leaves
the structure in an inconsistent state.
Clear the whole structure with memset(). I am not a fan of
doing so, but there are existing memset() calls in the
same source file, so let's keep it like that for consistency.
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>