/[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 1148 - (show annotations)
Wed May 16 22:45:33 2007 UTC (12 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 4393 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 """
2 @author: John NGUI
3 """
4
5 import vtk
6
7 class Glyph3D:
8 """
9 Class that defines 3D glyphs.
10 """
11
12 def __init__(self):
13 """
14 Initialise the 3D glyph.
15 """
16
17 self.__vtk_glyph3D = vtk.vtkGlyph3D()
18
19 def _setupGlyph3D(self, object, source):
20 """
21 Setup the 3D glyph.
22
23 @type object: vtkDataSet, etc
24 @param object: Input for the 3D glyph
25 @type source: vtkPolyData
26 @param source: Source for the 3D glyph (i.e. Arrow2D, Arrow3D, etc)
27 """
28
29 self.__object = object
30 self.__source = source
31
32 self.__setInput()
33 self.__setSource()
34 self.setScaleModeByVector()
35 self.__setVectorModeByVector()
36 self.__setClampingOn()
37
38 self.__setScalingOn()
39 self.__setOrientOn()
40
41 def __setInput(self):
42 """
43 Set the input for the 3D glyph.
44 """
45
46 self.__vtk_glyph3D.SetInput(self.__object)
47
48 def __setSource(self):
49 """
50 Set the source for the 3D glyph.
51 """
52
53 self.__vtk_glyph3D.SetSource(self.__source)
54
55 def setScaleModeByVector(self):
56 """
57 Set the 3D glyph to scale according to the vector.
58 """
59
60 self.__vtk_glyph3D.SetScaleModeToScaleByVector()
61
62 def setScaleModeByScalar(self):
63 """
64 Set the 3D glyph to scale according to the scalar.
65 """
66
67 self.__vtk_glyph3D.SetScaleModeToScaleByScalar()
68
69 def _setColorModeByVector(self):
70 """
71 Set the 3D glyph to color according to the vector.
72 """
73
74 self.__vtk_glyph3D.SetColorModeToColorByVector()
75
76 def _setColorModeByScalar(self):
77 """
78 Set the 3D glyph to color according to the scalar.
79 """
80
81 self.__vtk_glyph3D.SetColorModeToColorByScalar()
82
83 def __setVectorModeByVector(self):
84 """
85 Set the 3D glyph vector mode according to the vector.
86 """
87
88 self.__vtk_glyph3D.SetVectorModeToUseVector()
89
90 def setScaleFactor(self, scale_factor):
91 """
92 Set the 3D glyph scale factor.
93
94 @type scale_factor: Number
95 @param scale_factor: Scale factor
96 """
97
98 self.__vtk_glyph3D.SetScaleFactor(scale_factor)
99
100 def __setClampingOn(self):
101 """
102 Enable clamping of "scalar" values to range.
103 """
104
105 self.__vtk_glyph3D.SetClamping(1)
106
107 def __setScalingOn(self):
108 """
109 Enable the scaling of the rendered object.
110 """
111
112 self.__vtk_glyph3D.ScalingOn()
113
114 def __setOrientOn(self):
115 """
116 Enable the orientation of the rendered object along the vector/normal.
117 """
118
119 self.__vtk_glyph3D.OrientOn()
120
121 def _setRange(self, range):
122 """
123 Set the range to map scalar values.
124
125 @type range: Two column tuple containing numbers
126 @param range: Range to map scalar values
127 """
128
129 self.__vtk_glyph3D.SetRange(range)
130
131 def _getGlyph3D(self):
132 """
133 Return the 3D glyph.
134
135 @rtype: vtkGlyph3D
136 @return: 3D glyph
137 """
138
139 return self.__vtk_glyph3D
140
141 def _getGlyph3DOutput(self):
142 """
143 Return the output of the 3D glyph.
144
145 @rtype: vtkPolyData
146 @return Polygonal data
147 """
148
149 return self.__vtk_glyph3D.GetOutput()
150
151
152 ###############################################################################
153
154
155 class TensorGlyph:
156 """
157 Class that defines tensor glyphs.
158 """
159
160 def __init__(self):
161 """
162 Initialise the tensor glyph.
163 """
164
165 self.__vtk_tensor_glyph = vtk.vtkTensorGlyph()
166
167 def _setupTensorGlyph(self, object, source):
168 """
169 Setup the tensor glyph.
170
171 @type object: vtkDataSet, etc
172 @param object: Input for the 3D glyph
173 @type source: vtkPolyData
174 @param source: Source for the 3D glyph (i.e. Sphere, etc)
175 """
176
177 self.__object = object
178 self.__source = source
179
180 self.__setInput()
181 self.__setSource()
182 self.__vtk_tensor_glyph.ClampScalingOn()
183
184 def __setInput(self):
185 """
186 Set the input for the tensor glyph.
187 """
188
189 self.__vtk_tensor_glyph.SetInput(self.__object)
190
191 def __setSource(self):
192 """
193 Set the source for the tensor glyph.
194 """
195
196 self.__vtk_tensor_glyph.SetSource(self.__source)
197
198 def setScaleFactor(self, scale_factor):
199 """
200 Set the scale factor for the tensor glyph.
201
202 @type scale_factor: Number
203 @param scale_factor: Scale factor
204 """
205
206 self.__vtk_tensor_glyph.SetScaleFactor(scale_factor)
207
208 def setMaxScaleFactor(self, max_scale_factor):
209 """
210 Set the maximum allowable scale factor for the tensor glyph.
211
212 @type max_scale_factor: Number
213 @param max_scale_factor: Maximum allowable scale factor.
214 """
215
216 self.__vtk_tensor_glyph.SetMaxScaleFactor(max_scale_factor)
217
218 def _getTensorGlyphOutput(self):
219 """
220 Return the output of the tensor glyph.
221
222 @rtype: vtkPolyData
223 @return: Polygonal data
224 """
225
226 return self.__vtk_tensor_glyph.GetOutput()
227

  ViewVC Help
Powered by ViewVC 1.1.26