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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 637 - (hide annotations)
Thu Mar 23 10:55:31 2006 UTC (14 years, 2 months ago) by gross
File MIME type: text/x-python
File size: 5142 byte(s)
more copyright statements added
1 cochrane 337 """
2     Class and functions associated with a pyvisi Camera object
3 gross 637
4     @var __author__: name of author
5     @var __license__: licence agreement
6     @var __copyright__: copyrights
7     @var __url__: url entry point on documentation
8     @var __version__: version
9     @var __date__: date of the version
10 cochrane 337 """
11    
12 gross 637 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
13     http://www.access.edu.au
14     Primary Business: Queensland, Australia"""
15     __license__="""Licensed under the Open Software License version 3.0
16     http://www.opensource.org/licenses/osl-3.0.php"""
17     __author__="Paul Cochrane"
18     __url__="http://www.iservo.edu.au/esys"
19     __version__="$Revision$"
20     __date__="$Date$"
21    
22    
23 cochrane 337 # generic imports
24 gross 605 from common import debugMsg, overrideWarning
25 cochrane 337
26 gross 605 from item import Item
27 cochrane 337
28     class Camera(Item):
29     """
30     Camera class
31     """
32     def __init__(self, scene):
33     """
34     Initialisation of the Camera object
35    
36     @param scene: The Scene object to add the Camera object to
37     @type scene: Scene object
38     """
39     Item.__init__(self)
40     debugMsg("Called Camera.__init__()")
41    
42     # default x,y,z positions of Camera (specific to vtk)
43     self.xPos = 0.0
44     self.yPos = 0.0
45     self.zPos = 3.0
46    
47     # default x,y,z positions of the Camers's focal point (specific to vtk)
48     self.xFocalPoint = 0.0
49     self.yFocalPoint = 0.0
50     self.zFocalPoint = 0.0
51    
52     # default elevation and azimuth
53     self.elevation = 30 ####### we should try for matlab defaults
54     self.azimuth = 30
55    
56     # keep a reference to the renderer so we can send stuff to it
57     self.renderer = scene.renderer
58    
59     # some vtk initialisation commands
60     self.renderer.runString("# Camera.__init__()\n")
61    
62     # initialise the position of the Camera
63     self.setPosition(self.xPos, self.yPos, self.zPos)
64     self.setFocalPoint(self.xFocalPoint, self.yFocalPoint, self.zFocalPoint)
65    
66     def setPosition(self, *pos):
67     """
68     Set position of camera within scene
69    
70     @param pos: Position to set camera in terms of x,y,z coordinates
71     @type pos: tuple
72     """
73     debugMsg("Called Camera.setPosition()")
74    
75     # I need to do some mucking around in here with coordinate systems
76     # and so on, but at present, we'll just use vtk's coord system
77    
78     self.xPos = pos[0]
79     self.yPos = pos[1]
80     self.zPos = pos[2]
81    
82     # print a warning message if get to here
83     overrideWarning("Camera.setPosition")
84    
85     # now to set the position
86    
87     return
88    
89     def getPosition(self):
90     """
91     Get the position of Camera within Scene
92    
93     Returns the position in a tuple of form (xPos, yPos, zPos)
94     """
95     debugMsg("Called Camera.getPosition()")
96    
97     return (self.xPos, self.yPos, self.zPos)
98    
99     def setFocalPoint(self, *pos):
100     """
101     Sets the focal point of the Camera with the Scene
102    
103     @param pos: Position to set the focal point
104     @type pos: tuple
105     """
106     debugMsg("Called Camera.setFocalPoint()")
107    
108     # print a warning message if get to here
109     overrideWarning("Camera.setFocalPoint")
110    
111     # I need to do some mucking around in here with coordinate systems
112     # and so on, but at present, we'll just use vtk's coord system
113    
114     self.xFocalPoint = pos[0]
115     self.yFocalPoint = pos[1]
116     self.zFocalPoint = pos[2]
117    
118     # now set the focal point position
119     self.renderer.runString("#Camera.setFocalPoint()\n")
120    
121     return
122    
123     def getFocalPoint(self):
124     """
125     Get the position of the focal point of the Camera
126    
127     Returns the position of the focal point in a tuple of form
128     (xPos, yPos, zPos)
129     """
130     debugMsg("Called Camera.getFocalPoint()")
131    
132     return (self.xFocalPoint, self.yFocalPoint, self.zFocalPoint)
133    
134     def setElevation(self, elevation):
135     """
136     Set the elevation angle (in degrees) of the Camera
137    
138     @param elevation: The elevation angle (in degrees) of the Camera
139     @type elevation: float
140     """
141     debugMsg("Called Camera.setElevation()")
142    
143     self.elevation = elevation
144    
145     # print a warning message if get to here
146     overrideWarning("Camera.setElevation")
147    
148     return
149    
150     def getElevation(self):
151     """
152     Gets the elevation angle (in degrees) of the Camera
153     """
154     debugMsg("Called Camera.getElevation()")
155    
156     return self.elevation
157    
158     def setAzimuth(self, azimuth):
159     """
160     Set the azimuthal angle (in degrees) of the Camera
161    
162     @param azimuth: The azimuthal angle (in degrees) of the Camera
163     @type azimuth: float
164     """
165     debugMsg("Called Camera.setAzimuth()")
166    
167     self.azimuth = azimuth
168    
169     # print a warning message if get to here
170     overrideWarning("Camera.setAzimuth")
171    
172     return
173    
174     def getAzimuth(self):
175     """
176     Get the azimuthal angle (in degrees) of the Camera
177     """
178     debugMsg("Called Camera.getAzimuth()")
179    
180     return self.azimuth
181    
182     # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26