source: golgotha/src/maxtool/navigate.cc @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.8 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#include "lisp/li_init.hh"
10#include "m1_info.hh"
11#include "max_object.hh"
12#include "render.hh"
13#include "math/pi.hh"
14#include "app/app.hh"
15#include "st_edit.hh"
16
17class m1_navigate_state_class : public m1_utility_state_class
18{
19public:
20  enum
21  // Grab Masks for functions
22  {
23    moving    = m1_utility_window_class::LEFT,
24    zooming   = m1_utility_window_class::RIGHT,
25    panning   = m1_utility_window_class::MIDDLE
26  };
27 
28  virtual i4_bool mouse_down()
29  {
30    if (buttons() & moving)
31    {
32      if (!i4_current_app->get_window_manager()->shift_pressed() && m1_info.preselect_poly>=0)
33        li_call("select_none");
34      m1_render_window->select_poly(m1_info.preselect_poly);
35      m1_st_edit->select_point(m1_info.preselect_point);
36
37      return i4_T;
38    }
39
40    return i4_F;
41  }
42
43  virtual i4_bool mouse_drag()
44  {
45    //{{{ Handle Moving
46    if (buttons() & moving)
47    {
48      i4_float theta = m1_render_window->theta + 0.01*(mouse_x() - last_x());
49      i4_float phi = m1_render_window->phi - 0.01*(mouse_y() - last_y());
50     
51      if (theta<0.0)
52        theta += i4_pi()*2;
53      else if (theta>i4_pi()*2)
54        theta -= i4_pi()*2;
55     
56      if (phi<0.0)
57        phi += i4_pi()*2;
58      else if (phi>i4_pi()*2)
59        phi -= i4_pi()*2;
60     
61      m1_render_window->theta = theta;
62      m1_render_window->phi = phi;
63      m1_render_window->recalc_view();
64
65      return i4_T;
66    }
67    //}}}
68
69    //{{{ Handle Zooming
70    if (buttons() & zooming)
71    {
72      m1_render_window->dist *= exp(i4_float(mouse_y() - last_y())/height() * log(4));
73     
74      m1_render_window->recalc_view();
75      return i4_T;
76    }
77    //}}}
78
79    //{{{ Handle Panning
80    if (buttons() & zooming)
81    {
82      i4_float p_x = i4_float(mouse_x() - last_x())/width();
83      i4_float p_y = i4_float(mouse_y() - last_y())/height();
84     
85      m1_render_window->pan(p_x,p_y);
86      m1_render_window->recalc_view();
87      return i4_T;
88    }
89    //}}}
90
91    return i4_F;
92  }
93};
94
95m1_navigate_state_class navigate;
96m1_utility_state_class *m1_default_state = &navigate;
97
98li_object *m1_navigate(li_object *o, li_environment *env)
99//{{{
100{
101  m1_render_window->set_state(&navigate);
102  return 0;
103}
104//}}}
105
106li_automatic_add_function(m1_navigate, "navigate");
107
108//{{{ Emacs Locals
109// Local Variables:
110// folded-file: t
111// End:
112//}}}
Note: See TracBrowser for help on using the repository browser.