summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GipfelWidget.H4
-rw-r--r--src/GipfelWidget.cxx39
-rw-r--r--src/Hill.cxx4
-rw-r--r--src/Panorama.H7
-rw-r--r--src/Panorama.cxx59
5 files changed, 80 insertions, 33 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index a0459a6..e301244 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -1,5 +1,5 @@
//
-// "$Id: GipfelWidget.H,v 1.21 2005/05/20 13:34:39 hofmann Exp $"
+// "$Id: GipfelWidget.H,v 1.22 2005/06/22 19:47:19 hofmann Exp $"
//
// Copyright 2005 by Johannes Hofmann
//
@@ -43,6 +43,8 @@ class GipfelWidget : public Fl_Widget {
int set_mountain(int m_x, int m_y);
void set_labels(Hills *v);
+
+ void update_menuitems(Hills *h);
public:
GipfelWidget(int X,int Y,int W, int H);
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 5e1c3bf..b71abbf 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: GipfelWidget.cxx,v 1.33 2005/06/19 16:54:02 hofmann Exp $"
+// "$Id: GipfelWidget.cxx,v 1.34 2005/06/22 19:47:19 hofmann Exp $"
//
// GipfelWidget routines.
//
@@ -40,12 +40,7 @@
#include "GipfelWidget.H"
-static Fl_Menu_Item menuitems[] = {
- { "&File", 0, 0, 0, FL_SUBMENU },
- { "&Open File...", FL_CTRL + 'o', NULL},
- {0},
- { 0 }
-};
+static Fl_Menu_Item *menuitems;
GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) {
int i;
@@ -349,10 +344,38 @@ GipfelWidget::get_view_height() {
return pan->get_view_height();
}
+
+void
+GipfelWidget::update_menuitems(Hills *h) {
+ int i,j;
+
+ if (menuitems) {
+ free(menuitems);
+ menuitems = NULL;
+ }
+
+ menuitems = (Fl_Menu_Item*) calloc(h->get_num(), sizeof(Fl_Menu_Item) + 1);
+ j = 0;
+ for (i=0; i<h->get_num(); i++) {
+ if (h->get(i)->duplicate) {
+ continue;
+ }
+ menuitems[j++].text = h->get(i)->name;
+ }
+ mb->menu(menuitems);
+
+}
+
void
GipfelWidget::set_height_dist_ratio(double r) {
+ Hills *h;
+
pan->set_height_dist_ratio(r);
- set_labels(pan->get_visible_mountains());
+ h = pan->get_visible_mountains();
+ set_labels(h);
+
+ menuitems = (Fl_Menu_Item*) calloc(h->get_num(), sizeof(Fl_Menu_Item) + 1);
+ update_menuitems(pan->get_close_mountains());
redraw();
}
diff --git a/src/Hill.cxx b/src/Hill.cxx
index 8f2f527..08d834f 100644
--- a/src/Hill.cxx
+++ b/src/Hill.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Hill.cxx,v 1.15 2005/06/19 16:54:02 hofmann Exp $"
+// "$Id: Hill.cxx,v 1.16 2005/06/22 19:47:20 hofmann Exp $"
//
// Hill routines.
//
@@ -119,9 +119,7 @@ void Hills::mark_duplicates(double dist) {
j = i + 1;
n = get(j);
while (n && fabs(n->phi - m->phi) <= dist) {
- // fprintf(stderr, "%s %f %f %s %f %f\n", m->name, m->phi, m->lam, n->name, n->phi, n->lam);
if (fabs(n->lam - m->lam) <= dist) {
- fprintf(stderr, "Duplicate: %s <=> %s\n", m->name, n->name);
n->duplicate = 1;
}
j = j + 1;
diff --git a/src/Panorama.H b/src/Panorama.H
index 15e51cb..73e6b5d 100644
--- a/src/Panorama.H
+++ b/src/Panorama.H
@@ -1,5 +1,5 @@
//
-// "$Id: Panorama.H,v 1.19 2005/05/20 13:34:39 hofmann Exp $"
+// "$Id: Panorama.H,v 1.20 2005/06/22 19:47:20 hofmann Exp $"
//
// Copyright 2005 by Johannes Hofmann
//
@@ -30,6 +30,7 @@ class Panorama {
char *view_name;
double height_dist_ratio;
Hills *mountains;
+ Hills *close_mountains;
Hills *visible_mountains;
int x1, y1, x2, y2;
double a_center;
@@ -43,6 +44,8 @@ class Panorama {
void update_coordinates();
+ void update_close_mountains();
+
void update_visible_mountains();
double distance(double phi, double lam);
@@ -76,6 +79,8 @@ class Panorama {
void set_height_dist_ratio(double r);
+ Hills * get_close_mountains();
+
Hills * get_visible_mountains();
void set_center_angle(double a);
diff --git a/src/Panorama.cxx b/src/Panorama.cxx
index 45bafe1..8153a15 100644
--- a/src/Panorama.cxx
+++ b/src/Panorama.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Panorama.cxx,v 1.44 2005/06/19 16:54:02 hofmann Exp $"
+// "$Id: Panorama.cxx,v 1.45 2005/06/22 19:47:20 hofmann Exp $"
//
// Panorama routines.
//
@@ -52,6 +52,7 @@ static double pi_d, deg2rad;
Panorama::Panorama() {
mountains = new Hills();
+ close_mountains = new Hills();
visible_mountains = new Hills();
height_dist_ratio = 0.07;
pi_d = asin(1.0) * 2.0;
@@ -107,6 +108,11 @@ Panorama::set_viewpoint(const char *name) {
}
Hills *
+Panorama::get_close_mountains() {
+ return close_mountains;
+}
+
+Hills *
Panorama::get_visible_mountains() {
return visible_mountains;
}
@@ -160,17 +166,14 @@ Panorama::guess(Hills *p, Hill *m1) {
for (i=0; i<p->get_num(); i++) {
p2 = p->get(i);
- for (j=0; j<mountains->get_num(); j++) {
- m_tmp2 = mountains->get(j);
+ for (j=0; j<close_mountains->get_num(); j++) {
+ m_tmp2 = close_mountains->get(j);
m1 = m_tmp1;
m1->x = x1_sav;
m1->y = y1_sav;
- if (m1 == m_tmp2 ||
- fabs(m1->alph - m_tmp2->alph) > pi_d *0.7 ||
- m_tmp2->height / (m_tmp2->dist * EARTH_RADIUS) <
- height_dist_ratio) {
+ if (m1 == m_tmp2 || fabs(m1->alph - m_tmp2->alph) > pi_d *0.7) {
continue;
}
@@ -337,7 +340,7 @@ Panorama::set_scale(double s) {
void
Panorama::set_height_dist_ratio(double r) {
height_dist_ratio = r;
- update_visible_mountains();
+ update_close_mountains();
}
void
@@ -450,15 +453,15 @@ Panorama::update_angles() {
mountains->sort();
- update_visible_mountains();
+ update_close_mountains();
}
void
-Panorama::update_visible_mountains() {
+Panorama::update_close_mountains() {
int i;
Hill *m;
- visible_mountains->clear();
+ close_mountains->clear();
for (i=0; i<mountains->get_num(); i++) {
m = mountains->get(i);
@@ -467,17 +470,33 @@ Panorama::update_visible_mountains() {
(m->height / (m->dist * EARTH_RADIUS)
> height_dist_ratio)) {
- m->a_view = m->alph - a_center;
+ close_mountains->add(m);
+ }
+ }
- if (m->a_view > pi_d) {
- m->a_view -= 2.0*pi_d;
- } else if (m->a_view < -pi_d) {
- m->a_view += 2.0*pi_d;
- }
+ update_visible_mountains();
+}
+
+void
+Panorama::update_visible_mountains() {
+ int i;
+ Hill *m;
+
+ visible_mountains->clear();
+
+ for (i=0; i<close_mountains->get_num(); i++) {
+ m = close_mountains->get(i);
+
+ m->a_view = m->alph - a_center;
+
+ if (m->a_view > pi_d) {
+ m->a_view -= 2.0*pi_d;
+ } else if (m->a_view < -pi_d) {
+ m->a_view += 2.0*pi_d;
+ }
- if (m->a_view < pi_d / 3.0 && m->a_view > - pi_d / 3.0) {
- visible_mountains->add(m);
- }
+ if (m->a_view < pi_d / 3.0 && m->a_view > - pi_d / 3.0) {
+ visible_mountains->add(m);
}
}