diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/GipfelWidget.H | 4 | ||||
| -rw-r--r-- | src/GipfelWidget.cxx | 23 | ||||
| -rw-r--r-- | src/Hill.H | 5 | ||||
| -rw-r--r-- | src/Panorama.H | 14 | ||||
| -rw-r--r-- | src/Panorama.cxx | 54 | ||||
| -rw-r--r-- | src/gipfel.cxx | 22 | 
6 files changed, 93 insertions, 29 deletions
| diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H index 316fbca..85585ba 100644 --- a/src/GipfelWidget.H +++ b/src/GipfelWidget.H @@ -1,5 +1,5 @@  //  -// "$Id: GipfelWidget.H,v 1.5 2005/04/13 22:24:53 hofmann Exp $" +// "$Id: GipfelWidget.H,v 1.6 2005/04/14 21:15:45 hofmann Exp $"  //  // X11 header file for the Fast Light Tool Kit (FLTK).  // @@ -50,6 +50,8 @@ class GipfelWidget : public Fl_Widget {    void set_center_angle(double a); +  void set_nick_angle(double a); +    void set_scale(double s);    void set_height_dist_ratio(double r); diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx index faf70d1..f4ad159 100644 --- a/src/GipfelWidget.cxx +++ b/src/GipfelWidget.cxx @@ -1,5 +1,5 @@  //  -// "$Id: GipfelWidget.cxx,v 1.6 2005/04/14 19:54:58 hofmann Exp $" +// "$Id: GipfelWidget.cxx,v 1.7 2005/04/14 21:15:45 hofmann Exp $"  //  // PSEditWidget routines.  // @@ -73,7 +73,8 @@ GipfelWidget::set_viewpoint(const char *pos) {  void   GipfelWidget::draw() {    Mountain *m; -  int center = w() / 2; +  int center_x = w() / 2; +  int center_y = h() / 2;    if (img == NULL) {      return; @@ -82,8 +83,6 @@ GipfelWidget::draw() {    fl_push_clip(x(), y(), w(), h());    img->draw(x(),y(),w(),h(),0,0); - -    fl_font(FL_COURIER, 10);    m = pan->get_visible_mountains();    while (m) { @@ -93,8 +92,14 @@ GipfelWidget::draw() {        fl_color(FL_BLACK);      } -    fl_line(center + m->x + x(), 0 + y(), center + m->x + x(), h() + y()); -    fl_draw(m->name, center + m->x + x(), 20 + y() + (int) m->height / 8); +    fl_rectf(center_x + m->x + x() - 2,  +	     center_y + m->y + y() - 2, +	     4, +	     4); +      //    fl_line(center_x + m->x + x(), 0 + y(), center_x + m->x + x(), h() + y()); +    fl_draw(m->name,  +	    center_x + m->x + x(),  +	    center_y + m->y + y());      m = m->get_next_visible();    } @@ -143,6 +148,12 @@ GipfelWidget::set_center_angle(double a) {  }  void +GipfelWidget::set_nick_angle(double a) { +  pan->set_nick_angle(a); +  redraw(); +} + +void  GipfelWidget::set_scale(double s) {    pan->set_scale(s);    redraw(); @@ -1,5 +1,5 @@  //  -// "$Id: Hill.H,v 1.4 2005/04/14 19:54:58 hofmann Exp $" +// "$Id: Hill.H,v 1.5 2005/04/14 21:15:45 hofmann Exp $"  //  // X11 header file for the Fast Light Tool Kit (FLTK).  // @@ -36,7 +36,8 @@ class Mountain {    double height;    double alph;    double a_view; -  double distance; +  double a_nick; +  double dist;    int x, y;    char *name; diff --git a/src/Panorama.H b/src/Panorama.H index 30e2635..7bacb09 100644 --- a/src/Panorama.H +++ b/src/Panorama.H @@ -1,5 +1,5 @@  //  -// "$Id: Panorama.H,v 1.3 2005/04/13 21:58:31 hofmann Exp $" +// "$Id: Panorama.H,v 1.4 2005/04/14 21:15:45 hofmann Exp $"  //  // X11 header file for the Fast Light Tool Kit (FLTK).  // @@ -28,16 +28,16 @@  class Panorama {   private: -  double view_phi, view_lam; +  double view_phi, view_lam, view_height;    double height_dist_ratio;    Mountain *mountains;    Mountain *visible_mountains;    Mountain *m1, *m2;    double pi, deg2rad; -  double a_center; +  double a_center, a_nick;    double scale; -  int get_pos(const char *name, double *phi, double *lam); +  int get_pos(const char *name, double *phi, double *lam, double *height);    void update_visible_mountains(); @@ -48,11 +48,15 @@ class Panorama {    double cos_alpha(double phi, double c);    double alpha(double phi, double lam); + +  double nick(double dist, double height);    double center_angle(double alph_a, double alph_b, double d1, double d2);    int get_x(Mountain *m); +  int get_y(Mountain *m); +   public:    Panorama(); @@ -70,6 +74,8 @@ class Panorama {    void set_center_angle(double a); +  void set_nick_angle(double a); +    void set_scale(double s);  }; diff --git a/src/Panorama.cxx b/src/Panorama.cxx index 256b07d..f6a5916 100644 --- a/src/Panorama.cxx +++ b/src/Panorama.cxx @@ -1,5 +1,5 @@  //  -// "$Id: Panorama.cxx,v 1.5 2005/04/14 19:54:58 hofmann Exp $" +// "$Id: Panorama.cxx,v 1.6 2005/04/14 21:15:45 hofmann Exp $"  //  // PSEditWidget routines.  // @@ -36,8 +36,9 @@ Panorama::Panorama() {    height_dist_ratio = 0.07;    pi = asin(1.0) * 2.0;    deg2rad = pi / 180.0; -  a_center = 0.2*pi; -  scale = 0.2; +  a_center = 0.0; +  a_nick = 0.0; +  scale = 20.0;  }  Panorama::~Panorama() { @@ -95,7 +96,7 @@ Panorama::load_file(const char *name) {  int  Panorama::set_viewpoint(const char *name) { -  if (get_pos(name, &view_phi, &view_lam) != 1) { +  if (get_pos(name, &view_phi, &view_lam, &view_height) != 1) {      fprintf(stderr, "Could not find exactly one entry for %s.\n");      return 1;    } @@ -115,6 +116,11 @@ Panorama::get_x(Mountain *m) {  }  int +Panorama::get_y(Mountain *m) { +  return  - (int) (tan(m->a_nick - a_nick) * scale); +} + +int  Panorama::move_mountain(Mountain *m, int x, int y) {    if (m1 && m2 && m != m1 && m != m2) {      return 1; @@ -145,6 +151,12 @@ Panorama::set_center_angle(double a) {  }  void +Panorama::set_nick_angle(double a) { +  a_nick = a; +  update_visible_mountains(); +} + +void  Panorama::set_scale(double s) {    scale = s;    fprintf(stderr, "-->scale %f\n", s); @@ -159,15 +171,16 @@ Panorama::set_height_dist_ratio(double r) {  }  int -Panorama::get_pos(const char *name, double *phi, double *lam) { +Panorama::get_pos(const char *name, double *phi, double *lam, double *height) {    Mountain *m = mountains;    int found = 0; -  double p, l; +  double p, l, h;    while (m) {      if (strcmp(m->name, name) == 0) {        p = m->phi;        l = m->lam; +      h = m->height;        fprintf(stderr, "Found matching entry: %s (%fm)\n", m->name, m->height);        found++; @@ -177,8 +190,9 @@ Panorama::get_pos(const char *name, double *phi, double *lam) {    }    if (found == 1) { -    *phi = p; -    *lam = l; +    *phi    = p; +    *lam    = l; +    *height = h;    }    return found; @@ -190,8 +204,9 @@ Panorama::update_visible_mountains() {    visible_mountains = NULL;    while (m) { +    m->dist = distance(m->phi, m->lam);      if ((m->phi != view_phi || m->lam != view_lam) && -	(m->height / (distance(m->phi, m->lam)* 6368000)  +	(m->height / (m->dist * 6368000)   	 > height_dist_ratio)) {        m->alph = alpha(m->phi, m->lam); @@ -203,10 +218,11 @@ Panorama::update_visible_mountains() {        }        //      fprintf(stderr, "==> %s %f, dist %f km  %f\n", m->name, m->alph, distance(m->phi, m->lam)* 6368, m->a_view); -      if (m->a_view < pi / 2.0 &&  -	  m->a_view > - pi / 2.0) { -       +      if (m->a_view < pi / 2.0 && m->a_view > - pi / 2.0) { +	 +	m->a_nick = nick(m->dist, m->height);  	m->x = get_x(m); +	m->y = get_y(m);  	m->clear_next_visible();  	if (visible_mountains) {  	  visible_mountains->append_visible(m); @@ -266,3 +282,17 @@ Panorama::center_angle(double alph_a, double alph_b, double d1, double d2) {    fprintf(stderr, "tan_b=%f\n", tan_b);    return alph_a + atan(tan_b);  } + +double +Panorama::nick(double dist, double height) { +  double a, b, c; +  double beta; + +  b = height + 6368000.0; +  c = view_height + 6368000.0; + +  a = pow(((b * (b - (2.0 * c * cos(dist)))) + (c * c)), (1.0 / 2.0)); +  beta = acos((-(b*b) + (a*a) + (c*c))/(2 * a * c)); +   +  return beta - pi / 2.0; +} diff --git a/src/gipfel.cxx b/src/gipfel.cxx index 4db18ae..471bb3e 100644 --- a/src/gipfel.cxx +++ b/src/gipfel.cxx @@ -1,5 +1,5 @@  //  -// "$Id: gipfel.cxx,v 1.7 2005/04/14 19:54:58 hofmann Exp $" +// "$Id: gipfel.cxx,v 1.8 2005/04/14 21:15:45 hofmann Exp $"  //  // flpsed program.  // @@ -66,6 +66,12 @@ void angle_cb(Fl_Slider* o, void*) {    }  } +void nick_cb(Fl_Slider* o, void*) { +  if (gipf) { +    gipf->set_nick_angle((double)(o->value())); +  } +} +  void h_d_cb(Fl_Slider* o, void*) {    if (gipf) {      gipf->set_height_dist_ratio((double)(o->value())); @@ -139,8 +145,8 @@ int main(int argc, char** argv) {      img_file = my_argv[0];    } -  win = new Fl_Window(600,700); -  m = new Fl_Menu_Bar(0, 0, 600, 30); +  win = new Fl_Window(800,700); +  m = new Fl_Menu_Bar(0, 0, 800, 30);    m->menu(menuitems);    Fl_Slider* s = new Fl_Slider(0, 30, 160, 15, "scale");    s->type(1); @@ -158,7 +164,15 @@ int main(int argc, char** argv) {    a->bounds(-3.14, 3.14);    a->slider(FL_UP_BOX);    a->callback((Fl_Callback*)angle_cb); -  Fl_Slider* r = new Fl_Slider(320, 30, 160, 15, "height-dist"); +  Fl_Slider* n = new Fl_Slider(320, 30, 160, 15, "nick"); +  n->type(1); +  n->box(FL_THIN_DOWN_BOX); +  n->labelsize(10); +  n->step(0.00001); +  n->bounds(-0.5, 0.5); +  n->slider(FL_UP_BOX); +  n->callback((Fl_Callback*)nick_cb); +  Fl_Slider* r = new Fl_Slider(480, 30, 160, 15, "height-dist");    r->type(1);    r->box(FL_THIN_DOWN_BOX);    r->labelsize(10); | 
