/[escript]/temp_trunk_copy/pyvisi/py_src/camera.py
ViewVC logotype

Diff of /temp_trunk_copy/pyvisi/py_src/camera.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1148 by jongui, Wed May 16 22:45:33 2007 UTC revision 1194 by jongui, Thu Jun 14 05:53:49 2007 UTC
# Line 26  class Camera: Line 26  class Camera:
26          @param viewport: Viewport in which objects are to be rendered on          @param viewport: Viewport in which objects are to be rendered on
27          """          """
28    
         self.__scene = scene  
29          self.__viewport = viewport          self.__viewport = viewport
30          self.__vtk_camera = vtk.vtkCamera()          self.__vtk_camera = vtk.vtkCamera()
31    
# Line 35  class Camera: Line 34  class Camera:
34          # Keeps track whether the modification to the camera was due to the          # Keeps track whether the modification to the camera was due to the
35          # instantiation. If it is, then __setupCamera() method is called.          # instantiation. If it is, then __setupCamera() method is called.
36          self.__initialization = True          self.__initialization = True
37          self.__scene._addVisualizationModules(self)          scene._addVisualizationModules(self)
38    
39      def __setupCamera(self):      def __setupCamera(self, scene):
40          """          """
41          Setup the camera.          Setup the camera.
42    
43            @type scene: L{Scene <scene.Scene>} object
44            @param scene: Scene in which objects are to be rendered on
45          """          """
46    
47          # Assign the camera to the appropriate renderer          # Assign the camera to the appropriate renderer
48          self.__scene._setActiveCamera(self.__viewport, self.__vtk_camera)          scene._setActiveCamera(self.__viewport, self.__vtk_camera)
49          self.__resetCamera()              self.__resetCamera(scene)  
50    
51      def setFocalPoint(self, position):      def setFocalPoint(self, position):
52          """          """
# Line 174  class Camera: Line 176  class Camera:
176                    
177      def dolly(self, distance):      def dolly(self, distance):
178          """          """
179          Move the camera towards (greater than 1) and away (less than 1) from          Move the camera towards (greater than 1) the rendered object. However,
180          the rendered object.          the camera is unable to be moved away from the rendered object.
181    
182          @type distance: Number          @type distance: Number
183          @param distance: Amount to move towards or away the rendered object          @param distance: Amount to move towards the rendered object
184          """          """
185    
186          self.__vtk_camera.Dolly(distance)          self.__vtk_camera.Dolly(distance)
187          self.__modified = True          self.__modified = True
188    
189      def __resetCameraClippingRange(self):      def parallelProjectionOn(self):
190            """
191            Enable camera parallel projection.
192            """
193    
194            self.__vtk_camera.ParallelProjectionOn()
195            self.__modified = True
196    
197        def parallelProjectionOff(self):
198            """
199            Disable camera parallel projection.
200            """
201    
202            self.__vtk_camera.ParallelProjectionOff()
203            self.__modified = True
204    
205        def __resetCameraClippingRange(self, scene):
206          """          """
207          Reset the camera clipping range based on the bounds of the visible          Reset the camera clipping range based on the bounds of the visible
208          actors. This ensures the rendered object is not cut-off.          actors. This ensures the rendered object is not cut-off.
209          Needs to be called whenever the camera's settings are modified.          Needs to be called whenever the camera's settings are modified.
210    
211            @type scene: L{Scene <scene.Scene>} object
212            @param scene: Scene in which objects are to be rendered on
213          """          """
214    
215          self.__scene._getRenderer()[self.__viewport].ResetCameraClippingRange()          scene._getRenderer()[self.__viewport].ResetCameraClippingRange()
216    
217      def __resetCamera(self):      def __resetCamera(self, scene):
218          """          """
219          Repositions the camera to view the center point of the actors.          Repositions the camera to view the center point of the actors.
220    
221            @type scene: L{Scene <scene.Scene>} object
222            @param scene: Scene in which objects are to be rendered on
223          """          """
224    
225          self.__scene._getRenderer()[self.__viewport].ResetCamera()          scene._getRenderer()[self.__viewport].ResetCamera()
226    
227      def _isModified(self):      def _isModified(self):
228          """          """
# Line 213  class Camera: Line 237  class Camera:
237          else:          else:
238              return False              return False
239    
240      def _render(self):      def _render(self, scene):
241          """          """
242          Render the camera.          Render the camera.
243    
244            @type scene: L{Scene <scene.Scene>} object
245            @param scene: Scene in which objects are to be rendered on
246          """          """
247    
248          if(self._isModified() == True):          if(self._isModified() == True):
249              # Will only be true once only when the camera is instantiated.              # Will only be true once only when the camera is instantiated.
250              if(self.__initialization == True):              if(self.__initialization == True):
251                  self.__setupCamera()                  self.__setupCamera(scene)
252                  self.__initialization == False                  self.__initialization == False
253    
254              self.__resetCameraClippingRange()              self.__resetCameraClippingRange(scene)
255              self.__isModified = False              self.__modified = False
256                            
257    

Legend:
Removed from v.1148  
changed lines
  Added in v.1194

  ViewVC Help
Powered by ViewVC 1.1.26