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

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

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

revision 948 by jongui, Mon Jan 29 07:22:43 2007 UTC revision 949 by jongui, Fri Feb 2 05:33:05 2007 UTC
# Line 6  import vtk Line 6  import vtk
6    
7  class Transform:  class Transform:
8      """      """
9      Class that defines the orientation of rendered objects.      Class that defines the orientation of planes.
10      """      """
11    
12      def __init__(self):      def __init__(self):
# Line 14  class Transform: Line 14  class Transform:
14          Initialise the transform object.          Initialise the transform object.
15          """          """
16    
17          # NOTE: VTK's values are not accurate. Origin is not exaclty (0,0,0)          # NOTE: VTK's values are not 100% accurate. Origin is not exaclty
18          # and normal is not exactly (0, 0, 1). There is a slight          #(0,0,0) and normal is not exactly (0, 0, 1). There is a slight
19          # variance. As a result, a slight alteration has to be done in order          # variance. As a result, a slight alteration has to be done in order
20          # for the rendered object to be displayed correctly. Otherwise, the          # for the plane to be displayed correctly. Otherwise, the
21          # rendered object may just fall outside the bounding box and nothing          # plane may just fall outside the bounding box and nothing
22          # is displayed.            # is displayed.  
   
23          self.__OFFSET_VARIANCE = 0.0000000001          self.__OFFSET_VARIANCE = 0.0000000001
24          self.__vtk_transform = vtk.vtkTransform()          self.__vtk_transform = vtk.vtkTransform()
25    
26      def translate(self, x_offset, y_offset, z_offset):      def translate(self, x_offset, y_offset, z_offset):
27          """          """
28          Translate the rendered object along the x, y and z-axes.          Translate the rendered object along the x, y and z-axes.
29    
30          @type x_offset: Number          @type x_offset: Number
31          @param x_offset: Amount to translate along the x-axis          @param x_offset: Amount to translate along the x-axis
32          @type y_offset: Number          @type y_offset: Number
# Line 39  class Transform: Line 39  class Transform:
39            
40      def rotateX(self, angle):      def rotateX(self, angle):
41          """          """
42          Rotate the rendered object along the x-axis.          Rotate the plane along the x-axis.
43    
44          @type angle: Number          @type angle: Number
45          @param angle: Angle to rotate the camera          @param angle: Angle to rotate the camera
46          """          """
# Line 48  class Transform: Line 49  class Transform:
49    
50      def rotateY(self, angle):      def rotateY(self, angle):
51          """          """
52          Rotate the rendered object along the y-axis.          Rotate the plane along the y-axis.
53    
54          @type angle: Number          @type angle: Number
55          @param angle: Angle to rotate the camera          @param angle: Angle to rotate the camera
56          """          """
# Line 58  class Transform: Line 60  class Transform:
60    
61      def rotateZ(self, angle):      def rotateZ(self, angle):
62          """          """
63          Rotate the rendered object along the z-axis.          Rotate the plane along the z-axis.
64    
65          @type angle: Number          @type angle: Number
66          @param angle: Angle to rotate the camera          @param angle: Angle to rotate the camera
67          """          """
# Line 68  class Transform: Line 71  class Transform:
71      def setPlaneToXY(self, offset = 0):      def setPlaneToXY(self, offset = 0):
72          """          """
73          Set the plane orthogonal to the z-axis.          Set the plane orthogonal to the z-axis.
74    
75          @type offset: Number          @type offset: Number
76          @param offset: Amount to translate          @param offset: Amount to translate along the z-axis
77          """          """
78            
79          self.translate(0, 0, offset + self.__OFFSET_VARIANCE)          self.translate(0, 0, offset + self.__OFFSET_VARIANCE)
# Line 77  class Transform: Line 81  class Transform:
81      def setPlaneToYZ(self, offset = 0):      def setPlaneToYZ(self, offset = 0):
82          """          """
83          Set the plane orthogonal to the x-axis.          Set the plane orthogonal to the x-axis.
84    
85          @type offset: Number          @type offset: Number
86          @param offset: Amount to translate          @param offset: Amount to translate along the x-axis
87          """          """
88                    
89          # NOTE: rotateY must come first before translate. Otherwise,          # NOTE: rotateY must come first before translate. Otherwise,
# Line 89  class Transform: Line 94  class Transform:
94      def setPlaneToXZ(self, offset = 0):      def setPlaneToXZ(self, offset = 0):
95          """          """
96          Set the plane orthogonal to the y-axis.          Set the plane orthogonal to the y-axis.
97    
98          @type offset: Number          @type offset: Number
99          @param offset: Amount to translate          @param offset: Amount to translate along the y-axis
100          """          """
101    
102          # rotateX must come first before translate. Otherwise, it won't work.          # rotateX must come first before translate. Otherwise, it won't work.
# Line 100  class Transform: Line 106  class Transform:
106      def _getTransform(self):      def _getTransform(self):
107          """          """
108          Return the transform instance.          Return the transform instance.
109    
110          @rtype: vtkTransform          @rtype: vtkTransform
111          @return: VTK transform that is used to specify the orientation          @return: Transform instance that is used to specify the orientation
112              of objects              of the plane
113          """          """
114    
115          return self.__vtk_transform          return self.__vtk_transform

Legend:
Removed from v.948  
changed lines
  Added in v.949

  ViewVC Help
Powered by ViewVC 1.1.26