summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GipfelWidget.H4
-rw-r--r--src/GipfelWidget.cxx38
-rw-r--r--src/Hill.H3
-rw-r--r--src/Hill.cxx16
4 files changed, 52 insertions, 9 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index ab86a5d..4d1296c 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -1,5 +1,5 @@
//
-// "$Id: GipfelWidget.H,v 1.14 2005/05/03 20:04:14 hofmann Exp $"
+// "$Id: GipfelWidget.H,v 1.15 2005/05/03 21:36:39 hofmann Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -41,6 +41,8 @@ class GipfelWidget : public Fl_Widget {
int set_cur_mountain(int m_x, int m_y);
int set_mountain(int m_x, int m_y);
+
+ void set_labels(Mountains *v);
public:
GipfelWidget(int X,int Y,int W, int H);
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index eeba2fa..49562cf 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: GipfelWidget.cxx,v 1.17 2005/05/03 20:04:14 hofmann Exp $"
+// "$Id: GipfelWidget.cxx,v 1.18 2005/05/03 21:36:39 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -117,11 +117,11 @@ GipfelWidget::draw() {
}
fl_xyline(center_x + m->x + x() - 2, center_y + m->y + y(), center_x + m->x + x() + 2);
- fl_yxline(center_x + m->x + x(), center_y + m->y + y() - 2, center_y + m->y + y() + 2);
+ fl_yxline(center_x + m->x + x(), center_y + m->label_y + y() - 2, center_y + m->y + y() + 2);
fl_draw(m->name,
center_x + m->x + x(),
- center_y + m->y + y());
+ center_y + m->label_y + y());
}
for (i=0; i<marker->get_num(); i++) {
@@ -135,6 +135,31 @@ GipfelWidget::draw() {
fl_pop_clip();
}
+void
+GipfelWidget::set_labels(Mountains *v) {
+ int i, j, width, height;
+ Mountain *m, *n;
+
+ fl_font(FL_HELVETICA, 8);
+
+ for (i=0; i<v->get_num(); i++) {
+ m = v->get(i);
+
+ fl_measure(m->name, width, height);
+
+ m->label_x = m->x + width;
+ m->label_y = m->y;
+
+ for (j=0; j<v->get_num() && j < i; j++) {
+ n = v->get(j);
+
+ if (n->label_x >= m->x && n->label_y >= m->label_y - 1 && n->label_y <= m->label_y + height + 1) {
+ m->label_y = n->label_y - height - 1;
+ }
+ }
+ }
+}
+
int
GipfelWidget::set_cur_mountain(int m_x, int m_y) {
Mountains *mnts = pan->get_visible_mountains();
@@ -186,42 +211,49 @@ GipfelWidget::set_mountain(int m_x, int m_y) {
void
GipfelWidget::set_center_angle(double a) {
pan->set_center_angle(a);
+ set_labels(pan->get_visible_mountains());
redraw();
}
void
GipfelWidget::set_nick_angle(double a) {
pan->set_nick_angle(a);
+ set_labels(pan->get_visible_mountains());
redraw();
}
void
GipfelWidget::set_tilt_angle(double a) {
pan->set_tilt_angle(a);
+ set_labels(pan->get_visible_mountains());
redraw();
}
void
GipfelWidget::set_scale(double s) {
pan->set_scale(s);
+ set_labels(pan->get_visible_mountains());
redraw();
}
void
GipfelWidget::set_height_dist_ratio(double r) {
pan->set_height_dist_ratio(r);
+ set_labels(pan->get_visible_mountains());
redraw();
}
int
GipfelWidget::comp_params() {
pan->comp_params();
+ set_labels(pan->get_visible_mountains());
redraw();
}
int
GipfelWidget::guess() {
pan->guess(marker);
+ set_labels(pan->get_visible_mountains());
redraw();
}
diff --git a/src/Hill.H b/src/Hill.H
index bd97121..f092100 100644
--- a/src/Hill.H
+++ b/src/Hill.H
@@ -1,5 +1,5 @@
//
-// "$Id: Hill.H,v 1.9 2005/05/03 20:32:20 hofmann Exp $"
+// "$Id: Hill.H,v 1.10 2005/05/03 21:36:39 hofmann Exp $"
//
// X11 header file for the Fast Light Tool Kit (FLTK).
//
@@ -37,6 +37,7 @@ class Mountain {
double a_nick;
double dist;
int x, y;
+ int label_x, label_y;
char *name;
Mountain(const char *n, double p, double l, double h);
diff --git a/src/Hill.cxx b/src/Hill.cxx
index 5bef0fd..443e639 100644
--- a/src/Hill.cxx
+++ b/src/Hill.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Hill.cxx,v 1.7 2005/05/03 20:32:20 hofmann Exp $"
+// "$Id: Hill.cxx,v 1.8 2005/05/03 21:36:39 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -55,7 +55,6 @@ Mountain::~Mountain() {
Mountains::Mountains() {
- fprintf(stderr, "===>huhu\n");
num = 0;
cap = 100;
m = (Mountain **) malloc(cap * sizeof(class Mountain *));
@@ -80,9 +79,18 @@ Mountains::add(Mountain *m1) {
static int
-comp_mountains(const void *m1, const void *m2) {
+comp_mountains(const void *n1, const void *n2) {
+ Mountain *m1 = (Mountain *)n1;
+ Mountain *m2 = (Mountain *)n2;
+
if (m1 && m2) {
- return ((Mountain *)m1)->alph > ((Mountain *)m2)->alph;
+ if (m1->alph < m2->alph) {
+ return 1;
+ } else if (m1->alph > m2->alph) {
+ return -1;
+ } else {
+ return 0;
+ }
} else {
return 0;
}