summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2005-07-29 17:13:26 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2005-07-29 17:13:26 +0100
commit02a0aca8283e7acd62eb4223c41a671209e5bf7d (patch)
tree0789af2beda67f017580774b581aaa9b5b2541aa
parent6d9fb3fd9c5fe1093ea882077429bb4ecb9b4719 (diff)
popup menu and other stuff
-rw-r--r--.hgignore1
-rw-r--r--src/GipfelWidget.H4
-rw-r--r--src/GipfelWidget.cxx27
-rw-r--r--src/Hill.cxx3
-rw-r--r--src/gipfel.cxx2
5 files changed, 33 insertions, 4 deletions
diff --git a/.hgignore b/.hgignore
index 45e15bd..971fa2d 100644
--- a/.hgignore
+++ b/.hgignore
@@ -21,5 +21,6 @@ depcomp
install-sh
stamp-h1
missing
+tags
gipfel
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 <sys/wait.h>
#include <fcntl.h>
#include <errno.h>
+#include <math.h>
#include <FL/Fl.H>
#include <FL/Fl_Menu_Item.H>
@@ -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);