Example #1
0
   def monitor(self, path, filenames):
      debug().add('path', path).flush()

      class EventHandler(pyinotify.ProcessEvent):
         def __init__(self, app, files):
            self.app = app
            self.watch_list = files
            print 'EventHandler.watch_list={}'.format(self.watch_list)

         def process_IN_CLOSE_WRITE(self, event):
            f = event.name and os.path.join(event.path, event.name) or event.path
            print ' !! processing event {}, {}'.format(event.path, event.name)
            if os.path.join(event.path, event.name) in self.watch_list:
               mod = reload_module() 
               self.app._display = mod.__dict__['display']
               self.app.broken = False

               self.app.force_reload = []

               func_exists = lambda x: x in mod.__dict__
               skip_update = lambda x: getattr(mod.__dict__[x], 'do_not_update', False)
               do_update = lambda x: func_exists(x) and not skip_update(x)

               if 'frame' in mod.__dict__: 
                  self.app._frame = mod.__dict__['frame']

               if 'button_press' in mod.__dict__: 
                  self.app._button_press = mod.__dict__['button_press']
               
               if 'button_release' in mod.__dict__: 
                  self.app._button_release = mod.__dict__['button_release']

               if 'motion' in mod.__dict__:
                  self.app._motion = mod.__dict__['motion']

               if do_update('gl_init'):
                  self.app._gl_init = mod.__dict__['gl_init']
                  #self.app._gl_init()
                  self.app.force_reload.append(self.app._gl_init)

               if 'init' in mod.__dict__:
                  if not getattr(mod.__dict__['init'], 'do_not_update', False):
                     self.app._init = mod.__dict__['init']
                     #self.app._init()
                     self.app.force_reload.append(self.app._init)

      self.wm = pyinotify.WatchManager()
      self._Notifier = pyinotify.Notifier(self.wm, EventHandler(self, filenames), timeout=10)
      self.wm.add_watch(path, pyinotify.IN_CLOSE_WRITE)
Example #2
0
 def enable_tracking(self, **kwargs):
    debug().flush()
    cache = kwargs.get('cache', None)
    if cache:
       debug(msg='loading bounding region from cache')
    else:
       self.region = compute_bounding_region(self._vertex_buffer)
       debug(indent=1).add('region', self.region).flush()
       debug(indent=1).add('region.center', self.region.center()).flush()
       add_tracked_object(self)
Example #3
0
   def move_to(self, position):
      debug().add('position', position)

      dx = position[0] - self.origin[0]
      dy = position[1] - self.origin[1]
      dz = position[2] - self.origin[2]

      self.origin = position

      if not hasattr(self, 'region'):
         return

      self.region.bounds['x'].min += dx 
      self.region.bounds['x'].max += dx 

      self.region.bounds['y'].min += dy 
      self.region.bounds['y'].max += dy 

      self.region.bounds['z'].min += dz 
      self.region.bounds['z'].max += dz 
Example #4
0
   def __init__(self, init, gl_init, display, frame, 
                button_press, button_release, motion, 
                communicate,
                args, program_args):
      pyvrui.Application.__init__(self, sys.argv+args)
      pyvrui.GLObject.__init__(self)

      self._init = init
      self._gl_init = gl_init
      self._display = display
      self._frame = frame
      self._button_press = button_press
      self._button_release = button_release
      self._motion = motion
      self._communicate = communicate

      self.menu_callbacks = {} 

      if self._init:
         if program_args:
            debug(msg='initializing with program args', level=WARNING).flush()
            self._init(program_args)
         else:
            debug(msg='initializing without args', level=WARNING).flush()
            self._init()

      mainMenu = self.createMainMenu()
      pyvrui.setMainMenu(mainMenu)

      toolManager = pyvrui.getToolManager()
      toolManager.getToolCreationCallbacks().add(self.toolCreationCallback)
      toolManager.getToolDestructionCallbacks().add(self.toolDestructionCallback)

      #self.locatorTool = None
      self.locatorTools = []

      self.frame_count = 0