diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-03-29 14:00:12 +0200 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2009-03-29 14:00:12 +0200 |
commit | d2eca5bbe81dc4a899c97f1423c392554113f852 (patch) | |
tree | c853ff74d7b221cd1b6b610e9e397c2cc681586d /src/GipfelWidget.cxx | |
parent | dfb33cc7bd701e7549d28cb496c2dab73c92e2d2 (diff) |
fix long standing bug in label positioning code
Diffstat (limited to 'src/GipfelWidget.cxx')
-rw-r--r-- | src/GipfelWidget.cxx | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index c72cb39..f0403cf 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -344,6 +344,7 @@ GipfelWidget::set_labels(Hills *v) { for (int i = 0; i < v->get_num(); i++) { Hill *m = v->get(i); + Hills colliding; if (m->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) continue; @@ -363,13 +364,22 @@ GipfelWidget::set_labels(Hills *v) { if (!show_hidden && (n->flags & Hill::HIDDEN)) continue; + if (overlap(m->x, m->label_x, + n->x - CROSS_SIZE, n->label_x + CROSS_SIZE)) + colliding.add(n); + } + + colliding.sort_label_y(); + + for (int j = 0; j < colliding.get_num(); j++) { + Hill *n = colliding.get(j); + // Check for overlapping labels and // overlaps between labels and peak markers - if ((overlap(m->x, m->label_x, n->x, n->label_x) && - overlap(m->y + m->label_y - height, height, - n->y + n->label_y - height, height)) || - (overlap(m->x, m->label_x, n->x - 2, 4) && - overlap(m->y + m->label_y - height, height, n->y - 2, 4))) { + if (overlap(m->y + m->label_y - height, height, + n->y + n->label_y - height, height) || + overlap(m->y + m->label_y - height, + height, n->y - CROSS_SIZE, 2 * CROSS_SIZE)) { m->label_y = (int) rint(n->y + n->label_y - m->y - height - 2); } |