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

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

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

revision 835 by jongui, Mon Sep 4 22:20:28 2006 UTC revision 837 by jongui, Tue Sep 5 07:23:50 2006 UTC
# Line 1  Line 1 
1  """  """
2  Class and functions associated with cameras and views  Class that controls the camera and its settings.
3  """  """
4    
5  import vtk  import vtk
6    
7  class Camera:  class Camera:
8        """
9        @author: John Ngui
10        @author: Lutz Gross
11        """
12    
13      def __init__(self, open_scene):      def __init__(self, open_scene):
14            """
15            @type open_scene: L{OpenScene <openscene.OpenScene>} object
16            @param open_scene: Scene in which components are to be added to
17            """
18    
19          self.open_scene = open_scene          self.open_scene = open_scene
20          self.vtk_camera = None          self.vtk_camera = None
21    
22          self.setCamera()          self.setCamera()
23    
24      def setCamera(self):      def setCamera(self):
25            """
26            Set up the camera and associate it with the renderer.
27            """
28    
29          self.vtk_camera = vtk.vtkCamera()                self.vtk_camera = vtk.vtkCamera()      
30          self.open_scene.getRenderer().SetActiveCamera(self.vtk_camera)          self.open_scene.getRenderer().SetActiveCamera(self.vtk_camera)
31    
32      def setClippingRange(self, near_clipping, far_clipping):      def setClippingRange(self, near_clipping, far_clipping):
33            """
34            Set the near and far clipping plane of the camera.
35    
36            @type near_clipping: Number
37            @param near_clipping: Distance to the near clipping range
38            @type far_clipping: Number
39            @param far_clipping: Distance to the far clipping plane
40            """
41    
42          self.vtk_camera.SetClippingRange(near_clipping, far_clipping)          self.vtk_camera.SetClippingRange(near_clipping, far_clipping)
43    
44      def setFocalPoint(self, position):      def setFocalPoint(self, position):
45            """
46            Set the focal point of the camera.
47        
48            @type position: L{Position <geo.Position>} object
49            @param position: Camera focal point position
50            """
51    
52          self.vtk_camera.SetFocalPoint(position.getXCoor(), position.getYCoor(),          self.vtk_camera.SetFocalPoint(position.getXCoor(), position.getYCoor(),
53              position.getZCoor())                  position.getZCoor())    
54    
55      def setPosition(self, position):      def setPosition(self, position):
56            """
57            Set the position of the camera.
58    
59            @type position: L{Position <geo.Position>} object
60            @param position: Camera position
61            """
62    
63          self.vtk_camera.SetPosition(position.getXCoor(), position.getYCoor(),          self.vtk_camera.SetPosition(position.getXCoor(), position.getYCoor(),
64              position.getZCoor())              position.getZCoor())
65    
66      def setViewUp(self, position):      def setViewUp(self, position):
67            """
68            Set the up direction of the camera.
69    
70            @type position: L{Position <geo.Position>} object
71            @param position: Camera view up position
72            """
73    
74          self.vtk_camera.SetViewUp(position.getXCoor(), position.getYCoor(),          self.vtk_camera.SetViewUp(position.getXCoor(), position.getYCoor(),
75              position.getZCoor())              position.getZCoor())
76    

Legend:
Removed from v.835  
changed lines
  Added in v.837

  ViewVC Help
Powered by ViewVC 1.1.26