summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-29 13:02:26 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-29 13:02:26 +0200
commitdfb33cc7bd701e7549d28cb496c2dab73c92e2d2 (patch)
tree962b348645602dbe512dce455cea029fe2f2cc89
parent447bc15875c664983f0992f6d355360467863d6d (diff)
refactor set_labels() a bit
-rw-r--r--src/GipfelWidget.cxx15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 1185f36..c72cb39 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -331,8 +331,8 @@ GipfelWidget::draw() {
}
static int
-overlap(double m1, double n1, double m2, double n2) {
- return m1 <= n2 && n1 >= m2;
+overlap(double x1, double l1, double x2, double l2) {
+ return x1 <= x2 + l2 && x1 + l1 >= x2;
}
void
@@ -365,12 +365,11 @@ GipfelWidget::set_labels(Hills *v) {
// Check for overlapping labels and
// overlaps between labels and peak markers
- if ((overlap(m->x, m->x + m->label_x, n->x, n->x + n->label_x) &&
- overlap(m->y + m->label_y - height, m->y + m->label_y,
- n->y + n->label_y - height, n->y + n->label_y)) ||
- (overlap(m->x, m->x + m->label_x, n->x - 2, n->x + 2) &&
- overlap(m->y + m->label_y - height,
- m->y + m->label_y, n->y - 2, n->y + 2))) {
+ 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))) {
m->label_y = (int) rint(n->y + n->label_y - m->y - height - 2);
}