summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-12 20:01:12 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-11-12 20:01:12 -0800
commita154d1ccdc107a052a602afa6f0486f4c5005efc (patch)
tree152312ecedb6766ae03e640cd9b1b5a1ef903b9e /profile.c
parent4ce0ce153a254284e32d1a8740484f3029d9d758 (diff)
downloadsubsurface-a154d1ccdc107a052a602afa6f0486f4c5005efc.tar.gz
Tweak partial pressure plot to avoid printing values ontop of eachh other
This still can look too busy on shallow long dives with moderate vertical movement. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/profile.c b/profile.c
index b1a361e30..4eaad87e7 100644
--- a/profile.c
+++ b/profile.c
@@ -540,7 +540,11 @@ static void add_index(int idx, int margin, int **ap, int **a2p, int value)
i++;
if (a[i] == idx)
return;
- if (a[i] != -1 && a[i - 1] != -1 && idx - a[i - 1] < margin)
+ /* already have a POI to the left with the same vertical positiom and too close */
+ if ((i > 0 && a[i - 1] != -1 && a2[i - 1] == value && idx - a[i - 1] < margin))
+ return;
+ /* already have a POI to the right with the same vertical positiom and too close */
+ if (a[i] != -1 && a2[i] == value && a[i] - idx < margin)
return;
if (a[i] != -1 && a[i] - idx < margin)
return;
@@ -615,12 +619,18 @@ static void calculate_spikyness(int nr, double *data, double *spk_data, int delt
static gboolean higher_spike(double *spk_data, int idx, int nr, int deltax)
{
int i;
- double s = fabs(spk_data[idx]);
- for (i = MAX(0, idx - deltax); i <= MIN(idx + deltax, nr - 1); i++)
- if (fabs(spk_data[i]) > s)
- return TRUE;
- else if (fabs(spk_data[i]) == s && i < idx)
+ double s = spk_data[idx];
+ for (i = MAX(0, idx - deltax); i <= MIN(idx + deltax, nr - 1); i++) {
+ if (s > 0) {
+ if (spk_data[i] > s)
+ return TRUE;
+ } else {
+ if (spk_data[i] < s)
+ return TRUE;
+ }
+ if (spk_data[i] == s && i < idx)
return TRUE;
+ }
return FALSE;
}