profile: use dynamic distances between labels on chart

Use variable intervals for printing temperature and heart
beat labels. Obviously, so that the labels don't become
sparse on zooming, but also to make them not too crowded
on mobile / small screens.

This doesn't work for depth labels, because these labels
use data provided from the profile.c core that doesn't
know about the size of the chart.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2021-10-16 20:43:19 +02:00 committed by Dirk Hohndel
parent 5c83fcd647
commit efc89b9d9c
3 changed files with 23 additions and 8 deletions

View file

@ -99,6 +99,16 @@ double DiveCartesianAxis::height() const
return labelHeight + labelSpaceVertical * dpr;
}
int DiveCartesianAxis::getMinLabelDistance(const DiveCartesianAxis &timeAxis) const
{
// For the plot not being to crowded we want at least two
// labels to fit between each pair of displayed labels.
// May need some optimization.
QLineF m = timeAxis.line();
double interval = labelWidth * 3.0 * (timeAxis.maximum() - timeAxis.minimum()) / (m.x2() - m.x1());
return int(ceil(interval));
}
static double sensibleInterval(double inc, int decimals)
{
// Use full decimal increments