From 02a0aca8283e7acd62eb4223c41a671209e5bf7d Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Fri, 29 Jul 2005 17:13:26 +0100 Subject: popup menu and other stuff --- src/GipfelWidget.H | 4 +++- src/GipfelWidget.cxx | 27 ++++++++++++++++++++++++++- src/Hill.cxx | 3 ++- src/gipfel.cxx | 2 +- 4 files changed, 32 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index e301244..0bfc8ac 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -45,10 +45,12 @@ class GipfelWidget : public Fl_Widget { void set_labels(Hills *v); void update_menuitems(Hills *h); - + public: GipfelWidget(int X,int Y,int W, int H); + void menu_cb(Hill *hill); + int load_image(const char *file); int load_data(const char *file); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index 7cc5d1a..a8a6f00 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -41,10 +42,13 @@ #include "GipfelWidget.H" static Fl_Menu_Item *menuitems; +static double pi_d, deg2rad; GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) { int i; + pi_d = asin(1.0) * 2.0; + deg2rad = pi_d / 180.0; img = NULL; pan = new Panorama(); cur_mountain = NULL; @@ -344,6 +348,23 @@ GipfelWidget::get_view_height() { return pan->get_view_height(); } +void +GipfelWidget::menu_cb(Hill* hill) { + if (hill) { + set_center_angle(hill->alph / deg2rad); + if (!m1 || (m1 && m2)) { + m1 = hill; + } else { + m2 = hill; + } + } +} + +void +static_menu_cb(Fl_Widget *o, void *f) { + Hill *hill = (Hill*) ((Fl_Menu_*)o)->mvalue()->user_data(); + ((GipfelWidget *)f)->menu_cb(hill); +} void GipfelWidget::update_menuitems(Hills *h) { @@ -362,9 +383,13 @@ GipfelWidget::update_menuitems(Hills *h) { if (h_sort->get(i)->duplicate) { continue; } - menuitems[j++].text = h_sort->get(i)->name; + menuitems[j].text = h_sort->get(i)->name; + menuitems[j].user_data(h_sort->get(i)); + j++; } + mb->menu(menuitems); + mb->callback((Fl_Callback*) static_menu_cb, this); delete h_sort; } diff --git a/src/Hill.cxx b/src/Hill.cxx index 4057524..d189bd7 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -129,7 +129,8 @@ void Hills::mark_duplicates(double dist) { j = i + 1; n = get(j); while (n && fabs(n->phi - m->phi) <= dist) { - if (fabs(n->lam - m->lam) <= dist) { + if (fabs(n->lam - m->lam) <= dist && + fabs(n->height - m->height) <= 50.0 ) { n->duplicate = 1; } j = j + 1; diff --git a/src/gipfel.cxx b/src/gipfel.cxx index e21f5f0..74dba5e 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -225,7 +225,7 @@ create_control_window() { s_height_dist->box(FL_THIN_DOWN_BOX); s_height_dist->labelsize(10); s_height_dist->step(-0.001); - s_height_dist->bounds(0.2, 0.01); + s_height_dist->bounds(0.1, 0.01); s_height_dist->slider(FL_UP_BOX); s_height_dist->callback((Fl_Callback*)h_d_cb); s_height_dist->align(FL_ALIGN_TOP); -- cgit v1.2.3