1 #!/usr/bin/env python
\r
4 from OpenGL.GL import *
\r
6 from .baseview import *
\r
9 DELEGATE_PATTERN=re.compile('^on[A-Z]')
\r
11 class BaseController(object):
\r
12 def __init__(self, view):
\r
13 self.isInitialized=False
\r
17 def setRoot(self, root):
\r
20 self.isInitialized=False
\r
22 def setView(self, view):
\r
26 def delegate(self, to):
\r
27 for name in dir(to):
\r
28 if DELEGATE_PATTERN.match(name):
\r
29 method = getattr(to, name)
\r
30 setattr(self, name, method)
\r
32 def onUpdate(*args):pass
\r
33 def onLeftDown(*args):pass
\r
34 def onLeftUp(*args):pass
\r
35 def onMiddleDown(*args):pass
\r
36 def onMiddleUp(*args):pass
\r
37 def onRightDown(*args):pass
\r
38 def onRightUp(*args):pass
\r
39 def onMotion(*args):pass
\r
40 def onResize(*args):pass
\r
41 def onWheel(*args):pass
\r
42 def onKeyDown(*args):pass
\r
43 def onInitialize(*args):pass
\r
45 def initialize(self):
\r
46 self.view.onResize()
\r
47 glEnable(GL_DEPTH_TEST)
\r
48 #
\8f\89\8aú
\89»
\8e\9e\82Ì
\8cÄ
\82Ñ
\8fo
\82µ
\r
52 if not self.isInitialized:
\r
54 self.isInitialized=True
\r
55 # OpenGL
\83o
\83b
\83t
\83@
\82Ì
\83N
\83\8a\83A
\r
56 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
\r
57 #
\93\8a\89e
\8ds
\97ñ
\82Ì
\83N
\83\8a\83A
\r
58 glMatrixMode(GL_PROJECTION)
\r
60 self.view.updateProjection()
\r
61 #
\83\82\83f
\83\8b\83r
\83\85\81[
\8ds
\97ñ
\82Ì
\83N
\83\8a\83A
\r
62 glMatrixMode(GL_MODELVIEW)
\r
65 self.view.updateView()
\r