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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 600 - (show annotations)
Fri Mar 17 05:53:59 2006 UTC (13 years, 8 months ago) by gross
File MIME type: text/x-python
File size: 5415 byte(s)
some renaming
1 # Copyright (C) 2004-2005 Paul Cochrane
2 #
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # $Id: camera.py,v 1.13 2005/11/02 04:52:07 paultcochrane Exp $
18
19 ## @file camera.py
20
21 """
22 Class and functions associated with a pyvisi Camera object
23 """
24
25 # generic imports
26 from pyvisi.common import debugMsg, overrideWarning
27
28 from pyvisi.item import Item
29
30 __revision__ = '$Revision: 1.13 $'
31
32 class Camera(Item):
33 """
34 Camera class
35 """
36 def __init__(self, scene):
37 """
38 Initialisation of the Camera object
39
40 @param scene: The Scene object to add the Camera object to
41 @type scene: Scene object
42 """
43 Item.__init__(self)
44 debugMsg("Called Camera.__init__()")
45
46 # default x,y,z positions of Camera (specific to vtk)
47 self.xPos = 0.0
48 self.yPos = 0.0
49 self.zPos = 3.0
50
51 # default x,y,z positions of the Camers's focal point (specific to vtk)
52 self.xFocalPoint = 0.0
53 self.yFocalPoint = 0.0
54 self.zFocalPoint = 0.0
55
56 # default elevation and azimuth
57 self.elevation = 30 ####### we should try for matlab defaults
58 self.azimuth = 30
59
60 # keep a reference to the renderer so we can send stuff to it
61 self.renderer = scene.renderer
62
63 # some vtk initialisation commands
64 self.renderer.runString("# Camera.__init__()\n")
65
66 # initialise the position of the Camera
67 self.setPosition(self.xPos, self.yPos, self.zPos)
68 self.setFocalPoint(self.xFocalPoint, self.yFocalPoint, self.zFocalPoint)
69
70 def setPosition(self, *pos):
71 """
72 Set position of camera within scene
73
74 @param pos: Position to set camera in terms of x,y,z coordinates
75 @type pos: tuple
76 """
77 debugMsg("Called Camera.setPosition()")
78
79 # I need to do some mucking around in here with coordinate systems
80 # and so on, but at present, we'll just use vtk's coord system
81
82 self.xPos = pos[0]
83 self.yPos = pos[1]
84 self.zPos = pos[2]
85
86 # print a warning message if get to here
87 overrideWarning("Camera.setPosition")
88
89 # now to set the position
90
91 return
92
93 def getPosition(self):
94 """
95 Get the position of Camera within Scene
96
97 Returns the position in a tuple of form (xPos, yPos, zPos)
98 """
99 debugMsg("Called Camera.getPosition()")
100
101 return (self.xPos, self.yPos, self.zPos)
102
103 def setFocalPoint(self, *pos):
104 """
105 Sets the focal point of the Camera with the Scene
106
107 @param pos: Position to set the focal point
108 @type pos: tuple
109 """
110 debugMsg("Called Camera.setFocalPoint()")
111
112 # print a warning message if get to here
113 overrideWarning("Camera.setFocalPoint")
114
115 # I need to do some mucking around in here with coordinate systems
116 # and so on, but at present, we'll just use vtk's coord system
117
118 self.xFocalPoint = pos[0]
119 self.yFocalPoint = pos[1]
120 self.zFocalPoint = pos[2]
121
122 # now set the focal point position
123 self.renderer.runString("#Camera.setFocalPoint()\n")
124
125 return
126
127 def getFocalPoint(self):
128 """
129 Get the position of the focal point of the Camera
130
131 Returns the position of the focal point in a tuple of form
132 (xPos, yPos, zPos)
133 """
134 debugMsg("Called Camera.getFocalPoint()")
135
136 return (self.xFocalPoint, self.yFocalPoint, self.zFocalPoint)
137
138 def setElevation(self, elevation):
139 """
140 Set the elevation angle (in degrees) of the Camera
141
142 @param elevation: The elevation angle (in degrees) of the Camera
143 @type elevation: float
144 """
145 debugMsg("Called Camera.setElevation()")
146
147 self.elevation = elevation
148
149 # print a warning message if get to here
150 overrideWarning("Camera.setElevation")
151
152 return
153
154 def getElevation(self):
155 """
156 Gets the elevation angle (in degrees) of the Camera
157 """
158 debugMsg("Called Camera.getElevation()")
159
160 return self.elevation
161
162 def setAzimuth(self, azimuth):
163 """
164 Set the azimuthal angle (in degrees) of the Camera
165
166 @param azimuth: The azimuthal angle (in degrees) of the Camera
167 @type azimuth: float
168 """
169 debugMsg("Called Camera.setAzimuth()")
170
171 self.azimuth = azimuth
172
173 # print a warning message if get to here
174 overrideWarning("Camera.setAzimuth")
175
176 return
177
178 def getAzimuth(self):
179 """
180 Get the azimuthal angle (in degrees) of the Camera
181 """
182 debugMsg("Called Camera.getAzimuth()")
183
184 return self.azimuth
185
186 # vim: expandtab shiftwidth=4:

  ViewVC Help
Powered by ViewVC 1.1.26