# Diff of /trunk/pyvisi/py_src/geo.py

revision 852 by jongui, Wed Sep 20 03:23:16 2006 UTC revision 879 by jongui, Wed Oct 25 03:56:34 2006 UTC
# Line 5  Line 5
5
6  class Position:  class Position:
7      """      """
8      Class that defines the positioning of components in the visualization.      Class that defines the x, y and z coordinates of components.
9      """      """
10
11      def __init__(self, x_coor, y_coor, z_coor):      def __init__(self, x_coor, y_coor, z_coor):
12          """          """
Initialize the x,y and z coordinates.

13          @type x_coor: Number          @type x_coor: Number
14          @param x_coor: X coordinate in global position          @param x_coor: X coordinate
15          @type y_coor: Number          @type y_coor: Number
16          @param y_coor: Y coordinate in global position          @param y_coor: Y coordinate
17          @type z_coor: Number          @type z_coor: Number
18          @param z_coor: Z coordinate in global position          @param z_coor: Z coordinate
19          """          """
20
21          self.x_coor = x_coor          self.x_coor = x_coor
# Line 53  class Position: Line 51  class Position:
51
52          return self.z_coor          return self.z_coor
53
54    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            #self.vtk_transform.PostMultiply()
66
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            Set 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            Set 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            Set 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            self.rotateX(89.9)
157
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

Legend:
 Removed from v.852 changed lines Added in v.879