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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 947 - (show annotations)
Wed Jan 31 07:17:43 2007 UTC (12 years, 9 months ago) by jongui
File MIME type: text/x-python
File size: 3724 byte(s)
added some epydocs.
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6
7 class Glyph3D:
8 """
9 Class that defines 3D glyph.
10 """
11
12 def __init__(self, object, source, range):
13 """
14 Initialise the 3D glyph.
15
16 @type object: vtkUnstructuredGrid, etc
17 @param object: Input for the 3D glyph
18 @type source: vtkPolyData
19 @param source: Source for the 3D glyph (i.e. Arrow2D, Arrow3D, etc)
20 @type range: Two column tuple
21 @param range: Range to map scalar values
22 """
23
24 self.__object = object
25 self.__source = source
26 self.__range = range
27 self.__vtk_glyph3D = vtk.vtkGlyph3D()
28
29 self.__setInput()
30 self.__setSource()
31 self.setScaleModeByVector()
32 self.__setVectorModeByVector()
33 self.__setClampingOn()
34
35 self.__setScalingOn()
36 self.__setOrientOn()
37 self.__setRange()
38
39 def __setInput(self):
40 """
41 Set the input for the 3D glyph.
42 """
43
44 self.__vtk_glyph3D.SetInput(self.__object)
45
46 def __setSource(self):
47 """
48 Set the source for the 3D glyph.
49 """
50
51 self.__vtk_glyph3D.SetSource(self.__source)
52
53 def setScaleModeByVector(self):
54 """
55 Set the 3D glyph to scale according to the vector.
56 """
57
58 self.__vtk_glyph3D.SetScaleModeToScaleByVector()
59
60 def setScaleModeByScalar(self):
61 """
62 Set the 3D glyph to scale according to the scalar.
63 """
64
65 self.__vtk_glyph3D.SetScaleModeToScaleByScalar()
66
67 def _setColorModeByVector(self):
68 """
69 Set the 3D glyph to color according to the vector.
70 """
71
72 self.__vtk_glyph3D.SetColorModeToColorByVector()
73
74 def _setColorModeByScalar(self):
75 """
76 Set the 3D glyph to color according to the scalar.
77 """
78
79 self.__vtk_glyph3D.SetColorModeToColorByScalar()
80
81 def __setVectorModeByVector(self):
82 """
83 Set the 3D glyph vector mode according to the vector.
84 """
85
86 self.__vtk_glyph3D.SetVectorModeToUseVector()
87
88 def setScaleFactor(self, scale_factor):
89 """
90 Set the 3D glyph scaling factor.
91
92 @type scale_factor: Number
93 @param scale_factor: Scale factor
94 """
95
96 self.__vtk_glyph3D.SetScaleFactor(scale_factor)
97
98 def __setClampingOn(self):
99 """
100 Enable clamping of "scalar" values to range.
101 """
102
103 self.__vtk_glyph3D.SetClamping(1)
104
105 def __setScalingOn(self):
106 """
107 Enable the scaling of the rendered object.
108 """
109
110 self.__vtk_glyph3D.ScalingOn()
111
112 def __setOrientOn(self):
113 """
114 Enable the orienting of the rendered object along vector/normal.
115 """
116
117 self.__vtk_glyph3D.OrientOn()
118
119 def __setRange(self):
120 """
121 Set the 3D glyph range to maps scalar values into.
122 """
123
124 self.__vtk_glyph3D.SetRange(self.__range)
125
126 def _getOutput(self):
127 """
128 Return the 3D glyph.
129
130 @rtype: vtkPolyData
131 @return Polygonal data
132 """
133
134 return self.__vtk_glyph3D.GetOutput()
135
136
137 class TensorGlyph:
138
139 def __init__(self, object, source):
140 self.__object = object
141 self.__source = source
142 self.__vtk_tensor_glyph = vtk.vtkTensorGlyph()
143
144 self.__setInput()
145 self.__setSource()
146
147 def __setInput(self):
148 """
149 Set the input for the tensor glyph.
150 """
151
152 self.__vtk_tensor_glyph.SetInput(self.__object)
153
154 def __setSource(self):
155 """
156 Set the source for the tensor glyph.
157 """
158
159 self.__vtk_tensor_glyph.SetSource(self.__source)
160
161 def setScaleFactor(self, scale_factor):
162 """
163 Set the tensor glyph scaling factor.
164
165 @type scale_factor: Number
166 @param scale_factor: Scale factor
167 """
168
169 self.__vtk_tensor_glyph.SetScaleFactor(scale_factor)
170
171 def setMaxScaleFactor(self, max_scale_factor):
172 """
173 Set the maximum allowable scale factor.
174
175 @type max_scale_factor: Number
176 @param max_scale_factor: Maximum allowable scale factor.
177 """
178
179 self.__vtk_tensor_glyph.SetMaxScaleFactor(scale_factor)
180
181 def _getOutput(self):
182 """
183 Return the tensor glyph.
184
185 @rtype: vtkPolyData
186 @return: Polygonal data
187 """
188
189 return self.__vtk_tensor_glyph.GetOutput()

  ViewVC Help
Powered by ViewVC 1.1.26