diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2018-03-15 23:12:45 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-03-19 15:44:02 -0700 |
commit | b38eb45b295aaa346ad58e7ba3677456469a2fdd (patch) | |
tree | dd014f81296e7a04432191f2885d1db909083952 | |
parent | ea7f49031df050ea42a5cb78d8a06bd9c8adfc56 (diff) | |
download | subsurface-b38eb45b295aaa346ad58e7ba3677456469a2fdd.tar.gz |
Profile heartrate: Nicer min/max values and tic distance
Correct a bug in finding the minimum heartrate.
Use the minimum and maximum heartrate value to set min/max and
tic distance for the heartrate axis in the profile.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
-rw-r--r-- | core/profile.c | 4 | ||||
-rw-r--r-- | profile-widget/profilewidget2.cpp | 16 |
2 files changed, 16 insertions, 4 deletions
diff --git a/core/profile.c b/core/profile.c index 555f623cf..d9dbfed51 100644 --- a/core/profile.c +++ b/core/profile.c @@ -439,7 +439,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer maxpressure = pressure; if (heartbeat > maxhr) maxhr = heartbeat; - if (heartbeat < minhr) + if (heartbeat && heartbeat < minhr) minhr = heartbeat; if (depth > maxdepth) @@ -469,7 +469,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer if (minpressure > maxpressure) minpressure = 0; if (minhr > maxhr) - minhr = 0; + minhr = maxhr; memset(&pi, 0, sizeof(pi)); pi.maxdepth = maxdepth; diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index b65e76743..4381e6963 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -644,8 +644,20 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) #ifndef SUBSURFACE_MOBILE if (plotInfo.maxhr) { - heartBeatAxis->setMinimum(plotInfo.minhr); - heartBeatAxis->setMaximum(plotInfo.maxhr); + int heartBeatAxisMin = lrint(plotInfo.minhr / 5.0 - 0.5) * 5; + int heartBeatAxisMax, heartBeatAxisTick; + if (plotInfo.maxhr - plotInfo.minhr < 40) + heartBeatAxisTick = 10; + else if (plotInfo.maxhr - plotInfo.minhr < 80) + heartBeatAxisTick = 20; + else if (plotInfo.maxhr - plotInfo.minhr < 100) + heartBeatAxisTick = 25; + else + heartBeatAxisTick = 50; + for (heartBeatAxisMax = heartBeatAxisMin; heartBeatAxisMax < plotInfo.maxhr; heartBeatAxisMax += heartBeatAxisTick); + heartBeatAxis->setMinimum(heartBeatAxisMin); + heartBeatAxis->setMaximum(heartBeatAxisMax + 1); + heartBeatAxis->setTickInterval(heartBeatAxisTick); heartBeatAxis->updateTicks(HR_AXIS); // this shows the ticks } heartBeatAxis->setVisible(prefs.hrgraph && plotInfo.maxhr); |