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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 861 - (hide annotations)
Fri Sep 29 06:54:46 2006 UTC (12 years, 11 months ago) by jongui
File MIME type: text/x-python
File size: 3502 byte(s)
- Added some simple plane cutting animation and storing them to file.

1 gross 792 """
2 jongui 839 @author: John Ngui
3     @author: Lutz Gross
4 gross 792 """
5    
6 jongui 835 class Position:
7     """
8 jongui 860 Class that defines the coordinate of components in the visualization.
9 jongui 835 """
10 gross 792
11 jongui 835 def __init__(self, x_coor, y_coor, z_coor):
12     """
13     @type x_coor: Number
14 jongui 860 @param x_coor: X coordinate
15 jongui 835 @type y_coor: Number
16 jongui 860 @param y_coor: Y coordinate
17 jongui 835 @type z_coor: Number
18 jongui 860 @param z_coor: Z coordinate
19 jongui 835 """
20    
21     self.x_coor = x_coor
22     self.y_coor = y_coor
23     self.z_coor = z_coor
24 gross 792
25 jongui 835 def getXCoor(self):
26     """
27     Return the x coordinate.
28    
29     @rtype: Number
30     @return: X coordinate
31     """
32     return self.x_coor
33    
34     def getYCoor(self):
35     """
36     Return the y coordinate.
37    
38     @rtype: Number
39     @return: Y coordiante
40     """
41    
42     return self.y_coor
43    
44     def getZCoor(self):
45     """
46     Return the z coordinate
47    
48     @rtype: Number
49     @return: Z coordinate
50     """
51    
52     return self.z_coor
53    
54 jongui 860 import vtk
55    
56     class Transform:
57     """
58     Class that defines the orientation of rendered objects.
59     """
60    
61     def __init__(self):
62     self.vtk_transform = vtk.vtkTransform()
63     # Set the transformation to occur after any transformations
64     # represented by the current matrix.
65 jongui 861 #self.vtk_transform.PostMultiply()
66 jongui 860
67     def translate(self, x_offset, y_offset, z_offset):
68     """
69     Translate the rendered object along the x, y and z-axes.
70     @type x_offset: Number
71     @param x_offset: Amount to translate along the x-axis
72     @type y_offset: Number
73     @param y_offset: Amount to translate along the y-axis
74     @type z_offset: Number
75     @param z_offset: Amount to translate along the z-axis
76     """
77    
78     self.vtk_transform.Translate(-x_offset, -y_offset, -z_offset)
79    
80     def normalTranslate(self, offset):
81     """
82     Translate the rendered object along the plane normal.
83     @type offset: Number
84     @param offset: Amount to translate along the plane normal
85     """
86    
87     self.vtk_transform.Push(offset)
88    
89     def scale(self, x_scale, y_scale, z_scale):
90     """
91     Scale the rendered object along the x, y and z-axes.
92     @type x_scale: Number
93     @param x_scale: Amount to scale along the x-axis
94     @type y_scale: Number
95     @param y_scale: Amount to scale along the y-axis
96     @type z_scale: Number
97     @param z_scale: Amount to scale along the z-axis
98     """
99    
100     self.vtk_transform.Scale(x_scalr, y_scale, z_scale)
101    
102     def rotateX(self, angle):
103     """
104     Rotate the rendered object along the x-axis.
105     @type angle: Number
106     @param angle: Angle to rotate the camera
107     """
108    
109     self.vtk_transform.RotateX(-angle)
110    
111     def rotateY(self, angle):
112     """
113     Rotate the rendered object along the y-axis.
114     @type angle: Number
115     @param angle: Angle to rotate the camera
116     """
117    
118     self.vtk_transform.RotateY(angle)
119    
120     def rotateZ(self, angle):
121     """
122     Rotate the rendered object along the z-axis.
123     @type angle: Number
124     @param angle: Angle to rotate the camera
125     """
126    
127     self.vtk_transform.RotateZ(angle)
128    
129     def xyPlane(self, offset = 0):
130     """
131     The plane orthogonal to the z-axis.
132     @type offset: Number
133     @param offset: Amount to translate
134     """
135    
136     self.translate(0, 0, offset)
137    
138     def yzPlane(self, offset = 0):
139     """
140     The plane orthogonal to the x-axis.
141     @type offset: Number
142     @param offset: Amount to translate
143     """
144    
145     self.translate(offset, 0, 0)
146     self.rotateY(89.9)
147    
148     def xzPlane(self, offset = 0):
149     """
150     The plane orthogonal to the y-axis.
151     @type offset: Number
152     @param offset: Amount to translate
153     """
154    
155     self.translate(0, offset, 0)
156 jongui 861 self.rotateX(89.9)
157 jongui 860
158     def getTransform(self):
159     """
160     Return the transform instance.
161     @rtype: vtkTransform
162     @return: VTK transform that is used to specify the orientation
163     of objects
164     """
165    
166     return self.vtk_transform

  ViewVC Help
Powered by ViewVC 1.1.26