From a154d1ccdc107a052a602afa6f0486f4c5005efc Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 12 Nov 2012 20:01:12 -0800 Subject: 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 --- profile.c | 22 ++++++++++++++++------ 1 file 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; } -- cgit v1.2.3-70-g09d2