summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/GipfelWidget.H5
-rw-r--r--src/GipfelWidget.cxx38
-rw-r--r--src/Hill.H3
-rw-r--r--src/Panorama.H5
-rw-r--r--src/Panorama.cxx47
-rw-r--r--src/gipfel.cxx4
6 files changed, 96 insertions, 6 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index 61f3ed4..1aebbea 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -37,6 +37,7 @@ class GipfelWidget : public Fl_Widget {
Fl_Menu_Button *mb;
char *img_file;
double track_width;
+ int show_hidden;
int handle(int event);
@@ -75,6 +76,10 @@ class GipfelWidget : public Fl_Widget {
void set_height_dist_ratio(double r);
+ void set_hide_value(double h);
+
+ void set_show_hidden(int h);
+
void set_view_lat(double v);
void set_view_long(double v);
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index bfa61dd..df07113 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -67,6 +67,7 @@ GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) {
m2 = NULL;
img_file = NULL;
track_width = 500.0;
+ show_hidden = 0;
for (i=0; i<=3; i++) {
marker->add(new Hill(i * 10, 0));
@@ -309,7 +310,11 @@ GipfelWidget::draw() {
for (i=0; i<mnts->get_num(); i++) {
m = mnts->get(i);
- if (m->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) {
+ if (m->flags & (Hill::DUPLICATE|Hill::TRACK_POINT)) {
+ continue;
+ }
+
+ if (!show_hidden && (m->flags & Hill::HIDDEN)) {
continue;
}
@@ -319,6 +324,8 @@ GipfelWidget::draw() {
} else if (m == m2) {
fl_color(FL_RED);
draw_flag(center_x + m->x + x(), center_y + m->y + y(), "2");
+ } else if (m->flags & Hill::HIDDEN) {
+ fl_color(FL_BLUE);
} else {
fl_color(FL_BLACK);
}
@@ -345,12 +352,17 @@ GipfelWidget::draw() {
if (track_points && track_points->get_num() > 0) {
int last_x, last_y, last_initialized = 0;
- fl_color(FL_RED);
for (i=1; i<track_points->get_num(); i++) {
if (!(track_points->get(i)->flags & Hill::VISIBLE)) {
continue;
}
+ if (track_points->get(i)->flags & Hill::HIDDEN) {
+ fl_color(FL_BLUE);
+ } else {
+ fl_color(FL_RED);
+ }
+
fl_line_style(FL_SOLID|FL_CAP_ROUND|FL_JOIN_ROUND,
get_rel_track_width(track_points->get(i)));
if (last_initialized) {
@@ -388,7 +400,11 @@ GipfelWidget::set_labels(Hills *v) {
for (i=0; i<v->get_num(); i++) {
m = v->get(i);
- if (m->flags & (Hill::DUPLICATE | Hill::TRACK_POINT)) {
+ if (m->flags & (Hill::DUPLICATE|Hill::TRACK_POINT)) {
+ continue;
+ }
+
+ if (!show_hidden && (m->flags & Hill::HIDDEN)) {
continue;
}
@@ -608,6 +624,22 @@ GipfelWidget::set_height_dist_ratio(double r) {
}
void
+GipfelWidget::set_hide_value(double h) {
+ pan->set_hide_value(h);
+ set_labels(pan->get_visible_mountains());
+
+ redraw();
+}
+
+void
+GipfelWidget::set_show_hidden(int h) {
+ show_hidden = h;
+ set_labels(pan->get_visible_mountains());
+
+ redraw();
+
+}
+void
GipfelWidget::set_view_lat(double v) {
pan->set_view_lat(v);
set_labels(pan->get_visible_mountains());
diff --git a/src/Hill.H b/src/Hill.H
index 169208b..012d152 100644
--- a/src/Hill.H
+++ b/src/Hill.H
@@ -32,7 +32,8 @@ class Hill {
typedef enum {
DUPLICATE = 0x01,
TRACK_POINT = 0x02,
- VISIBLE = 0x04
+ VISIBLE = 0x04,
+ HIDDEN = 0x08
} flags_t;
double phi, lam;
diff --git a/src/Panorama.H b/src/Panorama.H
index d53dfc5..561f0b6 100644
--- a/src/Panorama.H
+++ b/src/Panorama.H
@@ -34,6 +34,7 @@ class Panorama {
char *view_name;
double height_dist_ratio;
double view_angle;
+ double hide_value;
Hills *mountains;
Hills *close_mountains;
Hills *visible_mountains;
@@ -50,6 +51,8 @@ class Panorama {
void update_close_mountains();
void update_visible_mountains();
+
+ void mark_hidden();
double distance(double phi, double lam);
@@ -90,6 +93,8 @@ class Panorama {
void set_height_dist_ratio(double r);
+ void set_hide_value(double h);
+
Hills * get_mountains();
Hills * get_close_mountains();
diff --git a/src/Panorama.cxx b/src/Panorama.cxx
index 61ba781..6c0b6ba 100644
--- a/src/Panorama.cxx
+++ b/src/Panorama.cxx
@@ -37,6 +37,7 @@ Panorama::Panorama() {
close_mountains = new Hills();
visible_mountains = new Hills();
height_dist_ratio = 0.07;
+ hide_value = 1.0;
pi_d = asin(1.0) * 2.0;
deg2rad = pi_d / 180.0;
parms.a_center = 0.0;
@@ -398,11 +399,56 @@ Panorama::update_angles() {
}
}
+
mountains->sort();
update_close_mountains();
}
+void
+Panorama::set_hide_value(double h) {
+ hide_value = h;
+ update_visible_mountains();
+}
+
+void
+Panorama::mark_hidden() {
+ int i, j;
+ Hill *m, *n;
+ double h;
+
+ for (i=0; i<visible_mountains->get_num(); i++) {
+ m = visible_mountains->get(i);
+
+ m->flags &= ~Hill::HIDDEN;
+
+ if (m->flags & Hill::DUPLICATE) {
+ continue;
+ }
+
+ for (j=0; j<visible_mountains->get_num(); j++) {
+ n = visible_mountains->get(j);
+
+ if (n->flags & Hill::DUPLICATE || n->flags & Hill::TRACK_POINT) {
+ continue;
+ }
+ if (m == n || fabs(m->a_view - n->a_view > pi_d / 2.0)) {
+ continue;
+ }
+ if (m->dist < n->dist || m->a_nick > n->a_nick) {
+ continue;
+ }
+
+ h = (n->a_nick - m->a_nick) / fabs(m->a_view - n->a_view);
+ if (isinf(h) || h > hide_value) {
+ m->flags |= Hill::HIDDEN;
+ }
+ }
+
+ }
+
+}
+
void
Panorama::update_close_mountains() {
int i;
@@ -451,6 +497,7 @@ Panorama::update_visible_mountains() {
}
}
+ mark_hidden();
update_coordinates();
}
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index edd3fd4..2e7f63f 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -292,10 +292,10 @@ create_control_window() {
i_view_height->callback((Fl_Callback*)view_height_cb);
// Buttons
- Fl_Button *b = new Fl_Button(240, 210, 50, 15, "comp");
+ Fl_Button *b = new Fl_Button(240, 210, 60, 20, "comp");
b->color(FL_RED);
b->callback(comp_cb);
- Fl_Button *b1 = new Fl_Button(320, 210, 50, 15, "guess");
+ Fl_Button *b1 = new Fl_Button(320, 210, 60, 20, "guess");
b1->callback(guess_cb);
b1->color(FL_GREEN);