Changeset 518


Ignore:
Timestamp:
09/14/10 15:07:03 (21 months ago)
Author:
ddangelo
Message:

Function to get the osg camera object for a given subdisplay. Not the best way (according to the avango.display idea), but the fastest one.
TODO: Think about an abstract way to do this in concept of avango.display.

Location:
trunk/avango-display/python/avango/display
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/avango-display/python/avango/display/__init__.py

    r454 r518  
    107107    return _selected_display.get_num_users(subdisplay) 
    108108 
     109def get_camera(subdisplay): 
     110    """ 
     111    Get the osg.Camera object of the selected subdisplay. If no camera for the 
     112    given subdisplay is found, None is returned 
     113    """ 
     114    return _selected_display.get_camera(subdisplay) 
     115 
    109116def make_user(user=0, interface="", subdisplay=""): 
    110117    """Create a field container that represents the user position. 
  • trunk/avango-display/python/avango/display/_display.py

    r471 r518  
    9090            self.connect_view_field(user_selector.ViewOut) 
    9191 
    92             self.view_created(camera,view) 
     92            self.view_created(camera,view,subdisplay) 
    9393 
    9494        if self._inspector and len(self._inspector.Children.value) == 0: 
     
    9999 
    100100        return display_view 
     101 
     102    def get_camera(self, subdisplay): 
     103        return None 
    101104 
    102105    def make_device(self, device, interface): 
     
    214217        self._users.append(user) 
    215218 
    216     def view_created(self,camera,view): 
     219    def view_created(self,camera,view,subdisplay=""): 
    217220        ''' 
    218221        Template function, which can be overridden by subclasses. 
  • trunk/avango-display/python/avango/display/setups/Monitor.py

    r512 r518  
    5959        self.add_user(user) 
    6060     
    61     def make_view(self, subdisplay, trackball_support=True): 
    62          
     61    def make_view(self, subdisplay): 
    6362        display_view = avango.display.nodes.MonitorView() 
    6463        if subdisplay == "": 
     
    6766        # In the Monitor setting each subdisplay simply get a new window 
    6867        else: 
    69             window = self.make_window(0, 0, 1024, 768, 4, 3, False, self._screen_identifier, 2) 
     68            window = self.make_window(0, 0, 1024, 768, 0.4, 0.3, False, self._screen_identifier, 2) 
    7069            window.Decoration.value = True 
    7170            window.AutoHeight.value = True 
     
    7372            window.Title.value = subdisplay 
    7473            window.Name.value = subdisplay 
    75      
    76             camera, view = self.make_camera(display_view, 0., window) 
    77             camera.ScreenTransform.value = avango.osg.make_trans_mat(0, 1.2, -2.4) 
    78      
     74             
     75            window_translation = avango.osg.make_trans_mat(0, 1.7, -0.6) 
     76            current_user = 0 
     77             
     78         
     79            eye_offset = 0.0 
     80            if window.StereoMode.value != avango.osg.viewer.stereo_mode.STEREO_MODE_NONE: 
     81                eye_offset = 0.03 
     82 
     83            camera, view = self.make_camera_with_viewport( 
     84                display_view, eye_offset, window_translation, window) 
     85            camera.EyeTransform.connect_from(self._users[current_user].Matrix) 
     86             
     87            #self.connect_view_field(user_selector.ViewOut) 
     88            self._subdisplay_window[subdisplay] = window 
     89             
     90            #print "<" + str(subdisplay) + "> make_view" 
    7991            self.add_view(view) 
    80      
    81             window_event = avango.osg.viewer.nodes.EventFields(View = view) 
    82             self._subdisplay_window_events[subdisplay] = window_event 
    83             window.DragEvent.connect_from(window_event.DragEvent) 
    84             window.MoveEvent.connect_from(window_event.MoveEvent) 
    85             self._subdisplay_camera[subdisplay] = camera 
    86             self._subdisplay_window[subdisplay] = window 
    87          
     92             
     93            self.view_created(camera,view,subdisplay) 
    8894         
    8995        #configure trackball 
     
    131137  
    132138     
    133     def view_created(self, camera, view): 
     139    def view_created(self, camera, view, subdisplay): 
    134140        'Primary window is automatically created by the constructor. All other windows are created by explicit calls of make_view(subdisplay)' 
    135141        # It seems that a view is only allowed to be associated with one EventField at a time. 
    136         if self._subdisplay_window_events.has_key(""): 
     142         
     143        if self._subdisplay_window_events.has_key(subdisplay): 
    137144            return 
    138145        else: 
    139146            window_event = avango.osg.viewer.nodes.EventFields(View = view) 
    140             self._subdisplay_window_events[""] = window_event 
    141             self._subdisplay_window[""].DragEvent.connect_from(window_event.DragEvent) 
    142             self._subdisplay_window[""].MoveEvent.connect_from(window_event.MoveEvent) 
    143             self._subdisplay_camera[""] = camera 
     147            self._subdisplay_window_events[subdisplay] = window_event 
     148            self._subdisplay_window[subdisplay].DragEvent.connect_from(window_event.DragEvent) 
     149            self._subdisplay_window[subdisplay].MoveEvent.connect_from(window_event.MoveEvent) 
     150            self._subdisplay_camera[subdisplay] = camera 
     151             
     152             
     153    def get_camera(self, subdisplay): 
     154        if self._subdisplay_camera.has_key(subdisplay): 
     155            return self._subdisplay_camera[subdisplay] 
     156        return None 
     157         
    144158 
    145159 
     
    221235             
    222236            return gamepad 
     237         
Note: See TracChangeset for help on using the changeset viewer.