diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/GipfelWidget.H | 8 | ||||
-rw-r--r-- | src/GipfelWidget.cxx | 49 | ||||
-rw-r--r-- | src/Panorama.H | 7 | ||||
-rw-r--r-- | src/Panorama.cxx | 40 | ||||
-rw-r--r-- | src/gipfel.cxx | 36 |
5 files changed, 118 insertions, 22 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 202ecc0..44148d6 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -36,7 +36,7 @@ class GipfelWidget : public Fl_Widget { Panorama *pan; Fl_Menu_Button *mb; char *img_file; - + double track_width; int handle(int event); @@ -46,6 +46,8 @@ class GipfelWidget : public Fl_Widget { void set_labels(Hills *v); + int get_rel_track_width(Hill *m); + public: GipfelWidget(int X,int Y,int W, int H); @@ -73,6 +75,8 @@ class GipfelWidget : public Fl_Widget { void set_height_dist_ratio(double r); + void set_hide_value(double h); + void set_view_lat(double v); void set_view_long(double v); @@ -97,6 +101,8 @@ class GipfelWidget : public Fl_Widget { double get_view_height(); + void set_track_width(double w); + Projection::Projection_t get_projection(); void set_projection(Projection::Projection_t p); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index a22c7a9..bed4cd1 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -66,6 +66,7 @@ GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) { m1 = NULL; m2 = NULL; img_file = NULL; + track_width = 500.0; for (i=0; i<=3; i++) { marker->add(new Hill(i * 10, 0)); @@ -308,7 +309,7 @@ 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|Hill::HIDDEN)) { continue; } @@ -343,22 +344,30 @@ GipfelWidget::draw() { } /* track */ - if (track_points && track_points->get_num() >= 1) { + if (track_points && track_points->get_num() > 0) { int last_x, last_y, last_initialized = 0; - - fl_color(FL_RED); - fl_line_style(FL_SOLID, 2); + 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) { - fl_line(center_x + x() + last_x, - center_y + y() + last_y, - center_x + x() + track_points->get(i)->x, - center_y + y() + track_points->get(i)->y); + fl_begin_line(); + fl_vertex(center_x + x() + last_x, center_y + y() + last_y); + fl_vertex(center_x + x() + track_points->get(i)->x, + center_y + y() + track_points->get(i)->y); + fl_end_line(); } + last_x = track_points->get(i)->x; last_y = track_points->get(i)->y; last_initialized++; @@ -386,7 +395,7 @@ 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|Hill::HIDDEN)) { continue; } @@ -606,6 +615,14 @@ 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_view_lat(double v) { pan->set_view_lat(v); set_labels(pan->get_visible_mountains()); @@ -663,6 +680,18 @@ GipfelWidget::update() { Fl::wait(1.0); } +int +GipfelWidget::get_rel_track_width(Hill *m) { + double dist = pan->get_real_distance(m); + + return MAX((pan->get_scale() * track_width) / (dist * 10.0), 1.0); +} + +void +GipfelWidget::set_track_width(double w) { + track_width = w; + redraw(); +} int GipfelWidget::handle(int event) { diff --git a/src/Panorama.H b/src/Panorama.H index 62b2b88..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; @@ -92,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(); @@ -130,6 +133,10 @@ class Panorama { double get_view_height(); + double get_earth_radius(Hill *m); + + double get_real_distance(Hill *m); + int comp_params(Hill *m1, Hill *m2); int guess(Hills *p1, Hill *m1); diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 22539cb..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; @@ -404,23 +405,31 @@ Panorama::update_angles() { 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 hide_val; - + 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) { + 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)) { @@ -430,11 +439,9 @@ Panorama::mark_hidden() { continue; } - hide_val = (n->a_nick - m->a_nick) / fabs(m->a_view - n->a_view); - if (hide_val > 5.0) { + h = (n->a_nick - m->a_nick) / fabs(m->a_view - n->a_view); + if (isinf(h) || h > hide_value) { m->flags |= Hill::HIDDEN; - -fprintf(stderr, "%s %f %f %s %f %f => %f\n", m->name, m->dist, m->a_nick, n->name, n->dist, n->a_nick, hide_val); } } @@ -454,7 +461,7 @@ Panorama::update_close_mountains() { if (m->flags & Hill::TRACK_POINT || ((m->phi != view_phi || m->lam != view_lam) && - (m->height / (m->dist * EARTH_RADIUS) + (m->height / (m->dist * get_earth_radius(m)) > height_dist_ratio))) { close_mountains->add(m); @@ -561,3 +568,20 @@ Panorama::nick(double dist, double height) { return beta - pi_d / 2.0; } +double +Panorama::get_earth_radius(Hill *m) { + return EARTH_RADIUS; +} + +double +Panorama::get_real_distance(Hill *m) { + double a, b, c, gam; + + a = view_height + get_earth_radius(m); // using m here is not quite right + b = m->height + get_earth_radius(m); + gam = m->dist; + + c = sqrt(pow(a, 2.0) + pow(b, 2.0) - 2.0 * a * b * cos(gam)); + return c; +} + diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 01b1cd0..f283704 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -55,7 +55,8 @@ char *data_file = DEFAULT_DATAFILE; GipfelWidget *gipf = NULL; Fl_Dial *s_center = NULL; -Fl_Slider *s_nick = NULL, *s_scale = NULL, *s_tilt = NULL, *s_height_dist; +Fl_Slider *s_nick, *s_scale, *s_tilt, *s_height_dist, *s_track_width; +Fl_Slider *s_hide_value; Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height; Fl_Box *b_viewpoint; Fl_Menu_Bar *mb; @@ -135,6 +136,14 @@ void view_height_cb(Fl_Value_Input* o, void*) { gipf->set_view_height(o->value()); } +void track_width_cb(Fl_Value_Input* o, void*) { + gipf->set_track_width(o->value()); +} + +void hide_value_cb(Fl_Value_Input* o, void*) { + gipf->set_hide_value(o->value()); +} + void viewpoint_cb(Fl_Value_Input* o, void*) { Hill *m = choose_hill(gipf->get_mountains(), "Choose Viewpoint"); if (m) { @@ -254,6 +263,27 @@ create_control_window() { s_height_dist->callback((Fl_Callback*)h_d_cb); s_height_dist->align(FL_ALIGN_TOP); + s_track_width = new Fl_Value_Slider(235, 180, 160, 15, "Track Width"); + s_track_width->type(1); + s_track_width->box(FL_THIN_DOWN_BOX); + s_track_width->labelsize(10); + s_track_width->step(1.0); + s_track_width->bounds(1.0, 2000.0); + s_track_width->slider(FL_UP_BOX); + s_track_width->callback((Fl_Callback*)track_width_cb); + s_track_width->align(FL_ALIGN_TOP); + + s_hide_value = new Fl_Value_Slider(235, 210, 160, 15, "Hide Value"); + s_hide_value->type(1); + s_hide_value->box(FL_THIN_DOWN_BOX); + s_hide_value->labelsize(10); + s_hide_value->step(0.01); + s_hide_value->bounds(0.1, 8.0); + s_hide_value->value(1.0); + s_hide_value->slider(FL_UP_BOX); + s_hide_value->callback((Fl_Callback*)hide_value_cb); + s_hide_value->align(FL_ALIGN_TOP); + // Viewpoint Stuff b_viewpoint = new Fl_Box(FL_DOWN_BOX, 30, 255, 300, 80, ""); @@ -278,10 +308,10 @@ create_control_window() { i_view_height->callback((Fl_Callback*)view_height_cb); // Buttons - Fl_Button *b = new Fl_Button(240, 180, 50, 15, "comp"); + Fl_Button *b = new Fl_Button(240, 240, 50, 15, "comp"); b->color(FL_RED); b->callback(comp_cb); - Fl_Button *b1 = new Fl_Button(320, 180, 50, 15, "guess"); + Fl_Button *b1 = new Fl_Button(320, 240, 50, 15, "guess"); b1->callback(guess_cb); b1->color(FL_GREEN); |